Skip to content

Commit

Permalink
feat: option to automatically power off radio after inactivity (#3414)
Browse files Browse the repository at this point in the history
  • Loading branch information
pault4r authored Aug 28, 2024
1 parent 1852c8c commit af9ba9c
Show file tree
Hide file tree
Showing 41 changed files with 868 additions and 753 deletions.
2 changes: 2 additions & 0 deletions companion/src/firmwares/edgetx/yaml_generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["antennaMode"] = antennaModeLut << rhs.antennaMode;
node["pwrOnSpeed"] = rhs.pwrOnSpeed;
node["pwrOffSpeed"] = rhs.pwrOffSpeed;
node["pwrOffIfInactive"] = rhs.pwrOffIfInactive; // Power off after inactivity
node["disablePwrOnOffHaptic"] = (int)rhs.disablePwrOnOffHaptic;

for (int i = 0; i < CPN_MAX_SPECIAL_FUNCTIONS; i++) {
Expand Down Expand Up @@ -559,6 +560,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["backlightColor"] >> rhs.backlightColor;
node["pwrOnSpeed"] >> rhs.pwrOnSpeed;
node["pwrOffSpeed"] >> rhs.pwrOffSpeed;
node["pwrOffIfInactive"] >> rhs.pwrOffIfInactive; // Power off after inactivity
node["disablePwrOnOffHaptic"] >> rhs.disablePwrOnOffHaptic;

if (node["customFn"]) {
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ class GeneralSettings {
bool modelSFDisabled;
bool modelCustomScriptsDisabled;
bool modelTelemetryDisabled;
unsigned int pwrOffIfInactive;

int modelSelectLayout;
int labelSingleSelect;
Expand Down
9 changes: 9 additions & 0 deletions companion/src/generaledit/generalsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ ui(new Ui::GeneralSetup)
ui->pwrOnDelay->hide();
ui->pwrOffDelayLabel->hide();
ui->pwrOffDelay->hide();
ui->pwrOffIfInactiveLabel->hide();
ui->pwrOffIfInactiveSB->hide();
}
else if (!IS_TARANIS(board)) {
ui->pwrOnDelayLabel->hide();
Expand Down Expand Up @@ -524,6 +526,7 @@ void GeneralSetupPanel::setValues()

ui->pwrOnDelay->setCurrentIndex(pwrDelayFromYaml(generalSettings.pwrOnSpeed));
ui->pwrOffDelay->setCurrentIndex(pwrDelayFromYaml(generalSettings.pwrOffSpeed));
ui->pwrOffIfInactiveSB->setValue(generalSettings.pwrOffIfInactive);

ui->registrationId->setText(generalSettings.registrationId);

Expand Down Expand Up @@ -831,6 +834,12 @@ void GeneralSetupPanel::on_inactimerSB_editingFinished()
emit modified();
}

void GeneralSetupPanel::on_pwrOffIfInactiveSB_editingFinished()
{
generalSettings.pwrOffIfInactive = ui->pwrOffIfInactiveSB->value();
emit modified();
}

void GeneralSetupPanel::on_memwarnChkB_stateChanged(int)
{
generalSettings.disableMemoryWarning = ui->memwarnChkB->isChecked() ? 0 : 1;
Expand Down
2 changes: 2 additions & 0 deletions companion/src/generaledit/generalsetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class GeneralSetupPanel : public GeneralPanel
void on_favMultiMode_CB_currentIndexChanged(int);
void on_invertLCD_CB_stateChanged(int);

void on_pwrOffIfInactiveSB_editingFinished();

private:
Ui::GeneralSetup *ui;

Expand Down
Loading

0 comments on commit af9ba9c

Please sign in to comment.