feat: More rotary encoder options for B&W screens (see #2045)
* First build * Fix X9 * Update api_general.cpp * Update translations.h * clean up translations * fix: B&W option handling, remove magic numbers, cleanup - Remove references to invertRotary, change to RotEncDir or similar - Add compatabilty importing to companion, firmware - Rename Lua API call - Move magic numbers to enum - Improve B&W option handling so it doesn't apply changes while in menu * chore: yaml regen * fix: Add missing guards for X9D/X9D+ * fix: Wrong enum name in simu * fix(cpn): Use correct names for UI elements * fix: Translations * fix: Allow `rotEncMode` in all yaml due to x9d var Of the three X9D variants, the X9D+2019 is the only one that has a rotary encoder as standard. However, as the base config file is for the X9D, this meant it wasn't reading or writing the config value. Rather than add a seperate config file for it for a single variable, simple to just allow it across all targets. * fix: Companion string, change colorlcd to `Choice` Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
Peter Feerick
parent
5752cf4061
commit
62692dba6a
@@ -202,7 +202,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
node["noJitterFilter"] = (int)rhs.noJitterFilter;
|
||||
node["disableRtcWarning"] = (int)rhs.rtcCheckDisable; // TODO: verify
|
||||
node["keysBacklight"] = (int)rhs.keysBacklight;
|
||||
node["rotEncDirection"] = (int)rhs.rotEncDirection;
|
||||
node["rotEncMode"] = (int)rhs.rotEncMode;
|
||||
node["imperial"] = rhs.imperial;
|
||||
node["ttsLanguage"] = rhs.ttsLanguage;
|
||||
node["beepVolume"] = rhs.beepVolume + 2;
|
||||
@@ -396,7 +396,8 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
node["noJitterFilter"] >> rhs.noJitterFilter; // new, but don't write old
|
||||
node["disableRtcWarning"] >> rhs.rtcCheckDisable; // TODO: verify
|
||||
node["keysBacklight"] >> rhs.keysBacklight;
|
||||
node["rotEncDirection"] >> rhs.rotEncDirection;
|
||||
node["rotEncDirection"] >> rhs.rotEncMode; // PR2045: read old name and
|
||||
node["rotEncMode"] >> rhs.rotEncMode; // new, but don't write old
|
||||
node["imperial"] >> rhs.imperial;
|
||||
node["ttsLanguage"] >> rhs.ttsLanguage;
|
||||
node["beepVolume"] >> ioffset_int(rhs.beepVolume, 2);
|
||||
|
||||
@@ -238,7 +238,7 @@ class GeneralSettings {
|
||||
bool noJitterFilter;
|
||||
bool rtcCheckDisable;
|
||||
bool keysBacklight;
|
||||
bool rotEncDirection;
|
||||
unsigned int rotEncMode;
|
||||
unsigned int imperial;
|
||||
char ttsLanguage[TTS_LANGUAGE_LEN + 1];
|
||||
int beepVolume;
|
||||
|
||||
@@ -3035,11 +3035,10 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||
internalField.Append(new BoolField<1>(this, generalData.rtcCheckDisable));
|
||||
if (IS_JUMPER_T18(board)) {
|
||||
internalField.Append(new BoolField<1>(this, generalData.keysBacklight));
|
||||
internalField.Append(new BoolField<1>(this, generalData.rotEncDirection));
|
||||
internalField.Append(new SpareBitsField<1>(this));
|
||||
}
|
||||
else {
|
||||
internalField.Append(new SpareBitsField<1>(this));
|
||||
internalField.Append(new BoolField<1>(this, generalData.rotEncDirection));
|
||||
internalField.Append(new SpareBitsField<2>(this));
|
||||
}
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
@@ -3350,6 +3349,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||
|
||||
if (version >= 220) {
|
||||
internalField.Append(new SignedField<2>(this, generalData.uartSampleMode, "Uart Sample Mode"));
|
||||
internalField.Append(new UnsignedField<2>(this, generalData.rotEncMode));
|
||||
//internalField.Append(new SpareBitsField<6>(this)); // may need padding to end of 8 byte boundary
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,11 +126,11 @@ ui(new Ui::GeneralSetup)
|
||||
}
|
||||
|
||||
if (!firmware->getCapability(RotaryEncoderNavigation)) {
|
||||
ui->invertRotary_CB->hide();
|
||||
ui->invertRotary_label->hide();
|
||||
ui->rotEncMode_CB->hide();
|
||||
ui->rotEncMode_label->hide();
|
||||
}
|
||||
else {
|
||||
ui->invertRotary_CB->setChecked(generalSettings.rotEncDirection);
|
||||
populateRotEncModeCB();
|
||||
}
|
||||
|
||||
if (!firmware->getCapability(HasPxxCountry)) {
|
||||
@@ -483,10 +483,29 @@ void GeneralSetupPanel::on_faimode_CB_stateChanged(int)
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_invertRotary_CB_stateChanged(int)
|
||||
void GeneralSetupPanel::populateRotEncModeCB()
|
||||
{
|
||||
generalSettings.rotEncDirection = ui->invertRotary_CB->isChecked();
|
||||
emit modified();
|
||||
QComboBox * b = ui->rotEncMode_CB;
|
||||
QString strings[] = { tr("Normal"), tr("Inverted"), tr("Vertical Inverted, Horizontal Normal"), tr("Vertical Inverted, Horizontal Alternate") };
|
||||
int itemCount = 4;
|
||||
|
||||
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
|
||||
itemCount = 2;
|
||||
}
|
||||
|
||||
b->clear();
|
||||
for (uint8_t i=0; i < itemCount; i++) {
|
||||
b->addItem(strings[i], 0);
|
||||
}
|
||||
b->setCurrentIndex(generalSettings.rotEncMode);
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_rotEncMode_CB_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
generalSettings.rotEncMode = index;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_speakerPitchSB_editingFinished()
|
||||
|
||||
@@ -49,7 +49,7 @@ class GeneralSetupPanel : public GeneralPanel
|
||||
void on_countrycode_CB_currentIndexChanged(int index);
|
||||
void on_units_CB_currentIndexChanged(int index);
|
||||
void on_faimode_CB_stateChanged(int );
|
||||
void on_invertRotary_CB_stateChanged(int);
|
||||
void on_rotEncMode_CB_currentIndexChanged(int index);
|
||||
void on_speakerPitchSB_editingFinished();
|
||||
void on_timezoneSB_editingFinished();
|
||||
void on_adjustRTC_stateChanged(int);
|
||||
@@ -100,6 +100,7 @@ class GeneralSetupPanel : public GeneralPanel
|
||||
void populateBacklightCB();
|
||||
void populateVoiceLangCB();
|
||||
void populateRotEncCB(int reCount);
|
||||
void populateRotEncModeCB();
|
||||
void updateVarioPitchRange();
|
||||
};
|
||||
|
||||
|
||||
@@ -1146,21 +1146,14 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QComboBox" name="re_CB"/>
|
||||
</item>
|
||||
<item row="21" column="0">
|
||||
<widget class="QLabel" name="invertRotary_label">
|
||||
<widget class="QLabel" name="rotEncMode_label">
|
||||
<property name="text">
|
||||
<string>Invert Rotary</string>
|
||||
<string>Rotary Encoder Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="21" column="1">
|
||||
<widget class="QCheckBox" name="invertRotary_CB">
|
||||
<property name="toolTip">
|
||||
<string>Invert the direction of the rotary encoder</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="rotEncMode_CB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user