Use driver to deliver output depending on the state of an objects rotation Im trying to solve a certain problem. i've tried several different approaches, but since i have not found any solution yet, i'm asking you guys.

I have a rotating object(1). Now i want an other object(2) to change the value of it's shape-keys, for only the duration of one quarter of object 1's full 360° turn. (=90°)



I don't want to keyframe the whole process because i have several rotating object, but they all rotate in different speeds and offsets. I want to be able to change the speed in which object 1 is turning without having to manually adjust object 2.
So i would like to use drivers for this task. But i have no idea of scripted expressions being any more complicated than e.g. var*.5 etc.
Can somebody show me a way (scripted expression) which delivers an output of 1 for the duration of a 90° rotation and 0 for the remaining 270°?
Or even an other approach.
Angles 0-90° has positive cos and sin so we use this logic statements  cos(rot)&gt;0 and sin(rot) &gt;0 which evaluate to 1 when the angle is 0-90° and 0 otherwise :



Note: the angle is in radian