Rotary encoder refactoring

This commit is contained in:
Bertrand Songis
2019-04-30 14:55:21 +02:00
parent 4f6828aa1c
commit c28210e3e4
60 changed files with 363 additions and 652 deletions
-29
View File
@@ -20,10 +20,6 @@
#include "opentx.h"
#if defined(ROTARY_ENCODER_NAVIGATION)
uint32_t rotencPosition;
#endif
uint32_t readKeys()
{
uint32_t result = 0;
@@ -114,27 +110,6 @@ bool keyDown()
return readKeys() || readTrims();
}
#if defined(ROTARY_ENCODER_NAVIGATION)
void checkRotaryEncoder()
{
uint32_t newpos = ROTARY_ENCODER_POSITION();
if (newpos != rotencPosition && !keyState(KEY_ENTER)) {
if ((rotencPosition & 0x01) ^ ((newpos & 0x02) >> 1)) {
--rotencValue[0];
}
else {
++rotencValue[0];
}
rotencPosition = newpos;
#if !defined(BOOT)
if (g_eeGeneral.backlightMode & e_backlight_mode_keys) {
backlightOn();
}
#endif
}
}
#endif
/* TODO common to ARM */
void readKeysAndTrims()
{
@@ -289,8 +264,4 @@ void keysInit()
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOG_PINS;
GPIO_Init(GPIOG, &GPIO_InitStructure);
#endif
#if defined(ROTARY_ENCODER_NAVIGATION)
rotencPosition = ROTARY_ENCODER_POSITION();
#endif
}