Skip to content

Commit 97841e8

Browse files
authoredMar 31, 2025
fix(color): allow long press of RTN key to also exit setup pages (#6036)
1 parent f88e905 commit 97841e8

10 files changed

+41
-49
lines changed
 

‎radio/src/gui/colorlcd/libui/page.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ void Page::enableRefresh()
117117
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
118118
}
119119

120+
#if defined(HARDWARE_KEYS)
121+
void Page::onLongPressRTN() { onCancel(); }
122+
#endif
123+
120124
SubPage::SubPage(EdgeTxIcon icon, const char* title, const char* subtitle, bool pauseRefresh) :
121125
Page(icon, PAD_SMALL, pauseRefresh)
122126
{

‎radio/src/gui/colorlcd/libui/page.h

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class Page : public NavWindow
6666

6767
void checkEvents() override;
6868
bool bubbleEvents() override { return false; }
69+
70+
#if defined(HARDWARE_KEYS)
71+
void onLongPressRTN() override;
72+
#endif
6973
};
7074

7175
class SubPage : public Page

‎radio/src/gui/colorlcd/libui/tabsgroup.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ void TabsGroup::checkEvents()
363363
#if defined(HARDWARE_KEYS)
364364
void TabsGroup::onPressPGUP() { header->prevTab(); }
365365
void TabsGroup::onPressPGDN() { header->nextTab(); }
366+
void TabsGroup::onLongPressRTN() { onCancel(); }
366367
#endif
367368

368369
void TabsGroup::onClicked() { Keyboard::hide(false); }

‎radio/src/gui/colorlcd/libui/tabsgroup.h

+1
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,6 @@ class TabsGroup : public NavWindow
100100
#if defined(HARDWARE_KEYS)
101101
void onPressPGUP() override;
102102
void onPressPGDN() override;
103+
void onLongPressRTN() override;
103104
#endif
104105
};

‎radio/src/gui/colorlcd/libui/window.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ void NavWindow::onEvent(event_t event)
445445
case EVT_KEY_BREAK(KEY_PAGEUP):
446446
onPressPGUP();
447447
break;
448+
449+
case EVT_KEY_LONG(KEY_EXIT):
450+
onLongPressRTN();
451+
break;
448452
#endif
449453

450454
default:

‎radio/src/gui/colorlcd/libui/window.h

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class NavWindow : public Window
228228
virtual void onPressPGDN() {}
229229
virtual void onLongPressPGUP() {}
230230
virtual void onLongPressPGDN() {}
231+
virtual void onLongPressRTN() {}
231232
#endif
232233
virtual bool bubbleEvents() { return true; }
233234
void onEvent(event_t event) override;

‎radio/src/gui/colorlcd/model/model_templates.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ void TemplatePage::updateInfo()
8080
}
8181
}
8282

83-
#if defined(HARDWARE_KEYS)
84-
void TemplatePage::onEvent(event_t event)
85-
{
86-
if (event == EVT_KEY_LONG(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT)) {
87-
deleteLater();
88-
} else {
89-
Page::onEvent(event);
90-
}
91-
}
92-
#endif
93-
9483
class SelectTemplate : public TemplatePage
9584
{
9685
public:

‎radio/src/gui/colorlcd/model/model_templates.h

-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class TemplatePage : public Page
3333

3434
void updateInfo();
3535

36-
#if defined(HARDWARE_KEYS)
37-
void onEvent(event_t event) override;
38-
#endif
39-
4036
#if defined(DEBUG_WINDOWS)
4137
std::string getName() const override { return "TemplatePage"; }
4238
#endif

‎radio/src/gui/colorlcd/radio/radio_ghost_module_config.cpp

+14-21
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,6 @@ static void ghostmoduleconfig_cb(lv_event_t* e)
124124
}
125125
}
126126

127-
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
128-
void RadioGhostModuleConfig::onCancel()
129-
{
130-
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYLEFT;
131-
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
132-
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
133-
}
134-
#endif
135-
136127
RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
137128
Page(ICON_RADIO_TOOLS), moduleIdx(moduleIdx)
138129
{
@@ -162,21 +153,23 @@ void RadioGhostModuleConfig::buildBody(Window* window)
162153
}
163154

164155
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
165-
void RadioGhostModuleConfig::onEvent(event_t event)
156+
void RadioGhostModuleConfig::onCancel()
166157
{
167-
switch (event) {
168-
case EVT_KEY_LONG(KEY_EXIT):
169-
memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu));
170-
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
171-
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE;
172-
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
173-
RTOS_WAIT_MS(10);
174-
Page::onEvent(event);
158+
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYLEFT;
159+
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
160+
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
161+
}
162+
163+
void RadioGhostModuleConfig::onLongPressRTN()
164+
{
165+
memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu));
166+
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
167+
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE;
168+
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
169+
RTOS_WAIT_MS(10);
175170
#if defined(TRIMS_EMULATE_BUTTONS)
176-
setHatsAsKeys(false); // switch trims back to normal
171+
setHatsAsKeys(false); // switch trims back to normal
177172
#endif
178-
break;
179-
}
180173
}
181174

182175
void RadioGhostModuleConfig::checkEvents()

‎radio/src/gui/colorlcd/radio/radio_ghost_module_config.h

+12-13
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@
2525

2626
class RadioGhostModuleConfig: public Page
2727
{
28-
public:
29-
explicit RadioGhostModuleConfig(uint8_t moduleIdx);
28+
public:
29+
explicit RadioGhostModuleConfig(uint8_t moduleIdx);
3030

31-
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
32-
void onEvent(event_t event) override;
33-
void checkEvents() override;
34-
void onCancel() override;
35-
#endif
31+
protected:
32+
uint8_t moduleIdx;
3633

37-
protected:
38-
uint8_t moduleIdx;
34+
void buildHeader(Window * window);
35+
void buildBody(Window * window);
36+
void init();
3937

40-
void buildHeader(Window * window);
41-
void buildBody(Window * window);
42-
void init();
38+
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
39+
void checkEvents() override;
40+
void onCancel() override;
41+
void onLongPressRTN() override;
42+
#endif
4343
};
44-

0 commit comments

Comments
 (0)