[nv14] Make Ghost menu work with joystick trims (#1416)
* Update radio_ghost_module_config.cpp * Update board.h * Update keys_driver.cpp * Auto-formatting * Add functions simply so gtests compiles * Update board.h define TRIMS_EMULATE_BUTTONS to avoid HW dependent defines in other code * Update radio_ghost_module_config.cpp Use TRIMS_EMULATE_BUTTONS rather than PCBNV14 * `simu` code behind build flag also Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
Peter Feerick
parent
91d3c88421
commit
1d7b04d679
@@ -34,8 +34,13 @@ class GhostModuleConfigWindow: public Window
|
||||
|
||||
void paint(BitmapBuffer * dc) override
|
||||
{
|
||||
#if LCD_H > LCD_W
|
||||
constexpr coord_t xOffset = 20;
|
||||
constexpr coord_t xOffset2 = 140;
|
||||
#else
|
||||
constexpr coord_t xOffset = 140;
|
||||
constexpr coord_t xOffset2 = 260;
|
||||
#endif
|
||||
constexpr coord_t yOffset = 20;
|
||||
constexpr coord_t lineSpacing = 25;
|
||||
|
||||
@@ -84,6 +89,9 @@ RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
|
||||
buildHeader(&header);
|
||||
buildBody(&body);
|
||||
setFocus(SET_FOCUS_DEFAULT);
|
||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||
setTrimsAsButtons(true); // Use trim joysticks to operate menu (e.g. on NV14)
|
||||
#endif
|
||||
}
|
||||
|
||||
void RadioGhostModuleConfig::buildHeader(Window * window)
|
||||
@@ -102,19 +110,23 @@ void RadioGhostModuleConfig::onEvent(event_t event)
|
||||
switch (event) {
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
case EVT_ROTARY_LEFT:
|
||||
#else
|
||||
case EVT_KEY_BREAK(KEY_UP):
|
||||
#endif
|
||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYUP;
|
||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
case EVT_ROTARY_RIGHT:
|
||||
#else
|
||||
case EVT_KEY_BREAK(KEY_DOWN):
|
||||
#endif
|
||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYDOWN;
|
||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYPRESS;
|
||||
@@ -135,6 +147,9 @@ void RadioGhostModuleConfig::onEvent(event_t event)
|
||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||
RTOS_WAIT_MS(10);
|
||||
Page::onEvent(event);
|
||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||
setTrimsAsButtons(false); // switch trims back to normal
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -151,6 +166,9 @@ void RadioGhostModuleConfig::checkEvents()
|
||||
else if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_CLOSING) {
|
||||
RTOS_WAIT_MS(10);
|
||||
deleteLater();
|
||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||
setTrimsAsButtons(false); // switch trims back to normal
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user