Moved last_position[n] = rotary_pos to after the if ( rotary_pos > last_positions[n]): block.
Without this, last_position[n] was being overwritten before it was compared to rotary_pos. This was causing if ( rotary_pos > last_positions[n]): to always evaluate to False which meant that colors would only move in one direction regardless of if the encoder was rotated clockwise or counterclockwise.
Moved
last_position[n] = rotary_pos
to after theif ( rotary_pos > last_positions[n]):
block.Without this,
last_position[n]
was being overwritten before it was compared torotary_pos
. This was causingif ( rotary_pos > last_positions[n]):
to always evaluate toFalse
which meant that colors would only move in one direction regardless of if the encoder was rotated clockwise or counterclockwise.