feat: Deadzone option for NV14 sticks (#1777)

Imported from open-flysky/Flysky-OpenTX-Test-Branch

* companion: Don't nuke `stickDeadZone` setting

* Implement data storage properly

* Add missing check for NV14 storage struct sizes

* Formatting

* Use one less byte in the packed data struct
Thanks @raphaelcoeffic :)

* Move setting of stickDeadZone default

* Use a Choice combo rather than NumberEdit

* Good riddance magic number

* Also set default stick zone if setting is missing

* Teach tests about `STICK_DEAD_ZONE`

* Tweak choice width

* Cpn NV14 add stick dead zone to hardware and section labels

* Cpn NV14 align default pot names to radio

Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
Peter Feerick
2022-04-06 10:30:20 +10:00
committed by GitHub
co-authored by elecpower
parent 9d27a6923c
commit d9b51f8ecf
46 changed files with 173 additions and 11 deletions
+26 -4
View File
@@ -41,7 +41,7 @@ class ExclusiveComboGroup: public QObject
QList<QComboBox*> combos;
std::function<bool(const QVariant&)> filter;
public:
ExclusiveComboGroup(QObject *parent, std::function<bool(const QVariant&)> filter) :
QObject(parent), filter(std::move(filter))
@@ -105,6 +105,8 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
int count;
int row = 0;
addSection(tr("Sticks"), row);
count = Boards::getCapability(board, Board::Sticks);
if (count) {
for (int i = 0; i < count; i++) {
@@ -112,6 +114,16 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
}
}
if (IS_FLYSKY_NV14(board)) {
addLabel(tr("Dead zone"), row, 0);
AutoComboBox *spnStickDeadZone = new AutoComboBox(this);
spnStickDeadZone->setModel(GeneralSettings::stickDeadZoneItemModel());
spnStickDeadZone->setField(generalSettings.stickDeadZone, this);
addParams(row, spnStickDeadZone);
}
addSection(tr("Pots"), row);
count = Boards::getCapability(board, Board::Pots);
count -= firmware->getCapability(HasFlySkyGimbals) ? 2 : 0;
if (count > 0) {
@@ -120,22 +132,26 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
}
}
addSection(tr("Sliders"), row);
count = Boards::getCapability(board, Board::Sliders);
if (count) {
for (int i = 0; i < count; i++) {
addSlider(i, row);
}
addLine(row);
}
addSection(tr("Switches"), row);
count = Boards::getCapability(board, Board::Switches);
if (count) {
for (int i = 0; i < count; i++) {
addSwitch(i, row);
}
addLine(row);
}
addLine(row);
if (Boards::getCapability(board, Board::HasRTC)) {
addLabel(tr("RTC Battery Check"), row, 0);
AutoCheckBox *rtcCheckDisable = new AutoCheckBox(this);
@@ -194,7 +210,7 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
generalSettings.internalModuleBaudrate = 0;
internalModuleBaudRate->setVisible(false);
}
addParams(row, internalModule, internalModuleBaudRate);
row++;
}
@@ -386,3 +402,9 @@ void HardwarePanel::addParams(int & row, QWidget * widget1, QWidget * widget2)
grid->addLayout(subgrid, row, 1);
row++;
}
void HardwarePanel::addSection(QString text, int & row)
{
addLabel(QString("<b>%1</b>").arg(text), row, 0);
row++;
}