Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(radio) - Add options to disable radio and model menu tabs. #3484

Merged
merged 19 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions companion/src/firmwares/edgetx/yaml_generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,21 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
if (hasColorLcd)
node["selectedTheme"] = rhs.selectedTheme;

// Radio level tabs control (global settings)
if (hasColorLcd)
node["radioThemesDisabled"] = (int)rhs.radioThemesDisabled;
node["radioGFDisabled"] = (int)rhs.radioGFDisabled;
node["radioTrainerDisabled"] = (int)rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] = (int)rhs.modelHeliDisabled;
node["modelFMDisabled"] = (int)rhs.modelFMDisabled;
node["modelCurvesDisabled"] = (int)rhs.modelCurvesDisabled;
node["modelGVDisabled"] = (int)rhs.modelGVDisabled;
node["modelLSDisabled"] = (int)rhs.modelLSDisabled;
node["modelSFDisabled"] = (int)rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] = (int)rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] = (int)rhs.modelTelemetryDisabled;

return node;
}

Expand Down Expand Up @@ -503,6 +518,20 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)

node["selectedTheme"] >> rhs.selectedTheme;

// Radio level tabs control (global settings)
node["radioThemesDisabled"] >> rhs.radioThemesDisabled;
node["radioGFDisabled"] >> rhs.radioGFDisabled;
node["radioTrainerDisabled"] >> rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] >> rhs.modelHeliDisabled;
node["modelFMDisabled"] >> rhs.modelFMDisabled;
node["modelCurvesDisabled"] >> rhs.modelCurvesDisabled;
node["modelGVDisabled"] >> rhs.modelGVDisabled;
node["modelLSDisabled"] >> rhs.modelLSDisabled;
node["modelSFDisabled"] >> rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] >> rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] >> rhs.modelTelemetryDisabled;

return true;
}
} // namespace YAML
43 changes: 37 additions & 6 deletions companion/src/firmwares/edgetx/yaml_modeldata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static const YamlLookupTable potsWarningModeLut = {
{ 2, "WARN_AUTO" },
};

static const YamlLookupTable jitterFilterLut = {
static const YamlLookupTable globalOnOffFilterLut = {
{ 0, "GLOBAL" },
{ 1, "OFF" },
{ 2, "ON" },
Expand Down Expand Up @@ -782,6 +782,8 @@ Node convert<ModelData>::encode(const ModelData& rhs)
Node node;
auto board = getCurrentBoard();

bool hasColorLcd = Boards::getCapability(board, Board::HasColorLcd);

node["semver"] = VERSION;

Node header;
Expand Down Expand Up @@ -896,7 +898,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)

node["thrTrimSw"] = rhs.thrTrimSwitch;
node["potsWarnMode"] = potsWarningModeLut << rhs.potsWarningMode;
node["jitterFilter"] = jitterFilterLut << rhs.jitterFilter;
node["jitterFilter"] = globalOnOffFilterLut << rhs.jitterFilter;

YamlPotsWarnEnabled potsWarnEnabled(&rhs.potsWarnEnabled[0]);
node["potsWarnEnabled"] = potsWarnEnabled.value;
Expand Down Expand Up @@ -943,7 +945,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["varioData"] = vario;
node["rssiSource"] = YamlTelemSource(rhs.rssiSource);

if (IS_TARANIS_X9(getCurrentBoard())) {
if (IS_TARANIS_X9(board)) {
node["voltsSource"] = YamlTelemSource(rhs.frsky.voltsSource);
node["altitudeSource"] = YamlTelemSource(rhs.frsky.altitudeSource);
}
Expand Down Expand Up @@ -986,7 +988,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["toplcdTimer"] = rhs.toplcdTimer;
}

if (IS_FAMILY_HORUS_OR_T16(getCurrentBoard())) {
if (IS_FAMILY_HORUS_OR_T16(board)) {
for (int i=0; i<MAX_CUSTOM_SCREENS; i++) {
const auto& csd = rhs.customScreens.customScreenData[i];
if (!csd.isEmpty()) {
Expand All @@ -1003,7 +1005,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)

node["modelRegistrationID"] = rhs.registrationId;

if (Boards::getCapability(getCurrentBoard(), Board::FunctionSwitches)) {
if (Boards::getCapability(board, Board::FunctionSwitches)) {
node["functionSwitchConfig"] = rhs.functionSwitchConfig;
node["functionSwitchGroup"] = rhs.functionSwitchGroup;
node["functionSwitchStartConfig"] = rhs.functionSwitchStartConfig;
Expand All @@ -1026,6 +1028,21 @@ Node convert<ModelData>::encode(const ModelData& rhs)
}
}

// Radio level tabs control (global settings)
if (hasColorLcd)
node["radioThemesDisabled"] = globalOnOffFilterLut << rhs.radioThemesDisabled;
node["radioGFDisabled"] = globalOnOffFilterLut << rhs.radioGFDisabled;
node["radioTrainerDisabled"] = globalOnOffFilterLut << rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] = globalOnOffFilterLut << rhs.modelHeliDisabled;
node["modelFMDisabled"] = globalOnOffFilterLut << rhs.modelFMDisabled;
node["modelCurvesDisabled"] = globalOnOffFilterLut << rhs.modelCurvesDisabled;
node["modelGVDisabled"] = globalOnOffFilterLut << rhs.modelGVDisabled;
node["modelLSDisabled"] = globalOnOffFilterLut << rhs.modelLSDisabled;
node["modelSFDisabled"] = globalOnOffFilterLut << rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] = globalOnOffFilterLut << rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] = globalOnOffFilterLut << rhs.modelTelemetryDisabled;

return node;
}

