Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PPR = 1440 * 4 # decoder position steps per revolution
- # reduce x modulo n, but giving result in range(base,base+n) rather than range(0,n).
- # default output range is -n/2..n/2-1 (if n even) or -(n-1)/2..(n-1)/2 (if n odd).
- def mod( x, n, base=-(n//2) ):
- return ( x - base ) % n + base
- # update position from shmem.position, unwrap from (mod 2**32) to integer
- position += mod( shmem.position - position, 2**32 )
- angle = position * 360 / PPR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement