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))
return switches[index];
}
else if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) {
else if (IS_FLYSKY_NV14(board)) {
const Board::SwitchInfo switches[] = {
{SWITCH_2POS, "SA"},
{SWITCH_3POS, "SB"},
@@ -360,6 +360,20 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index)
if (index < DIM(switches))
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)) {
const Board::SwitchInfo switches[] = {
{SWITCH_3POS, "SA"},
@@ -700,10 +714,17 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board, const
{tr("S3").toStdString(), "POT3"},
});
} else if ((IS_TARANIS_SMALL(board) && !IS_JUMPER_TLITE(board)) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) {
tbl.insert(tbl.end(), {
{tr("S1").toStdString(), "POT1"},
{tr("S2").toStdString(), "POT2"},
});
if (version < adcVersion) {
tbl.insert(tbl.end(), {
{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)) {
if (version < adcVersion) {
tbl.insert(tbl.end(), {
@@ -892,6 +913,8 @@ QString Boards::potTypeToString(int value)
return tr("Multi pos switch");
case POT_WITHOUT_DETENT:
return tr("Pot without detent");
case POT_SLIDER_WITH_DETENT:
return tr("slider");
default:
return CPN_STR_UNKNOWN_ITEM;
}
+1
View File
@@ -83,6 +83,7 @@ namespace Board {
POT_WITH_DETENT,
POT_MULTIPOS_SWITCH,
POT_WITHOUT_DETENT,
POT_SLIDER_WITH_DETENT,
POT_TYPE_COUNT
};
@@ -184,6 +184,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["fai"] = (int)rhs.fai;
node["disableMemoryWarning"] = (int)rhs.disableMemoryWarning;
node["beepMode"] = rhs.beeperMode;
node["alarmsFlash"] = (int)rhs.flashBeep;
node["disableAlarmWarning"] = (int)rhs.disableAlarmWarning;
node["disableRssiPoweroffAlarm"] = (int)rhs.disableRssiPoweroffAlarm;
node["USBMode"] = rhs.usbMode;
@@ -297,7 +298,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
seq = getCurrentFirmware()->getAnalogInputSeqADC(adcoffset + i) - sticks;
if (seq >= 0 && seq < maxPots) {
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["disableMemoryWarning"] >> rhs.disableMemoryWarning;
node["beepMode"] >> rhs.beeperMode;
node["alarmsFlash"] >> rhs.flashBeep;
node["disableAlarmWarning"] >> rhs.disableAlarmWarning;
node["disableRssiPoweroffAlarm"] >> rhs.disableRssiPoweroffAlarm;
node["USBMode"] >> rhs.usbMode;
@@ -576,7 +578,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
else {
for (int i = 0; i < Boards::getCapability(board, Board::Sliders); 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());
if (ana_idx < 0)
ana_idx = getCurrentFirmware()->getAnalogInputIndexADC(ana_str.c_str());
if (ana_idx >= 0) {
rhs.type = SOURCE_TYPE_STICK;
rhs.index = ana_idx;
@@ -36,6 +36,7 @@ const YamlLookupTable potConfigLut = {
{Board::POT_WITH_DETENT, "with_detent"},
{Board::POT_MULTIPOS_SWITCH, "multipos_switch"},
{Board::POT_WITHOUT_DETENT, "without_detent"},
{Board::POT_SLIDER_WITH_DETENT, "slider"},
};
const YamlLookupTable slidersLut = {
@@ -172,6 +172,7 @@ enum Capability {
HasIntModuleCRSF,
HasIntModuleELRS,
HasIntModuleFlySky,
BacklightLevelMin,
};
class EEPROMInterface
@@ -804,6 +804,12 @@ int OpenTxFirmware::getCapability(::Capability capability)
case HasIntModuleFlySky:
return id.contains("afhds2a") || id.contains("afhds3") ||
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:
return 0;
}
+25 -6
View File
@@ -254,6 +254,10 @@ ui(new Ui::GeneralSetup)
populateRotEncCB(reCount);
}
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
ui->backlightautoSB->setMinimum(5);
}
ui->contrastSB->setMinimum(firmware->getCapability(MinContrast));
ui->contrastSB->setMaximum(firmware->getCapability(MaxContrast));
ui->contrastSB->setValue(generalSettings.contrast);
@@ -470,10 +474,15 @@ void GeneralSetupPanel::setValues()
ui->label_HL->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->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->volume_SB->setValue(generalSettings.speakerVolume);
ui->volume_SB->setValue(generalSettings.speakerVolume + 12);
ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength+2);
ui->speakerPitchSB->setValue(generalSettings.speakerPitch);
ui->hapticStrength->setValue(generalSettings.hapticStrength);
@@ -624,19 +633,29 @@ void GeneralSetupPanel::on_varioR0_SB_editingFinished()
void GeneralSetupPanel::on_BLBright_SB_editingFinished()
{
generalSettings.backlightBright = 100 - ui->BLBright_SB->value();
emit modified();
if (ui->BLBright_SB->value() < ui->OFFBright_SB->value()) {
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()
{
generalSettings.backlightOffBright = ui->OFFBright_SB->value();
emit modified();
if (ui->OFFBright_SB->value() > ui->BLBright_SB->value()) {
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()
{
generalSettings.speakerVolume = ui->volume_SB->value();
generalSettings.speakerVolume = ui->volume_SB->value() - 12;
emit modified();
}