Expand Down Expand Up @@ -1099,7 +1116,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)

node["thrTrimSw"] >> rhs.thrTrimSwitch;
node["potsWarnMode"] >> potsWarningModeLut >> rhs.potsWarningMode;
node["jitterFilter"] >> jitterFilterLut >> rhs.jitterFilter;
node["jitterFilter"] >> globalOnOffFilterLut >> rhs.jitterFilter;

YamlPotsWarnEnabled potsWarnEnabled;
node["potsWarnEnabled"] >> potsWarnEnabled.value;
Expand Down Expand Up @@ -1219,6 +1236,20 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
node["usbJoystickCircularCut"] >> rhs.usbJoystickCircularCut;
node["usbJoystickCh"] >> rhs.usbJoystickCh;

// Radio level tabs control (global settings)
node["radioThemesDisabled"] >> globalOnOffFilterLut >> rhs.radioThemesDisabled;
node["radioGFDisabled"] >> globalOnOffFilterLut >> rhs.radioGFDisabled;
node["radioTrainerDisabled"] >> globalOnOffFilterLut >> rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] >> globalOnOffFilterLut >> rhs.modelHeliDisabled;
node["modelFMDisabled"] >> globalOnOffFilterLut >> rhs.modelFMDisabled;
node["modelCurvesDisabled"] >> globalOnOffFilterLut >> rhs.modelCurvesDisabled;
node["modelGVDisabled"] >> globalOnOffFilterLut >> rhs.modelGVDisabled;
node["modelLSDisabled"] >> globalOnOffFilterLut >> rhs.modelLSDisabled;
node["modelSFDisabled"] >> globalOnOffFilterLut >> rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] >> globalOnOffFilterLut >> rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] >> globalOnOffFilterLut >> rhs.modelTelemetryDisabled;

// preferably perform conversions here to avoid cluttering the field decodes

