From dad627c4fed48e2d2b059d12560108ac41d830af Mon Sep 17 00:00:00 2001 From: Logan Smith <32109138+logandgsmith@users.noreply.github.com> Date: Sat, 25 Nov 2023 15:46:09 -0500 Subject: [PATCH] Update seesaw_quadrotary.py Move `last_position[n] = rotary_pos` to after current position is evaluated. Without this, `last_position[n]` was being overwritten before it was compared to `rotary_pos`. --- examples/seesaw_quadrotary.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/seesaw_quadrotary.py b/examples/seesaw_quadrotary.py index 5cca3fa..6a6196f 100644 --- a/examples/seesaw_quadrotary.py +++ b/examples/seesaw_quadrotary.py @@ -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] @@ -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: