Skip to content

Commit 3109848

Browse files
authored
Merge pull request #126 from logandgsmith/patch-1
Update seesaw_quadrotary.py to change color of neopixel based on direction of rotation
2 parents 262e47e + dad627c commit 3109848

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/seesaw_quadrotary.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
print(positions)
3636
for n, rotary_pos in enumerate(positions):
3737
if rotary_pos != last_positions[n]:
38-
print(f"Rotary #{n}: {rotary_pos}")
39-
last_positions[n] = rotary_pos
40-
4138
if switches[n].value: # Change the LED color if switch is not pressed
4239
if (
4340
rotary_pos > last_positions[n]
@@ -46,6 +43,9 @@
4643
else:
4744
colors[n] -= 8 # Advance backward through the colorwheel.
4845
colors[n] = (colors[n] + 256) % 256 # wrap around to 0-256
46+
# Set last position to current position after evaluating
47+
print(f"Rotary #{n}: {rotary_pos}")
48+
last_positions[n] = rotary_pos
4949

5050
# if switch is pressed, light up white, otherwise use the stored color
5151
if not switches[n].value:

0 commit comments

Comments
 (0)