feat: Add facilty for custom throttle warning position (#1395)

* replace magic number for throttle idle with correct define

* settings for custom throttle warning position

* settings fixed not to break byte-aligment of bit-fields

* evaluate custom throttle warning position

* add requested throttle value to warning text

* comment about field alignment in ModelData struct

* Menu for editing custom throttle warning for 128x64 radios
Tested on RM TX12

* Improoved menu display

* move displayed strings to translation

* translation template added for each language

* support for 212x64 B&W radios

* menu for colorlcd
not tested

* corrected translation entry for TW

* corrected handling of padding bits in ModelData structure

* Companion support for custom throttle warning position

* Rebase catchup

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
piotrva
2022-01-30 15:04:40 +10:00
committed by GitHub
co-authored by Peter Feerick
parent a052ba63c2
commit bf931a5097
42 changed files with 249 additions and 40 deletions
@@ -736,6 +736,8 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["trimInc"] = rhs.trimInc;
node["displayTrims"] = rhs.trimsDisplay;
node["disableThrottleWarning"] = (int)rhs.disableThrottleWarning;
node["enableCustomThrottleWarning"] = (int)rhs.enableCustomThrottleWarning;
node["customThrottleWarningPosition"] = (int)rhs.customThrottleWarningPosition;
node["beepANACenter"] = rhs.beepANACenter;
node["extendedLimits"] = (int)rhs.extendedLimits;
node["extendedTrims"] = (int)rhs.extendedTrims;
@@ -961,6 +963,8 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
node["trimInc"] >> rhs.trimInc;
node["displayTrims"] >> rhs.trimsDisplay;
node["disableThrottleWarning"] >> rhs.disableThrottleWarning;
node["enableCustomThrottleWarning"] >> rhs.enableCustomThrottleWarning;
node["customThrottleWarningPosition"] >> rhs.customThrottleWarningPosition;
node["beepANACenter"] >> rhs.beepANACenter;
node["extendedLimits"] >> rhs.extendedLimits;
node["extendedTrims"] >> rhs.extendedTrims;
+2
View File
@@ -121,6 +121,8 @@ class ModelData {
int trimInc; // Trim Increments
unsigned int trimsDisplay;
bool disableThrottleWarning;
bool enableCustomThrottleWarning;
int customThrottleWarningPosition;
unsigned int jitterFilter; // Added in EdgeTx 2.7 (#870)
unsigned int beepANACenter; // 1<<0->A1.. 1<<6->A7
+14
View File
@@ -1496,6 +1496,18 @@ void SetupPanel::on_throttleWarning_toggled(bool checked)
emit modified();
}
void SetupPanel::on_enableCustomThrottleWarning_toggled(bool checked)
{
model->enableCustomThrottleWarning = checked;
emit modified();
}
void SetupPanel::on_customThrottleWarningPosition_valueChanged(int value)
{
model->customThrottleWarningPosition = value;
emit modified();
}
void SetupPanel::on_throttleReverse_toggled(bool checked)
{
model->throttleReversed = checked;
@@ -1589,6 +1601,8 @@ void SetupPanel::update()
ui->throttleSource->updateValue();
populateThrottleTrimSwitchCB();
ui->throttleWarning->setChecked(!model->disableThrottleWarning);
ui->enableCustomThrottleWarning->setChecked(model->enableCustomThrottleWarning);
ui->customThrottleWarningPosition->setValue(model->customThrottleWarningPosition);
ui->trimIncrement->setCurrentIndex(model->trimInc+2);
ui->throttleTrim->setChecked(model->thrTrim);
ui->extendedLimits->setChecked(model->extendedLimits);
+2
View File
@@ -179,6 +179,8 @@ class SetupPanel : public ModelPanel
void on_extendedLimits_toggled(bool checked);
void on_extendedTrims_toggled(bool checked);
void on_throttleWarning_toggled(bool checked);
void on_enableCustomThrottleWarning_toggled(bool checked);
void on_customThrottleWarningPosition_valueChanged(int value);
void on_throttleReverse_toggled(bool checked);
void on_displayText_toggled(bool checked);
void on_gfEnabled_toggled(bool checked);
+51 -9
View File
@@ -183,6 +183,22 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_spacer">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string></string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_10">
<property name="font">
@@ -450,7 +466,7 @@
<item row="0" column="5">
<widget class="QComboBox" name="throttleTrimSwitch"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QComboBox" name="trimIncrement">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -485,7 +501,7 @@
</item>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="AutoComboBox" name="trimsDisplay">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -520,7 +536,33 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="enableCustomThrottleWarning">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Custom Throttle Warning</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="customThrottleWarningPosition">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="displayText">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -530,14 +572,14 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QCheckBox" name="gfEnabled">
<property name="text">
<string>Global Functions</string>
</property>
</widget>
</item>
<item row="2" column="4">
<item row="3" column="4">
<widget class="QLabel" name="label_jitterFilter">
<property name="font">
<font>
@@ -550,7 +592,7 @@
</property>
</widget>
</item>
<item row="2" column="5">
<item row="3" column="5">
<widget class="QComboBox" name="jitterFilter">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -576,7 +618,7 @@
</widget>
</item>
<item row="1" column="4">
<item row="2" column="4">
<widget class="QPushButton" name="editText">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -622,7 +664,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</property>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="2">
<widget class="QCheckBox" name="extendedTrims">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -632,7 +674,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QCheckBox" name="extendedLimits">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -652,7 +694,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</property>
</widget>
</item>
<item row="1" column="6">
<item row="2" column="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>