Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- output of below code
- current position in degrees: 319
- move this many talon units: 484, to get to 130 degrees
- checking new position is at 130, 130
- -----------------------
- def get_position_degrees(talon_units):
- # will handle 0 to 1023 or more
- degrees = ((talon_units % 1023) * 360) / 1023
- return degrees
- def move_talon_units(degrees, current_talon_units):
- new_position = degrees * 1023 / 360
- # you only use these next two lines if talon_units exceed 1023 otherwise you return new_units
- current_position = current_talon_units % 1023
- units = (1023 - current_position) + new_position
- return units
- talon_units = 5000
- print("current position in degrees: %d" % get_position_degrees(talon_units))
- new_position_in_degrees = 130
- additional_talon_units = move_talon_units(new_position_in_degrees, talon_units)
- print("move this many talon units: %d, to get to %d degrees" %
- (
- additional_talon_units,
- new_position_in_degrees
- ))
- new_talon_units = talon_units + additional_talon_units
- print("checking new position is at %d, %d"%
- (
- new_position_in_degrees,
- get_position_degrees(new_talon_units)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement