chores(flysky): Separate AFHDS2A and AFHDS3 into 2 different module type (#3783)

* chores(flysky): separate AFHDS2A and AFHDS3 into 2 different module type

This should allow to remove some of the hacks added earlier.

* chore: Add some EL18 CI bits

* fix(afhds): cmake defs

* fix(ci): add el18 to commit-tests.sh

* chore(cpn): separate AFHDS2A and AFHDS3

* chore(cpn): remove binary import of afhds and legacy fxFreq field for afhds3

* fix(cpn): limit available internal afhds protocols to those supported by hardware

* chore(cpn): update Flysky int module test

* fix(cpn): compile error

* fix(cpn): afhds2a max channels

* fix: TR_MODULE_PROTOCOLS

* enh(cpn): more support for afhds2a and 3

* fix(cpn): rebase compile error

* fix(cpn): bit indexes

* fix(cpn): emi toString

* fix(cpn): limit available internal afhds protocols to those supported by hardware

* enh(cpn): add support for Flysky EL18

* fix(cpn): available protocols

* fix(cpn): rebase moduledata

* chore(cpn): add module fields to model print

* Separate AFHDS2A and AFHDS3 UI settings.

* Fix AFHDS3 conversion from old subtype value.
Fix 'Channel Range' layout on portrait LCD.

* Fix name.

---------

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
Co-authored-by: elecpower <neilh713@tpg.com.au>
Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
This commit is contained in:
Raphael Coeffic
2023-09-07 19:24:03 +10:00
committed by GitHub
co-authored by Peter Feerick elecpower Phil Mitchell
parent 9515d29c9d
commit c4f1e7127d
59 changed files with 1098 additions and 463 deletions
+69 -18
View File
@@ -225,6 +225,7 @@ void TimerPanel::onModeChanged(int index)
#define MASK_MULTI_DSM_OPT (1<<19)
#define MASK_CHANNELMAP (1<<20)
#define MASK_MULTI_BAYANG_OPT (1<<21)
#define MASK_AFHDS (1<<22)
quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT;
@@ -320,9 +321,32 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul
connect(ui->clearRx1, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked()));
connect(ui->clearRx2, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked()));
connect(ui->clearRx3, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked()));
connect(ui->cboAfhdsOpt1, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=] (int index)
{
if (lock)
return;
if (this->module.protocol == PULSES_FLYSKY_AFHDS2A)
Helpers::setBitmappedValue(this->module.flysky.mode, ui->cboAfhdsOpt1->currentData().toInt(), 1);
else
this->module.afhds3.phyMode = ui->cboAfhdsOpt1->currentData().toInt();
emit modified();
});
connect(ui->cboAfhdsOpt2, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=] (int index)
{
if (lock)
return;
if (this->module.protocol == PULSES_FLYSKY_AFHDS2A)
Helpers::setBitmappedValue(this->module.flysky.mode, ui->cboAfhdsOpt2->currentData().toInt(), 0);
else
this->module.afhds3.emi = ui->cboAfhdsOpt2->currentData().toInt();
emit modified();
});
lock = false;
}
ModulePanel::~ModulePanel()
@@ -529,10 +553,10 @@ void ModulePanel::update()
if (pdef.disableChannelMap)
mask |= MASK_CHANNELMAP;
break;
case PULSES_AFHDS3:
module.channelsCount = 18;
mask |= MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT | MASK_FAILSAFES;
mask |= MASK_SUBTYPES | MASK_RX_FREQ | MASK_RF_POWER;
case PULSES_FLYSKY_AFHDS3:
mask |= MASK_RX_NUMBER;
case PULSES_FLYSKY_AFHDS2A:
mask |= MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT | MASK_FAILSAFES | MASK_AFHDS;
break;
case PULSES_LEMON_DSMP:
mask |= MASK_CHANNELS_RANGE;
@@ -638,9 +662,6 @@ void ModulePanel::update()
if (firmware->getCapability(HasModuleR9MFlex))
i = 2;
break;
case PULSES_AFHDS3:
numEntries = 4;
break;
case PULSES_PPM:
numEntries = PPM_NUM_SUBTYPES;
break;
@@ -755,11 +776,33 @@ void ModulePanel::update()
ui->clearRx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2)));
ui->rx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2)));
// AFHFS
if (mask & MASK_AFHDS) {
if (protocol == PULSES_FLYSKY_AFHDS2A) {
ui->label_afhds->setText(tr("Options"));
ui->cboAfhdsOpt1->setModel(ModuleData::afhds2aMode1ItemModel());
ui->cboAfhdsOpt1->setCurrentIndex(Helpers::getBitmappedValue(module.flysky.mode, 1));
ui->cboAfhdsOpt2->setModel(ModuleData::afhds2aMode2ItemModel());
ui->cboAfhdsOpt2->setCurrentIndex(Helpers::getBitmappedValue(module.flysky.mode, 0));
}
else {
ui->label_afhds->setText(tr("Type"));
ui->cboAfhdsOpt1->setModel(ModuleData::afhds3PhyModeItemModel());
ui->cboAfhdsOpt1->setCurrentIndex(ui->cboAfhdsOpt1->findData(module.afhds3.phyMode));
ui->cboAfhdsOpt2->setModel(ModuleData::afhds3EmiItemModel());
ui->cboAfhdsOpt2->setCurrentIndex(ui->cboAfhdsOpt2->findData(module.afhds3.emi));
}
}
ui->label_afhds->setVisible(mask & MASK_AFHDS);
ui->cboAfhdsOpt1->setVisible(mask & MASK_AFHDS);
ui->cboAfhdsOpt2->setVisible(mask & MASK_AFHDS);
// Failsafes
ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES);
ui->failsafeMode->setVisible(mask & MASK_FAILSAFES);
//hide reciever mode for afhds3
qobject_cast<QListView *>(ui->failsafeMode->view())->setRowHidden(FAILSAFE_RECEIVER, protocol == PULSES_AFHDS3);
if ((mask & MASK_FAILSAFES) && module.failsafeMode == FAILSAFE_CUSTOM) {
if (ui->failsafesGroupBox->isHidden()) {
@@ -813,6 +856,12 @@ void ModulePanel::onProtocolChanged(int index)
ui->telemetryBaudrate->setCurrentIndex(1);
}
}
else if (module.protocol == PULSES_FLYSKY_AFHDS2A) {
module.flysky.setDefault();
}
else if (module.protocol == PULSES_FLYSKY_AFHDS3) {
module.afhds3.setDefault();
}
emit protocolChanged();
emit updateItemModels();
@@ -832,7 +881,11 @@ void ModulePanel::on_r9mPower_currentIndexChanged(int index)
{
if (!lock) {
if (module.protocol == PULSES_AFHDS3 && module.afhds3.rfPower != (unsigned int)index) {
if (module.protocol == PULSES_FLYSKY_AFHDS2A && module.flysky.rfPower != (unsigned int)index) {
module.flysky.rfPower = index;
emit modified();
}
else if (module.protocol == PULSES_FLYSKY_AFHDS3 && module.afhds3.rfPower != (unsigned int)index) {
module.afhds3.rfPower = index;
emit modified();
}
@@ -978,19 +1031,17 @@ void ModulePanel::onSubTypeChanged()
if (!lock && module.subType != type) {
lock=true;
module.subType = type;
if (module.protocol != PULSES_AFHDS3) {
update();
}
emit modified();
lock = false;
}
}
void ModulePanel::onRfFreqChanged(int freq) {
if (module.afhds3.rxFreq != (unsigned int)freq) {
module.afhds3.rxFreq = (unsigned int)freq;
emit modified();
}
// TODO fix for AFHDS2A
//if (module.afhds3.rxFreq != (unsigned int)freq) {
// module.afhds3.rxFreq = (unsigned int)freq;
// emit modified();
//}
}
void ModulePanel::on_disableTelem_stateChanged(int state)