fix(radio): issues with rotary encoder (#5194)

- detection of initial direction of encoder after startup
- change of direction issue on radios with incorrectly wired encoder
- handle all wiring variations (without needing special #defines)
- handle the case when the radio is started with the encoder not on a detent position
This commit is contained in:
philmoz
2024-06-21 12:00:44 +10:00
committed by GitHub
parent cc630033b8
commit d84a78cc1d
6 changed files with 84 additions and 85 deletions
+3 -3
View File
@@ -272,14 +272,14 @@ static void rotaryDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
static int8_t prevDir = 0;
static uint32_t lastDt = 0;
rotenc_t newPos = rotaryEncoderGetRawValue();
rotenc_t diff = (newPos - prevPos) / ROTARY_ENCODER_GRANULARITY;
prevPos += diff * ROTARY_ENCODER_GRANULARITY;
rotenc_t newPos = rotaryEncoderGetValue();
rotenc_t diff = newPos - prevPos;
data->enc_diff = (int16_t)diff;
data->state = LV_INDEV_STATE_RELEASED;
if (diff != 0) {
prevPos = newPos;
reset_inactivity();
int8_t dir = 0;