Adds support for correct Alps EC10E roller hookup (#261)
Enhanced roller update (thx to Mike Blandford https://www.rcgroups.com/forums/showpost.php?p=46929617&postcount=9974 ) * TX12 should also have ROTARY_ENCODER_GRANULARITY 2
This commit is contained in:
@@ -580,10 +580,6 @@ bool setTrimValue(uint8_t phase, uint8_t idx, int trim);
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#define ROTARY_ENCODER_GRANULARITY (2 << g_eeGeneral.rotarySteps)
|
||||
#elif defined(RADIO_FAMILY_T16) && !defined(RADIO_T18)
|
||||
#define ROTARY_ENCODER_GRANULARITY (1)
|
||||
#elif defined(RADIO_TX12)
|
||||
#define ROTARY_ENCODER_GRANULARITY (1)
|
||||
#else
|
||||
#define ROTARY_ENCODER_GRANULARITY (2)
|
||||
#endif
|
||||
|
||||
@@ -72,25 +72,34 @@ void rotaryEncoderInit()
|
||||
void rotaryEncoderCheck()
|
||||
{
|
||||
#if (defined(RADIO_FAMILY_T16) && !defined(RADIO_T18)) || defined(RADIO_TX12)
|
||||
static uint8_t state = 0;
|
||||
static uint8_t state = 0;
|
||||
uint8_t pins = ROTARY_ENCODER_POSITION();
|
||||
|
||||
if (pins != (state & 0x03) && !(readKeys() & (1 << KEY_ENTER))) {
|
||||
if ((pins & 0x01) ^ ((pins & 0x02) >> 1)) {
|
||||
if ((state & 0x03) == 3)
|
||||
++rotencValue;
|
||||
else
|
||||
--rotencValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((state & 0x03) == 3)
|
||||
--rotencValue;
|
||||
else if ((state & 0x03) == 0)
|
||||
++rotencValue;
|
||||
}
|
||||
state &= ~0x03 ;
|
||||
state |= pins ;
|
||||
if ((pins ^ (state & 0x03)) == 0x03)
|
||||
{
|
||||
if (pins == 3)
|
||||
{
|
||||
rotencValue += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotencValue -= 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((state & 0x01) ^ ((pins & 0x02) >> 1))
|
||||
{
|
||||
rotencValue -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotencValue += 1;
|
||||
}
|
||||
}
|
||||
state &= ~0x03;
|
||||
state |= pins;
|
||||
#else
|
||||
uint8_t newPosition = ROTARY_ENCODER_POSITION();
|
||||
if (newPosition != rotencPosition && !(readKeys() & (1 << KEY_ENTER))) {
|
||||
|
||||
Reference in New Issue
Block a user