@@ -33,7 +33,7 @@ def compute_pixel_angles():
33
33
34
34
def degrees_between (a1 , a2 ):
35
35
smaller = min (a1 , a2 )
36
- larger = max (a1 , a2 )
36
+ larger = max (a1 , a2 )
37
37
return min (larger - smaller , 360 + smaller - larger )
38
38
39
39
@@ -65,10 +65,11 @@ def positive_degrees(angle):
65
65
66
66
while True :
67
67
debug = cpx .switch # True is toward the left
68
- x , y = cpx .acceleration [:2 ] # Ignore z
69
- down_angle = positive_degrees (angle_in_degrees (x , y ))
68
+ accel_x , accel_y = cpx .acceleration [:2 ] # Ignore z
69
+ down_angle = positive_degrees (angle_in_degrees (accel_x , accel_y ))
70
70
magnitude_limit = STANDARD_GRAVITY
71
- normalized_magnitude = min (math .sqrt (x * x + y * y ), magnitude_limit ) / magnitude_limit
71
+ normalized_magnitude = min (math .sqrt (accel_x * accel_x + accel_y * accel_y ),
72
+ magnitude_limit ) / magnitude_limit
72
73
73
74
pixels_lit = []
74
75
for i , pixel_position in enumerate (pixel_positions ):
@@ -80,5 +81,5 @@ def positive_degrees(angle):
80
81
if debug :
81
82
lit_formatted = ', ' .join (('{}: {:>3d}' .format (p , i ) for p , i in pixels_lit ))
82
83
print ('x: {:>6.2f}, y: {:>6.2f}, angle: {:>6.2f}, mag: {:>3.2f}, pixels: [{}]' .format (
83
- x , y , down_angle , normalized_magnitude , lit_formatted ))
84
+ accel_x , accel_y , down_angle , normalized_magnitude , lit_formatted ))
84
85
time .sleep (0.5 )
0 commit comments