feat: Convert PPM_UNIT build option to runtime radio setting (#3993)
This commit is contained in:
@@ -224,6 +224,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
node["keysBacklight"] = (int)rhs.keysBacklight;
|
||||
node["rotEncMode"] = (int)rhs.rotEncMode;
|
||||
node["imperial"] = rhs.imperial;
|
||||
node["ppmunit"] = rhs.ppmunit;
|
||||
node["ttsLanguage"] = rhs.ttsLanguage;
|
||||
node["beepVolume"] = rhs.beepVolume + 2;
|
||||
node["wavVolume"] = rhs.wavVolume + 2;
|
||||
@@ -487,6 +488,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
node["rotEncDirection"] >> rhs.rotEncMode; // PR2045: read old name and
|
||||
node["rotEncMode"] >> rhs.rotEncMode; // new, but don't write old
|
||||
node["imperial"] >> rhs.imperial;
|
||||
node["ppmunit"] >> rhs.ppmunit;
|
||||
node["ttsLanguage"] >> rhs.ttsLanguage;
|
||||
node["beepVolume"] >> ioffset_int(rhs.beepVolume, 2);
|
||||
node["wavVolume"] >> ioffset_int(rhs.wavVolume, 2);
|
||||
|
||||
@@ -118,7 +118,6 @@ enum Capability {
|
||||
HasModuleR9MFlex,
|
||||
HasModuleR9MMini,
|
||||
PPMCenter,
|
||||
PPMUnitMicroseconds,
|
||||
SYMLimits,
|
||||
HastxCurrentCalibration,
|
||||
HasVolume,
|
||||
|
||||
@@ -180,6 +180,12 @@ class GeneralSettings {
|
||||
HATSMODE_COUNT
|
||||
};
|
||||
|
||||
enum PPMUnit {
|
||||
PPM_PERCENT_PREC0,
|
||||
PPM_PERCENT_PREC1,
|
||||
PPM_US
|
||||
};
|
||||
|
||||
GeneralSettings() { clear(); }
|
||||
void clear();
|
||||
void init();
|
||||
@@ -263,6 +269,7 @@ class GeneralSettings {
|
||||
bool keysBacklight;
|
||||
unsigned int rotEncMode;
|
||||
unsigned int imperial;
|
||||
unsigned int ppmunit;
|
||||
char ttsLanguage[TTS_LANGUAGE_LEN + 1];
|
||||
int beepVolume;
|
||||
int wavVolume;
|
||||
|
||||
@@ -619,8 +619,6 @@ int OpenTxFirmware::getCapability(::Capability capability)
|
||||
return 32;
|
||||
case PPMCenter:
|
||||
return (IS_HORUS_OR_TARANIS(board) ? 500 : (id.contains("ppmca") ? 125 : 0));
|
||||
case PPMUnitMicroseconds:
|
||||
return id.contains("ppmus") ? 1 : 0;
|
||||
case SYMLimits:
|
||||
return 1;
|
||||
case OptrexDisplay:
|
||||
@@ -1131,7 +1129,6 @@ void addOpenTxCommonOptions(OpenTxFirmware * firmware)
|
||||
Firmware::Option("faichoice", Firmware::tr("Possibility to enable FAI MODE (no telemetry) at field")),
|
||||
Firmware::Option("faimode", Firmware::tr("FAI MODE (no telemetry) always enabled"))
|
||||
};
|
||||
firmware->addOption("ppmus", Firmware::tr("Channel values displayed in us"));
|
||||
firmware->addOptionsGroup(fai_options);
|
||||
firmware->addOption("nooverridech", Firmware::tr("No OverrideCH functions available"));
|
||||
}
|
||||
|
||||
@@ -154,6 +154,8 @@ ui(new Ui::GeneralSetup)
|
||||
ui->units_CB->setCurrentIndex(generalSettings.imperial);
|
||||
}
|
||||
|
||||
ui->ppm_units_CB->setCurrentIndex(generalSettings.ppmunit);
|
||||
|
||||
ui->gpsFormatCB->setCurrentIndex(generalSettings.gpsFormat);
|
||||
|
||||
ui->timezoneLE->setTime((generalSettings.timezone * 3600) + (generalSettings.timezoneMinutes/*quarter hours*/ * 15 * 60));
|
||||
@@ -680,6 +682,12 @@ void GeneralSetupPanel::on_units_CB_currentIndexChanged(int index)
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_ppm_units_CB_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.ppmunit = ui->ppm_units_CB->currentIndex();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_beeperlenCB_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.beeperLength = index-2;
|
||||
|
||||
@@ -47,6 +47,7 @@ class GeneralSetupPanel : public GeneralPanel
|
||||
void on_re_CB_currentIndexChanged(int index);
|
||||
void on_countrycode_CB_currentIndexChanged(int index);
|
||||
void on_units_CB_currentIndexChanged(int index);
|
||||
void on_ppm_units_CB_currentIndexChanged(int index);
|
||||
void on_faimode_CB_stateChanged(int );
|
||||
void on_rotEncMode_CB_currentIndexChanged(int index);
|
||||
void on_speakerPitchSB_editingFinished();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>858</width>
|
||||
<height>880</height>
|
||||
<height>891</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -2485,6 +2485,35 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="26" column="0">
|
||||
<widget class="QLabel" name="ppm_units_label">
|
||||
<property name="text">
|
||||
<string>PPM Units</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="26" column="1">
|
||||
<widget class="QComboBox" name="ppm_units_CB">
|
||||
<property name="currentText">
|
||||
<string>0.--</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0.--</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0.0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>us</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "filtereditemmodels.h"
|
||||
#include "curveimagewidget.h"
|
||||
|
||||
LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model,
|
||||
LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model, GeneralSettings & generalSettings,
|
||||
int min, int max, int deflt, FilteredItemModel * gvarModel, ModelPanel * panel):
|
||||
firmware(firmware),
|
||||
spinbox(new QDoubleSpinBox()),
|
||||
@@ -34,7 +34,7 @@ LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row
|
||||
spinbox->setAccelerated(true);
|
||||
spinbox->setDecimals(1);
|
||||
|
||||
if (firmware->getCapability(PPMUnitMicroseconds)) {
|
||||
if (generalSettings.ppmunit == GeneralSettings::PPM_US) {
|
||||
displayStep = 0.512;
|
||||
spinbox->setSuffix("us");
|
||||
}
|
||||
@@ -141,13 +141,13 @@ ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSetting
|
||||
}
|
||||
|
||||
// Channel offset
|
||||
chnOffset[i] = new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].offset, model, -1000, 1000, 0, dialogFilteredItemModels->getItemModel(gvid), this);
|
||||
chnOffset[i] = new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].offset, model, generalSettings, -1000, 1000, 0, dialogFilteredItemModels->getItemModel(gvid), this);
|
||||
|
||||
// Channel min
|
||||
chnMin[i] = new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].min, model, -model.getChannelsMax() * 10, 0, -1000, dialogFilteredItemModels->getItemModel(gvid), this);
|
||||
chnMin[i] = new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].min, model, generalSettings, -model.getChannelsMax() * 10, 0, -1000, dialogFilteredItemModels->getItemModel(gvid), this);
|
||||
|
||||
// Channel max
|
||||
chnMax[i] = new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].max, model, 0, model.getChannelsMax() * 10, 1000, dialogFilteredItemModels->getItemModel(gvid), this);
|
||||
chnMax[i] = new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].max, model, generalSettings, 0, model.getChannelsMax() * 10, 1000, dialogFilteredItemModels->getItemModel(gvid), this);
|
||||
|
||||
// Channel inversion
|
||||
invCB[i] = new QComboBox(this);
|
||||
|
||||
@@ -38,7 +38,7 @@ class LimitsGroup
|
||||
Q_DECLARE_TR_FUNCTIONS(LimitsGroup)
|
||||
|
||||
public:
|
||||
LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model,
|
||||
LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model, GeneralSettings & generalSettings,
|
||||
int min, int max, int deflt, FilteredItemModel * gvarModel, ModelPanel * panel = nullptr);
|
||||
~LimitsGroup();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user