Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update seesaw_quadrotary.py to change color of neopixel based on direction of rotation #126

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/seesaw_quadrotary.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
print(positions)
for n, rotary_pos in enumerate(positions):
if rotary_pos != last_positions[n]:
print(f"Rotary #{n}: {rotary_pos}")
last_positions[n] = rotary_pos

if switches[n].value: # Change the LED color if switch is not pressed
if (
rotary_pos > last_positions[n]
Expand All @@ -46,6 +43,9 @@
else:
colors[n] -= 8 # Advance backward through the colorwheel.
colors[n] = (colors[n] + 256) % 256 # wrap around to 0-256
# Set last position to current position after evaluating
print(f"Rotary #{n}: {rotary_pos}")
last_positions[n] = rotary_pos

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