fix(cpn): Align brightness settings with radio, Speaker Volume values (#4156)

This commit is contained in:
philmoz
2023-10-16 18:18:55 +10:00
committed by GitHub
parent 7bf24f668a
commit d473fab90c
8 changed files with 68 additions and 13 deletions
+28 -5
View File
@@ -346,7 +346,7 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index)
if (index < DIM(switches)) if (index < DIM(switches))
return switches[index]; return switches[index];
} }
else if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) { else if (IS_FLYSKY_NV14(board)) {
const Board::SwitchInfo switches[] = { const Board::SwitchInfo switches[] = {
{SWITCH_2POS, "SA"}, {SWITCH_2POS, "SA"},
{SWITCH_3POS, "SB"}, {SWITCH_3POS, "SB"},
@@ -360,6 +360,20 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index)
if (index < DIM(switches)) if (index < DIM(switches))
return switches[index]; return switches[index];
} }
else if (IS_FLYSKY_EL18(board)) {
const Board::SwitchInfo switches[] = {
{SWITCH_2POS, "SA"},
{SWITCH_3POS, "SB"},
{SWITCH_3POS, "SC"},
{SWITCH_2POS, "SD"},
{SWITCH_2POS, "SE"},
{SWITCH_3POS, "SF"},
{SWITCH_3POS, "SG"},
{SWITCH_TOGGLE, "SH"}
};
if (index < DIM(switches))
return switches[index];
}
else if (IS_FAMILY_HORUS_OR_T16(board)) { else if (IS_FAMILY_HORUS_OR_T16(board)) {
const Board::SwitchInfo switches[] = { const Board::SwitchInfo switches[] = {
{SWITCH_3POS, "SA"}, {SWITCH_3POS, "SA"},
@@ -700,10 +714,17 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board, const
{tr("S3").toStdString(), "POT3"}, {tr("S3").toStdString(), "POT3"},
}); });
} else if ((IS_TARANIS_SMALL(board) && !IS_JUMPER_TLITE(board)) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) { } else if ((IS_TARANIS_SMALL(board) && !IS_JUMPER_TLITE(board)) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) {
tbl.insert(tbl.end(), { if (version < adcVersion) {
{tr("S1").toStdString(), "POT1"}, tbl.insert(tbl.end(), {
{tr("S2").toStdString(), "POT2"}, {tr("S1").toStdString(), "POT1"},
}); {tr("S2").toStdString(), "POT2"},
});
} else {
tbl.insert(tbl.end(), {
{tr("S1").toStdString(), "P1", 4},
{tr("S2").toStdString(), "P2", 5},
});
}
} else if (IS_TARANIS_X9(board)) { } else if (IS_TARANIS_X9(board)) {
if (version < adcVersion) { if (version < adcVersion) {
tbl.insert(tbl.end(), { tbl.insert(tbl.end(), {
@@ -892,6 +913,8 @@ QString Boards::potTypeToString(int value)
return tr("Multi pos switch"); return tr("Multi pos switch");
case POT_WITHOUT_DETENT: case POT_WITHOUT_DETENT:
return tr("Pot without detent"); return tr("Pot without detent");
case POT_SLIDER_WITH_DETENT:
return tr("slider");
default: default:
return CPN_STR_UNKNOWN_ITEM; return CPN_STR_UNKNOWN_ITEM;
} }
+1
View File
@@ -83,6 +83,7 @@ namespace Board {
POT_WITH_DETENT, POT_WITH_DETENT,
POT_MULTIPOS_SWITCH, POT_MULTIPOS_SWITCH,
POT_WITHOUT_DETENT, POT_WITHOUT_DETENT,
POT_SLIDER_WITH_DETENT,
POT_TYPE_COUNT POT_TYPE_COUNT
}; };
@@ -184,6 +184,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["fai"] = (int)rhs.fai; node["fai"] = (int)rhs.fai;
node["disableMemoryWarning"] = (int)rhs.disableMemoryWarning; node["disableMemoryWarning"] = (int)rhs.disableMemoryWarning;
node["beepMode"] = rhs.beeperMode; node["beepMode"] = rhs.beeperMode;
node["alarmsFlash"] = (int)rhs.flashBeep;
node["disableAlarmWarning"] = (int)rhs.disableAlarmWarning; node["disableAlarmWarning"] = (int)rhs.disableAlarmWarning;
node["disableRssiPoweroffAlarm"] = (int)rhs.disableRssiPoweroffAlarm; node["disableRssiPoweroffAlarm"] = (int)rhs.disableRssiPoweroffAlarm;
node["USBMode"] = rhs.usbMode; node["USBMode"] = rhs.usbMode;
@@ -297,7 +298,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
seq = getCurrentFirmware()->getAnalogInputSeqADC(adcoffset + i) - sticks; seq = getCurrentFirmware()->getAnalogInputSeqADC(adcoffset + i) - sticks;
if (seq >= 0 && seq < maxPots) { if (seq >= 0 && seq < maxPots) {
strcpy(potName[seq], rhs.sliderName[i]); strcpy(potName[seq], rhs.sliderName[i]);
potConfig[seq] = rhs.sliderConfig[i]; potConfig[seq] = ((rhs.sliderConfig[i] == Board::SLIDER_WITH_DETENT) ? Board::POT_SLIDER_WITH_DETENT : Board::POT_NONE);
} }
} }
@@ -436,6 +437,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["fai"] >> rhs.fai; node["fai"] >> rhs.fai;
node["disableMemoryWarning"] >> rhs.disableMemoryWarning; node["disableMemoryWarning"] >> rhs.disableMemoryWarning;
node["beepMode"] >> rhs.beeperMode; node["beepMode"] >> rhs.beeperMode;
node["alarmsFlash"] >> rhs.flashBeep;
node["disableAlarmWarning"] >> rhs.disableAlarmWarning; node["disableAlarmWarning"] >> rhs.disableAlarmWarning;
node["disableRssiPoweroffAlarm"] >> rhs.disableRssiPoweroffAlarm; node["disableRssiPoweroffAlarm"] >> rhs.disableRssiPoweroffAlarm;
node["USBMode"] >> rhs.usbMode; node["USBMode"] >> rhs.usbMode;
@@ -576,7 +578,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
else { else {
for (int i = 0; i < Boards::getCapability(board, Board::Sliders); i++) { for (int i = 0; i < Boards::getCapability(board, Board::Sliders); i++) {
strcpy(rhs.sliderName[i], potName[numPots + i]); strcpy(rhs.sliderName[i], potName[numPots + i]);
rhs.sliderConfig[i] = potConfig[numPots + i]; rhs.sliderConfig[i] = ((potConfig[numPots + i] == Board::POT_SLIDER_WITH_DETENT) ? Board::SLIDER_WITH_DETENT : Board::SLIDER_NONE);
} }
} }
@@ -264,6 +264,8 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
} }
int ana_idx = getCurrentFirmware()->getAnalogInputIndex(ana_str.c_str()); int ana_idx = getCurrentFirmware()->getAnalogInputIndex(ana_str.c_str());
if (ana_idx < 0)
ana_idx = getCurrentFirmware()->getAnalogInputIndexADC(ana_str.c_str());
if (ana_idx >= 0) { if (ana_idx >= 0) {
rhs.type = SOURCE_TYPE_STICK; rhs.type = SOURCE_TYPE_STICK;
rhs.index = ana_idx; rhs.index = ana_idx;
@@ -36,6 +36,7 @@ const YamlLookupTable potConfigLut = {
{Board::POT_WITH_DETENT, "with_detent"}, {Board::POT_WITH_DETENT, "with_detent"},
{Board::POT_MULTIPOS_SWITCH, "multipos_switch"}, {Board::POT_MULTIPOS_SWITCH, "multipos_switch"},
{Board::POT_WITHOUT_DETENT, "without_detent"}, {Board::POT_WITHOUT_DETENT, "without_detent"},
{Board::POT_SLIDER_WITH_DETENT, "slider"},
}; };
const YamlLookupTable slidersLut = { const YamlLookupTable slidersLut = {
@@ -172,6 +172,7 @@ enum Capability {
HasIntModuleCRSF, HasIntModuleCRSF,
HasIntModuleELRS, HasIntModuleELRS,
HasIntModuleFlySky, HasIntModuleFlySky,
BacklightLevelMin,
}; };
class EEPROMInterface class EEPROMInterface
@@ -804,6 +804,12 @@ int OpenTxFirmware::getCapability(::Capability capability)
case HasIntModuleFlySky: case HasIntModuleFlySky:
return id.contains("afhds2a") || id.contains("afhds3") || return id.contains("afhds2a") || id.contains("afhds3") ||
IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board); IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board);
case BacklightLevelMin:
if (IS_HORUS_X12S(board))
return 5;
if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 1;
return 46;
default: default:
return 0; return 0;
} }
+25 -6
View File
@@ -254,6 +254,10 @@ ui(new Ui::GeneralSetup)
populateRotEncCB(reCount); populateRotEncCB(reCount);
} }
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
ui->backlightautoSB->setMinimum(5);
}
ui->contrastSB->setMinimum(firmware->getCapability(MinContrast)); ui->contrastSB->setMinimum(firmware->getCapability(MinContrast));
ui->contrastSB->setMaximum(firmware->getCapability(MaxContrast)); ui->contrastSB->setMaximum(firmware->getCapability(MaxContrast));
ui->contrastSB->setValue(generalSettings.contrast); ui->contrastSB->setValue(generalSettings.contrast);
@@ -470,10 +474,15 @@ void GeneralSetupPanel::setValues()
ui->label_HL->hide(); ui->label_HL->hide();
ui->hapticLengthCB->hide(); ui->hapticLengthCB->hide();
} }
ui->OFFBright_SB->setMinimum(firmware->getCapability(BacklightLevelMin));
if (generalSettings.backlightOffBright > 100-generalSettings.backlightBright)
generalSettings.backlightOffBright = 100-generalSettings.backlightBright;
ui->BLBright_SB->setValue(100-generalSettings.backlightBright); ui->BLBright_SB->setValue(100-generalSettings.backlightBright);
ui->OFFBright_SB->setValue(generalSettings.backlightOffBright); ui->OFFBright_SB->setValue(generalSettings.backlightOffBright);
ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value());
ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value());
ui->soundModeCB->setCurrentIndex(generalSettings.speakerMode); ui->soundModeCB->setCurrentIndex(generalSettings.speakerMode);
ui->volume_SB->setValue(generalSettings.speakerVolume); ui->volume_SB->setValue(generalSettings.speakerVolume + 12);
ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength+2); ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength+2);
ui->speakerPitchSB->setValue(generalSettings.speakerPitch); ui->speakerPitchSB->setValue(generalSettings.speakerPitch);
ui->hapticStrength->setValue(generalSettings.hapticStrength); ui->hapticStrength->setValue(generalSettings.hapticStrength);
@@ -624,19 +633,29 @@ void GeneralSetupPanel::on_varioR0_SB_editingFinished()
void GeneralSetupPanel::on_BLBright_SB_editingFinished() void GeneralSetupPanel::on_BLBright_SB_editingFinished()
{ {
generalSettings.backlightBright = 100 - ui->BLBright_SB->value(); if (ui->BLBright_SB->value() < ui->OFFBright_SB->value()) {
emit modified(); ui->BLBright_SB->setValue(ui->OFFBright_SB->value());
} else {
ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value());
generalSettings.backlightBright = 100 - ui->BLBright_SB->value();
emit modified();
}
} }
void GeneralSetupPanel::on_OFFBright_SB_editingFinished() void GeneralSetupPanel::on_OFFBright_SB_editingFinished()
{ {
generalSettings.backlightOffBright = ui->OFFBright_SB->value(); if (ui->OFFBright_SB->value() > ui->BLBright_SB->value()) {
emit modified(); ui->OFFBright_SB->setValue(ui->BLBright_SB->value());
} else {
ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value());
generalSettings.backlightOffBright = ui->OFFBright_SB->value();
emit modified();
}
} }
void GeneralSetupPanel::on_volume_SB_editingFinished() void GeneralSetupPanel::on_volume_SB_editingFinished()
{ {
generalSettings.speakerVolume = ui->volume_SB->value(); generalSettings.speakerVolume = ui->volume_SB->value() - 12;
emit modified(); emit modified();
} }