if (SemanticVersion(QString(rhs.semver)) < SemanticVersion("2.8.0")) {
Expand Down
14 changes: 14 additions & 0 deletions companion/src/firmwares/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@ class GeneralSettings {

char selectedTheme[SELECTED_THEME_NAME_LEN + 1];

// Radio level tabs control (global settings)
bool radioThemesDisabled;
bool radioGFDisabled;
bool radioTrainerDisabled;
// Model level tabs control (global setting)
bool modelHeliDisabled;
bool modelFMDisabled;
bool modelCurvesDisabled;
bool modelGVDisabled;
bool modelLSDisabled;
bool modelSFDisabled;
bool modelCustomScriptsDisabled;
bool modelTelemetryDisabled;

bool switchPositionAllowedTaranis(int index) const;
bool switchSourceAllowedTaranis(int index) const;
bool isPotAvailable(int index) const;
Expand Down
14 changes: 14 additions & 0 deletions companion/src/firmwares/modeldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ class ModelData {

char registrationId[8+1];

// Radio level tabs control (global settings)
unsigned int radioThemesDisabled;
unsigned int radioGFDisabled;
unsigned int radioTrainerDisabled;
// Model level tabs control (global setting)
unsigned int modelHeliDisabled;
unsigned int modelFMDisabled;
unsigned int modelCurvesDisabled;
unsigned int modelGVDisabled;
unsigned int modelLSDisabled;
unsigned int modelSFDisabled;
unsigned int modelCustomScriptsDisabled;
unsigned int modelTelemetryDisabled;

enum FunctionSwitchConfig {
FUNC_SWITCH_CONFIG_NONE,
FUNC_SWITCH_CONFIG_FIRST = FUNC_SWITCH_CONFIG_NONE,
Expand Down
2 changes: 2 additions & 0 deletions companion/src/generaledit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ set(generaledit_SRCS
calibration.cpp
hardware.cpp
trainer.cpp
generaloptions.cpp
)

set(generaledit_HDRS
calibration.h
hardware.h
trainer.h
generaloptions.h
)

set(generaledit_UIS
Expand Down
2 changes: 2 additions & 0 deletions companion/src/generaledit/generaledit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "calibration.h"
#include "hardware.h"
#include "../modeledit/customfunctions.h"
#include "generaloptions.h"
#include "verticalscrollarea.h"
#include "compounditemmodels.h"

Expand Down Expand Up @@ -69,6 +70,7 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
auto hwpnl = new HardwarePanel(this, generalSettings, firmware, editorItemModels);
addTab(hwpnl, tr("Hardware"));
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
addTab(new GeneralOptionsPanel(this, generalSettings, firmware), tr("Enabled Features"));

connect(hwpnl, &HardwarePanel::internalModuleChanged, this, [&] { intModChanged = true; });

Expand Down
160 changes: 160 additions & 0 deletions companion/src/generaledit/generaloptions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include "generaloptions.h"
#include "autocheckbox.h"

#include <QLabel>
#include <QGridLayout>

GeneralOptionsPanel::GeneralOptionsPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
GeneralPanel(parent, generalSettings, firmware),
board(firmware->getBoard()),
params(new QList<QWidget *>),
row(0),
col(0)
{
grid = new QGridLayout(this);

addSection(tr("Radio Menus"));

if (Boards::getCapability(board, Board::HasColorLcd)) {
addLabel(tr("Themes"));
AutoCheckBox *themesDisable = new AutoCheckBox(this);
themesDisable->setField(generalSettings.radioThemesDisabled, this, true);
params->append(themesDisable);
addParams();
}

addLabel(tr("Global Functions"));
AutoCheckBox *globalFuncsDisable = new AutoCheckBox(this);
globalFuncsDisable->setField(generalSettings.radioGFDisabled, this, true);
params->append(globalFuncsDisable);
addParams();

addLabel(tr("Trainer"));
AutoCheckBox *trainerDisable = new AutoCheckBox(this);
trainerDisable->setField(generalSettings.radioTrainerDisabled, this, true);
params->append(trainerDisable);
addParams();

row = 0;
col = 2;
addSection(tr("Model Menus"));

if (firmware->getCapability(Heli)) {
addLabel(tr("Heli"));
AutoCheckBox *heliDisable = new AutoCheckBox(this);
heliDisable->setField(generalSettings.modelHeliDisabled, this, true);
params->append(heliDisable);
addParams();
}

addLabel(tr("Flight Modes"));
AutoCheckBox *fmDisable = new AutoCheckBox(this);
fmDisable->setField(generalSettings.modelFMDisabled, this, true);
params->append(fmDisable);
addParams();

addLabel(tr("Curves"));
AutoCheckBox *curvesDisable = new AutoCheckBox(this);
curvesDisable->setField(generalSettings.modelCurvesDisabled, this, true);
params->append(curvesDisable);
addParams();

if (firmware->getCapability(Gvars)) {
addLabel(tr("Global Variables"));
AutoCheckBox *gvDisable = new AutoCheckBox(this);
gvDisable->setField(generalSettings.modelGVDisabled, this, true);
params->append(gvDisable);
addParams();
}

addLabel(tr("Logical Switches"));
AutoCheckBox *lsDisable = new AutoCheckBox(this);
lsDisable->setField(generalSettings.modelLSDisabled, this, true);
params->append(lsDisable);
addParams();

addLabel(tr("Special Functions"));
AutoCheckBox *sfDisable = new AutoCheckBox(this);
sfDisable->setField(generalSettings.modelSFDisabled, this, true);
params->append(sfDisable);
addParams();

addLabel(tr("Custom Mix Scripts"));
AutoCheckBox *cmsDisable = new AutoCheckBox(this);
cmsDisable->setField(generalSettings.modelCustomScriptsDisabled, this, true);
params->append(cmsDisable);
addParams();

addLabel(tr("Telemetry"));
AutoCheckBox *teleDisable = new AutoCheckBox(this);
teleDisable->setField(generalSettings.modelTelemetryDisabled, this, true);
params->append(teleDisable);
addParams();

addVSpring(grid, 0, grid->rowCount());
addHSpring(grid, grid->columnCount(), 0);
disableMouseScrolling();
}

GeneralOptionsPanel::~GeneralOptionsPanel()
{

}

void GeneralOptionsPanel::addLabel(QString text)
{
QLabel *label = new QLabel(this);
label->setText(text);
grid->addWidget(label, row, col);
}

void GeneralOptionsPanel::addLine()
{
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
line->setLineWidth(1);
line->setMidLineWidth(0);
grid->addWidget(line, row++, 0, 1, grid->columnCount());
}

void GeneralOptionsPanel::addParams()
{
int col = 0;
QGridLayout *subgrid = new QGridLayout();

for (int i = 0; i < params->size(); i++) {
subgrid->addWidget(params->at(i), 0, col++);
}

addHSpring(subgrid, col, 0);
grid->addLayout(subgrid, row++, this->col + 1);
params->clear();
}

void GeneralOptionsPanel::addSection(QString text)
{
addLabel(QString("<b>%1</b>").arg(text));
row++;
}
Loading