Skip to content

Commit

Permalink
Allow SYS and MDL key navigation from within radio and model menus.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Sep 26, 2023
1 parent 6f40ea4 commit a48ca7a
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 261 deletions.
55 changes: 29 additions & 26 deletions radio/src/gui/colorlcd/menu_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

#include "menu_model.h"

#include "translations.h"
#include "view_channels.h"
#include "menu_radio.h"
#include "model_curves.h"
#include "model_flightmodes.h"
#include "model_gvars.h"
Expand All @@ -32,16 +31,15 @@
#include "model_mixer_scripts.h"
#include "model_mixes.h"
#include "model_outputs.h"
#include "model_select.h"
#include "model_setup.h"
#include "model_telemetry.h"
#include "opentx.h"
#include "special_functions.h"
#include "translations.h"
#include "view_channels.h"

ModelMenu::ModelMenu():
TabsGroup(ICON_MODEL)
{
build();
}
ModelMenu::ModelMenu() : TabsGroup(ICON_MODEL) { build(); }

void ModelMenu::build()
{
Expand All @@ -56,32 +54,24 @@ void ModelMenu::build()

addTab(new ModelSetupPage());
#if defined(HELI)
if (_modelHeliEnabled)
addTab(new ModelHeliPage());
if (_modelHeliEnabled) addTab(new ModelHeliPage());
#endif
#if defined(FLIGHT_MODES)
if (_modelFMEnabled)
addTab(new ModelFlightModesPage());
if (_modelFMEnabled) addTab(new ModelFlightModesPage());
#endif
addTab(new ModelInputsPage());
addTab(new ModelMixesPage());
addTab(new ModelOutputsPage());
if (_modelCurvesEnabled)
addTab(new ModelCurvesPage());
if (_modelCurvesEnabled) addTab(new ModelCurvesPage());
#if defined(GVARS)
if (_modelGVEnabled)
addTab(new ModelGVarsPage());
if (_modelGVEnabled) addTab(new ModelGVarsPage());
#endif
if (_modelLSEnabled)
addTab(new ModelLogicalSwitchesPage());
if (_modelSFEnabled)
addTab(new SpecialFunctionsPage(g_model.customFn));
if (_modelLSEnabled) addTab(new ModelLogicalSwitchesPage());
if (_modelSFEnabled) addTab(new SpecialFunctionsPage(g_model.customFn));
#if defined(LUA_MODEL_SCRIPTS)
if (_modelCustomScriptsEnabled)
addTab(new ModelMixerScriptsPage());
if (_modelCustomScriptsEnabled) addTab(new ModelMixerScriptsPage());
#endif
if (_modelTelemetryEnabled)
addTab(new ModelTelemetryPage());
if (_modelTelemetryEnabled) addTab(new ModelTelemetryPage());

#if defined(PCBNV14) || defined(PCBPL18)
addGoToMonitorsButton();
Expand Down Expand Up @@ -109,9 +99,21 @@ void ModelMenu::checkEvents()
void ModelMenu::onEvent(event_t event)
{
#if defined(HARDWARE_KEYS)
if (event == EVT_KEY_FIRST(KEY_MODEL)) {
if (event == EVT_KEY_BREAK(KEY_MODEL)) {
killEvents(event);
new ChannelsViewMenu();
new ChannelsViewMenu(this);
} else if (event == EVT_KEY_LONG(KEY_MODEL)) {
killEvents(KEY_MODEL);
onCancel();
new ModelLabelsWindow();
} else if (event == EVT_KEY_BREAK(KEY_SYS)) {
onCancel();
new RadioMenu();
} else if (event == EVT_KEY_LONG(KEY_SYS)) {
onCancel();
killEvents(KEY_SYS);
// Radio setup
(new RadioMenu())->setCurrentTab(2);
} else {
TabsGroup::onEvent(event);
}
Expand All @@ -122,7 +124,8 @@ void ModelMenu::onEvent(event_t event)
void ModelMenu::addGoToMonitorsButton()
{
new TextButton(
&header, {LCD_W / 2 + 6, MENU_TITLE_TOP + 1, LCD_W / 2 - 8, MENU_TITLE_HEIGHT - 2},
&header,
{LCD_W / 2 + 6, MENU_TITLE_TOP + 1, LCD_W / 2 - 8, MENU_TITLE_HEIGHT - 2},
STR_OPEN_CHANNEL_MONITORS, [=]() {
pushEvent(EVT_KEY_FIRST(KEY_MODEL));
return 0;
Expand Down
40 changes: 18 additions & 22 deletions radio/src/gui/colorlcd/menu_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,33 @@
* GNU General Public License for more details.
*/

#ifndef _MENU_MODEL_H_
#define _MENU_MODEL_H_
#pragma once

#include "tabsgroup.h"

class ModelMenu : public TabsGroup
{
public:
ModelMenu();

void onEvent(event_t event) override;
public:
ModelMenu();

#if defined(DEBUG_WINDOWS)
std::string getName() const override { return "ModelMenu"; }
std::string getName() const override { return "ModelMenu"; }
#endif

protected:
protected:
#if defined(PCBNV14) || defined(PCBPL18)
void addGoToMonitorsButton(void);
void addGoToMonitorsButton(void);
#endif
bool _modelHeliEnabled = true;
bool _modelFMEnabled = true;
bool _modelCurvesEnabled = true;
bool _modelGVEnabled = true;
bool _modelLSEnabled = true;
bool _modelSFEnabled = true;
bool _modelCustomScriptsEnabled = true;
bool _modelTelemetryEnabled = true;

void build();
void checkEvents() override;
bool _modelHeliEnabled = true;
bool _modelFMEnabled = true;
bool _modelCurvesEnabled = true;
bool _modelGVEnabled = true;
bool _modelLSEnabled = true;
bool _modelSFEnabled = true;
bool _modelCustomScriptsEnabled = true;
bool _modelTelemetryEnabled = true;

void build();
void checkEvents() override;
void onEvent(event_t event) override;
};

#endif // _MENU_MODEL_H_
53 changes: 31 additions & 22 deletions radio/src/gui/colorlcd/menu_radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,25 @@
* GNU General Public License for more details.
*/

#include "opentx.h"
#include "menu_radio.h"
#include "radio_setup.h"

#include "menu_model.h"
#include "model_select.h"
#include "myeeprom.h"
#include "opentx.h"
#include "radio_calibration.h"
#include "radio_hardware.h"
#include "radio_sdmanager.h"
#include "radio_setup.h"
#include "radio_theme.h"
#include "radio_tools.h"
#include "special_functions.h"
#include "radio_calibration.h"
#include "radio_trainer.h"
#include "radio_version.h"
#include "radio_hardware.h"
#include "radio_theme.h"
#include "myeeprom.h"
#include "special_functions.h"

RadioMenu::RadioMenu():
TabsGroup(ICON_RADIO)
{
build();
}
RadioMenu::RadioMenu() : TabsGroup(ICON_RADIO) { build(); }

RadioMenu::~RadioMenu()
{
storageCheck(true);
}
RadioMenu::~RadioMenu() { storageCheck(true); }

void RadioMenu::build()
{
Expand All @@ -52,12 +48,9 @@ void RadioMenu::build()
addTab(new RadioToolsPage());
addTab(new RadioSdManagerPage());
addTab(new RadioSetupPage());
if (_radioThemesEnabled)
addTab(new ThemeSetupPage());
if (_radioGFEnabled)
addTab(new SpecialFunctionsPage(g_eeGeneral.customFn));
if (_radioTrainerEnabled)
addTab(new RadioTrainerPage());
if (_radioThemesEnabled) addTab(new ThemeSetupPage());
if (_radioGFEnabled) addTab(new SpecialFunctionsPage(g_eeGeneral.customFn));
if (_radioTrainerEnabled) addTab(new RadioTrainerPage());
addTab(new RadioHardwarePage());
addTab(new RadioVersionPage());
}
Expand All @@ -76,3 +69,19 @@ void RadioMenu::checkEvents()
setCurrentTab(2);
}
}

void RadioMenu::onEvent(event_t event)
{
#if defined(HARDWARE_KEYS)
if (event == EVT_KEY_BREAK(KEY_MODEL)) {
onCancel();
new ModelMenu();
} else if (event == EVT_KEY_LONG(KEY_MODEL)) {
onCancel();
killEvents(KEY_MODEL);
new ModelLabelsWindow();
} else {
TabsGroup::onEvent(event);
}
#endif
}
27 changes: 13 additions & 14 deletions radio/src/gui/colorlcd/menu_radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@
* GNU General Public License for more details.
*/

#ifndef _MENU_RADIO_H_
#define _MENU_RADIO_H_
#pragma once

#include "tabsgroup.h"

class RadioMenu: public TabsGroup {
public:
RadioMenu();
~RadioMenu();
class RadioMenu : public TabsGroup
{
public:
RadioMenu();
~RadioMenu();

protected:
bool _radioThemesEnabled = true;
bool _radioGFEnabled = true;
bool _radioTrainerEnabled = true;
protected:
bool _radioThemesEnabled = true;
bool _radioGFEnabled = true;
bool _radioTrainerEnabled = true;

void build();
void checkEvents() override;
void build();
void checkEvents() override;
void onEvent(event_t event) override;
};

#endif // _MENU_RADIO_H_
Loading

0 comments on commit a48ca7a

Please sign in to comment.