Skip to content

Commit

Permalink
feat: option to disable power on/off haptic (#5017)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfeerick authored Jun 9, 2024
1 parent 2c800c0 commit 42153fb
Show file tree
Hide file tree
Showing 41 changed files with 960 additions and 824 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 @@ -279,6 +279,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["antennaMode"] = antennaModeLut << rhs.antennaMode;
node["pwrOnSpeed"] = rhs.pwrOnSpeed;
node["pwrOffSpeed"] = rhs.pwrOffSpeed;
node["disablePwrOnOffHaptic"] = (int)rhs.disablePwrOnOffHaptic;

for (int i = 0; i < CPN_MAX_SPECIAL_FUNCTIONS; i++) {
const CustomFunctionData& fn = rhs.customFn[i];
Expand Down Expand Up @@ -557,6 +558,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["backlightColor"] >> rhs.backlightColor;
node["pwrOnSpeed"] >> rhs.pwrOnSpeed;
node["pwrOffSpeed"] >> rhs.pwrOffSpeed;
node["disablePwrOnOffHaptic"] >> rhs.disablePwrOnOffHaptic;

if (node["customFn"]) {
// decode common for radio GF and model SF and conversion test assumes decoding a model
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 @@ -296,6 +296,7 @@ class GeneralSettings {

int pwrOnSpeed;
int pwrOffSpeed;
bool disablePwrOnOffHaptic;

char selectedTheme[SELECTED_THEME_NAME_LEN + 1];

Expand Down
8 changes: 8 additions & 0 deletions companion/src/generaledit/generalsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ ui(new Ui::GeneralSetup)
ui->pwrOnDelay->hide();
}

ui->pwrOnOffHaptic_CB->setChecked(!generalSettings.disablePwrOnOffHaptic); // Default is zero=checked

ui->registrationId->setValidator(new NameValidator(board, this));
ui->registrationId->setMaxLength(REGISTRATION_ID_LEN);

Expand Down Expand Up @@ -642,6 +644,12 @@ void GeneralSetupPanel::on_pwrOffDelay_valueChanged(int)
emit modified();
}

void GeneralSetupPanel::on_pwrOnOffHaptic_CB_stateChanged(int)
{
generalSettings.disablePwrOnOffHaptic = ui->pwrOnOffHaptic_CB->isChecked() ? 0 : 1;
emit modified();
}

void GeneralSetupPanel::on_beepVolume_SL_valueChanged()
{
generalSettings.beepVolume=ui->beepVolume_SL->value();
Expand Down
1 change: 1 addition & 0 deletions companion/src/generaledit/generalsetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class GeneralSetupPanel : public GeneralPanel

void on_pwrOnDelay_valueChanged(int);
void on_pwrOffDelay_valueChanged(int);
void on_pwrOnOffHaptic_CB_stateChanged(int);

void on_modelQuickSelect_CB_stateChanged(int);
void on_startSoundCB_stateChanged(int);
Expand Down
Loading

0 comments on commit 42153fb

Please sign in to comment.