Skip to content

Commit

Permalink
Easier rotary encoder inversion code (#1326)
Browse files Browse the repository at this point in the history
* Easier inversion code.

* Evaluate define INVERTED_ROTARY_ENCODER instead.

* Make Zorro roller direction more natural and matching also TX16S navigation style.
  • Loading branch information
rotorman authored and pfeerick committed Jan 1, 2022
1 parent 09b5d5f commit 8567608
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions radio/src/targets/common/arm/stm32/rotary_encoder_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,14 @@ void rotaryEncoderCheck()
#else
uint8_t newPosition = ROTARY_ENCODER_POSITION();
if (newPosition != rotencPosition && !(readKeys() & (1 << KEY_ENTER))) {
if ((rotencPosition & 0x01) ^ ((newPosition & 0x02) >> 1)) {
#if defined(ROTARY_ENCODER_INVERT)
++rotencValue;
if (!((rotencPosition & 0x01) ^ ((newPosition & 0x02) >> 1))) {
#else
--rotencValue;
if ((rotencPosition & 0x01) ^ ((newPosition & 0x02) >> 1)) {
#endif
} else {
#if defined(ROTARY_ENCODER_INVERT)
--rotencValue;
#else
} else {
++rotencValue;
#endif
}
rotencPosition = newPosition;
#endif
Expand Down

0 comments on commit 8567608

Please sign in to comment.