feat: Option for inverting rotary encoder direction (#1690)

* feat: Add option for rotary encoder direction
Based heavily on opentx/opentx#8852 by @3djc

* companion ui elements

* Cleanup

* Hook up UI, reading setting from yaml

* Teach simulator about rotEncDirection

* Simu and radio default scroll direction correction
Otherwise the "default" would be the opposite to how it has always been

* Remove what will be a confict with fix in #1586

* Wasn't using rotEncDirection consistently

* Zorro RE dir is opp to TX16, TX12, TPro, X9D+2019
This commit is contained in:
Peter Feerick
2022-03-22 16:14:57 +10:00
committed by GitHub
parent b36e456ca7
commit b54ad7169a
47 changed files with 416 additions and 326 deletions
+8
View File
@@ -102,6 +102,7 @@ enum {
ITEM_RADIO_SETUP_USB_MODE,
CASE_JACK_DETECT(ITEM_RADIO_SETUP_JACK_MODE)
ITEM_RADIO_SETUP_RX_CHANNEL_ORD,
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_INVERSE)
ITEM_RADIO_SETUP_STICK_MODE_LABELS,
ITEM_RADIO_SETUP_STICK_MODE,
ITEM_RADIO_SETUP_MAX
@@ -175,6 +176,7 @@ void menuRadioSetup(event_t event)
0,
0, // USB mode
CASE_JACK_DETECT(0) // Jack mode
CASE_ROTARY_ENCODER(0)
0, COL_TX_MODE, 0, 1/*to force edit mode*/});
if (event == EVT_ENTRY) {
@@ -658,6 +660,12 @@ void menuRadioSetup(event_t event)
#endif
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
case ITEM_RADIO_SETUP_ROTARY_INVERSE:
g_eeGeneral.rotEncDirection = editCheckBox(g_eeGeneral.rotEncDirection, RADIO_SETUP_2ND_COLUMN, y, STR_INVERT_ROTARY, attr, event);
break;
#endif
case ITEM_RADIO_SETUP_STICK_MODE:
lcdDrawChar(2*FW, y, '1'+reusableBuffer.generalSettings.stickMode, attr);
for (uint8_t i=0; i<NUM_STICKS; i++) {
+8
View File
@@ -95,6 +95,7 @@ enum MenuRadioSetupItems {
ITEM_RADIO_SETUP_SWITCHES_DELAY,
ITEM_RADIO_SETUP_USB_MODE,
ITEM_RADIO_SETUP_RX_CHANNEL_ORD,
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_INVERSE)
ITEM_RADIO_SETUP_STICK_MODE_LABELS,
ITEM_RADIO_SETUP_STICK_MODE,
ITEM_RADIO_SETUP_MAX
@@ -174,6 +175,7 @@ void menuRadioSetup(event_t event)
0, // switches delay
0, // USB mode
0, // RX channels order
CASE_ROTARY_ENCODER(0) // Invert rotary encoder
LABEL(TX_MODE),
0, // sticks mode
1 /*to force edit mode*/
@@ -588,6 +590,12 @@ void menuRadioSetup(event_t event)
}
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
case ITEM_RADIO_SETUP_ROTARY_INVERSE:
g_eeGeneral.rotEncDirection = editCheckBox(g_eeGeneral.rotEncDirection, RADIO_SETUP_2ND_COLUMN, y, STR_INVERT_ROTARY, attr, event);
break;
#endif
case ITEM_RADIO_SETUP_STICK_MODE:
lcdDrawChar(2*FW, y, '1'+reusableBuffer.generalSettings.stickMode, attr);
for (uint8_t i=0; i<4; i++) {
+6
View File
@@ -496,6 +496,12 @@ void RadioSetupPage::build(FormWindow * window)
new Choice(window, grid.getFieldSlot(), STR_USBMODES, USB_UNSELECTED_MODE, USB_MAX_MODE, GET_SET_DEFAULT(g_eeGeneral.USBMode));
grid.nextLine();
#if defined(ROTARY_ENCODER_NAVIGATION)
new StaticText(window, grid.getLabelSlot(), STR_INVERT_ROTARY, 0, COLOR_THEME_PRIMARY1);
new CheckBox(window, grid.getFieldSlot(), GET_SET_DEFAULT(g_eeGeneral.rotEncDirection));
grid.nextLine();
#endif
// RX channel order
new StaticText(window, grid.getLabelSlot(), STR_RXCHANNELORD, 0, COLOR_THEME_PRIMARY1); // RAET->AETR
choice = new Choice(window, grid.getFieldSlot(), 0, 4*3*2 - 1, GET_SET_DEFAULT(g_eeGeneral.templateSetup));