Although slightly more time consuming to set up, you can also do this with just the F-Curve of the driver since it's a simple value mapping.
Doing it this way will make your rig more lightweight than using a Python expression since the graph curve will be evaluated anyway.
The images and shortcut keys below are for Blender 2.79, but work the same on 2.80 and up.
- Set the driver type to Sum Values.
- Make a Transform Channel variable for the Local X Scale of the bone (easier to understand than having to write the property explicitly down to
- So the values of all variables of the driver (just one variable, in this case) will be summed, and the result will be used as the input "frame" (the time) within the F-Curve of the driver. Let's edit the F-Curve to change how it maps the input.
Set the curve extrapolation mode (Shift+E) to Constant Extrapolation.
Select both keyframes and press (T) for the Keyframe Interpolation dialog, set them to Linear keys (instead of the default of Bezier), which are faster to process.
Place one keyframe on frame 0.3, value 1.0.
- The other keyframe goes on frame 1.0, value 0.0.
So when the input is 0.3 you get an output of 1.0, when the input is 1.0 you get an output of 0.0.
PS you can use the View tab to place the 2D cursor with precision and use the (I) key to create new keyframes on the driver curve at that cursor location.