fix(ghst): Fix Ghost module remote menu for radios with rotenc (#2618)
This commit is contained in:
@@ -22,7 +22,6 @@
|
|||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "radio_ghost_module_config.h"
|
#include "radio_ghost_module_config.h"
|
||||||
#include "libopenui.h"
|
#include "libopenui.h"
|
||||||
|
|
||||||
#include "telemetry/ghost.h"
|
#include "telemetry/ghost.h"
|
||||||
#include "telemetry/ghost_menu.h"
|
#include "telemetry/ghost_menu.h"
|
||||||
|
|
||||||
@@ -85,6 +84,40 @@ class GhostModuleConfigWindow: public Window
|
|||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void ghostmoduleconfig_cb(lv_event_t* e)
|
||||||
|
{
|
||||||
|
RadioGhostModuleConfig* ghostmoduleconfig = (RadioGhostModuleConfig*)lv_event_get_user_data(e);
|
||||||
|
if (!ghostmoduleconfig || ghostmoduleconfig->deleted()) return;
|
||||||
|
|
||||||
|
uint32_t key = lv_event_get_key(e);
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case LV_KEY_LEFT:
|
||||||
|
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYUP;
|
||||||
|
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
||||||
|
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||||
|
break;
|
||||||
|
case LV_KEY_RIGHT:
|
||||||
|
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYDOWN;
|
||||||
|
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
||||||
|
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LV_KEY_ENTER:
|
||||||
|
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYPRESS;
|
||||||
|
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
||||||
|
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadioGhostModuleConfig::onCancel()
|
||||||
|
{
|
||||||
|
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYLEFT;
|
||||||
|
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
||||||
|
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||||
|
}
|
||||||
|
|
||||||
RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
|
RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
|
||||||
Page(ICON_RADIO_TOOLS),
|
Page(ICON_RADIO_TOOLS),
|
||||||
moduleIdx(moduleIdx)
|
moduleIdx(moduleIdx)
|
||||||
@@ -92,7 +125,11 @@ RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
|
|||||||
init();
|
init();
|
||||||
buildHeader(&header);
|
buildHeader(&header);
|
||||||
buildBody(&body);
|
buildBody(&body);
|
||||||
// setFocus(SET_FOCUS_DEFAULT);
|
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||||
|
lv_group_add_obj(lv_group_get_default(), lvobj);
|
||||||
|
lv_group_set_editing(lv_group_get_default(), true);
|
||||||
|
lv_obj_add_event_cb(lvobj, ghostmoduleconfig_cb, LV_EVENT_KEY, this);
|
||||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||||
setTrimsAsButtons(true); // Use trim joysticks to operate menu (e.g. on NV14)
|
setTrimsAsButtons(true); // Use trim joysticks to operate menu (e.g. on NV14)
|
||||||
#endif
|
#endif
|
||||||
@@ -112,38 +149,6 @@ void RadioGhostModuleConfig::buildBody(FormWindow * window)
|
|||||||
void RadioGhostModuleConfig::onEvent(event_t event)
|
void RadioGhostModuleConfig::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
switch (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;
|
|
||||||
|
|
||||||
#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;
|
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_ENTER):
|
|
||||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYPRESS;
|
|
||||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
|
||||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVT_KEY_BREAK(KEY_EXIT):
|
|
||||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYLEFT;
|
|
||||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
|
||||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVT_KEY_LONG(KEY_EXIT):
|
case EVT_KEY_LONG(KEY_EXIT):
|
||||||
memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu));
|
memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu));
|
||||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
|
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class RadioGhostModuleConfig: public Page
|
|||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
|
void onCancel() override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user