feat(el18): Use trim hats as keys for navigation (#3894)
Co-authored-by: elecpower <neilh713@tpg.com.au> Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
elecpower
Peter Feerick
parent
b733ec4eae
commit
f40fa1a64b
@@ -235,7 +235,27 @@ extern "C" void touchDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#if defined(USE_HATS_AS_KEYS)
|
||||
|
||||
int16_t getEmuRotaryData();
|
||||
|
||||
static void rotaryDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
{
|
||||
int16_t diff = getEmuRotaryData();
|
||||
|
||||
if(diff != 0) {
|
||||
reset_inactivity();
|
||||
audioKeyPress();
|
||||
|
||||
data->enc_diff = diff;
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
}
|
||||
|
||||
// libopenui_depends.h
|
||||
int8_t rotaryEncoderGetAccel() { return 0; }
|
||||
|
||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||
extern volatile uint32_t rotencDt;
|
||||
static int8_t _rotary_enc_accel = 0;
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
|
||||
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)
|
||||
setTrimsAsButtons(true); // Use trim joysticks to operate menu (e.g. on NV14)
|
||||
setHatsAsKeys(true); // Use trim joysticks to operate menu (e.g. on NV14)
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ void RadioGhostModuleConfig::onEvent(event_t event)
|
||||
RTOS_WAIT_MS(10);
|
||||
Page::onEvent(event);
|
||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||
setTrimsAsButtons(false); // switch trims back to normal
|
||||
setHatsAsKeys(false); // switch trims back to normal
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ void RadioGhostModuleConfig::checkEvents()
|
||||
RTOS_WAIT_MS(10);
|
||||
deleteLater();
|
||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||
setTrimsAsButtons(false); // switch trims back to normal
|
||||
setHatsAsKeys(false); // switch trims back to normal
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ void RadioSetupPage::build(FormWindow * window)
|
||||
new Choice(line, rect_t{}, STR_USBMODES, USB_UNSELECTED_MODE, USB_MAX_MODE,
|
||||
GET_SET_DEFAULT(g_eeGeneral.USBMode));
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS)
|
||||
line = window->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_ROTARY_ENC_MODE, 0, COLOR_THEME_PRIMARY1);
|
||||
new Choice(line, rect_t{}, STR_ROTARY_ENC_OPT, ROTARY_ENCODER_MODE_NORMAL,
|
||||
@@ -811,6 +811,13 @@ void RadioSetupPage::build(FormWindow * window)
|
||||
GET_SET_DEFAULT(g_eeGeneral.rotEncMode));
|
||||
#endif
|
||||
|
||||
#if defined(USE_HATS_AS_KEYS)
|
||||
line = window->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_HATSMODE, 0, COLOR_THEME_PRIMARY1);
|
||||
new Choice(line, rect_t{}, STR_HATSOPT, HATSMODE_TRIMS_ONLY, HATSMODE_SWITCHABLE,
|
||||
GET_SET_DEFAULT(g_eeGeneral.hatsMode));
|
||||
#endif
|
||||
|
||||
// RX channel order
|
||||
line = window->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_DEF_CHAN_ORD, 0,
|
||||
|
||||
@@ -274,7 +274,7 @@ void TabsGroup::onEvent(event_t event)
|
||||
#if defined(HARDWARE_KEYS)
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP)
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS)
|
||||
if (event == EVT_KEY_FIRST(KEY_PAGEDN)) {
|
||||
#else
|
||||
if (event == EVT_KEY_BREAK(KEY_PAGEDN)) {
|
||||
@@ -283,7 +283,7 @@ void TabsGroup::onEvent(event_t event)
|
||||
uint8_t current = header.carousel.getCurrentIndex() + 1;
|
||||
setCurrentTab(current >= tabs.size() ? 0 : current);
|
||||
}
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP)
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS)
|
||||
else if (event == EVT_KEY_FIRST(KEY_PAGEUP)) {
|
||||
#else
|
||||
else if (event == EVT_KEY_LONG(KEY_PAGEDN)) {
|
||||
|
||||
@@ -55,6 +55,14 @@ TrimsSetup::TrimsSetup() : Page(ICON_MODEL_SETUP)
|
||||
auto btn_obj = btn->getLvObj();
|
||||
lv_obj_set_width(btn_obj, lv_pct(100));
|
||||
|
||||
#if defined(USE_HATS_AS_KEYS)
|
||||
// Hats mode for NV14/EL18
|
||||
line = body.newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_HATSMODE, 0, COLOR_THEME_PRIMARY1);
|
||||
new Choice(line, rect_t{}, STR_HATSOPT, HATSMODE_TRIMS_ONLY, HATSMODE_GLOBAL,
|
||||
GET_SET_DEFAULT(g_model.hatsMode));
|
||||
#endif
|
||||
|
||||
// Trim step
|
||||
line = body.newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_TRIMINC, 0,
|
||||
|
||||
@@ -280,7 +280,7 @@ void ViewMain::onEvent(event_t event)
|
||||
new ScreenMenu();
|
||||
break;
|
||||
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP)
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS)
|
||||
case EVT_KEY_FIRST(KEY_PAGEDN):
|
||||
#else
|
||||
case EVT_KEY_BREAK(KEY_PAGEDN):
|
||||
@@ -293,7 +293,7 @@ void ViewMain::onEvent(event_t event)
|
||||
|
||||
//TODO: these need to go away!
|
||||
// -> board code should map the keys as required
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP)
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS)
|
||||
case EVT_KEY_FIRST(KEY_PAGEUP):
|
||||
#else
|
||||
case EVT_KEY_LONG(KEY_PAGEDN):
|
||||
|
||||
Reference in New Issue
Block a user