[MULTI] Implement option Value adjustment in Companion (#4459)
* [MULTI] Implement option Value adjustment in Companion Also refactor ui code to use the same multi table as the radio to make updates easier and consistent * Fix warnings with gcc 6 * Make the whole thing more C++ like Using QVector instead of std::vector gives me strange errors. * Fix gcc warning * another signedness fix * Add missing include * Add Gw008 protocol and move subtype definitions out of the translations * Add note about struct * More cleanups Integrate @mpaperno’s latest ideas about cleaning up
This commit is contained in:
committed by
Bertrand Songis
parent
00b2799427
commit
40dae8a8a7
@@ -25,6 +25,7 @@
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include "modelprinter.h"
|
||||
#include "multiprotocols.h"
|
||||
|
||||
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
@@ -157,6 +158,7 @@ void TimerPanel::on_name_editingFinished()
|
||||
#define MASK_OPEN_DRAIN 64
|
||||
#define MASK_MULTIMODULE 128
|
||||
#define MASK_ANTENNA 256
|
||||
#define MASK_MULTIOPTION 512
|
||||
|
||||
quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT;
|
||||
|
||||
@@ -381,6 +383,13 @@ void ModulePanel::update()
|
||||
break;
|
||||
case PULSES_MULTIMODULE:
|
||||
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER | MASK_MULTIMODULE;
|
||||
max_rx_num = 15;
|
||||
if (module.multi.rfProtocol == MM_RF_PROTO_DSM2)
|
||||
mask |= MASK_CHANNELS_COUNT;
|
||||
else
|
||||
module.channelsCount = 16;
|
||||
if (multiProtocols.getProtocol(module.multi.rfProtocol).optionsstr != nullptr)
|
||||
mask |= MASK_MULTIOPTION;
|
||||
break;
|
||||
case PULSES_OFF:
|
||||
break;
|
||||
@@ -442,9 +451,11 @@ void ModulePanel::update()
|
||||
ui->multiProtocol->setCurrentIndex(module.multi.rfProtocol);
|
||||
ui->label_multiSubType->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->multiSubType->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->label_option->setVisible(mask & MASK_MULTIOPTION);
|
||||
ui->optionValue->setVisible(mask & MASK_MULTIOPTION);
|
||||
|
||||
if (mask & MASK_MULTIMODULE) {
|
||||
int numEntries = getNumSubtypes(static_cast<MultiModuleRFProtocols>(module.multi.rfProtocol));
|
||||
int numEntries = multiProtocols.getProtocol(module.multi.rfProtocol).numSubytes();
|
||||
if (module.multi.customProto)
|
||||
numEntries=8;
|
||||
// Removes extra items
|
||||
@@ -456,6 +467,14 @@ void ModulePanel::update()
|
||||
ui->multiSubType->addItem(ModelPrinter::printMultiSubType(module.multi.rfProtocol, module.multi.customProto, i), (QVariant) i);
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & MASK_MULTIOPTION) {
|
||||
auto pdef = multiProtocols.getProtocol(module.multi.rfProtocol);
|
||||
ui->optionValue->setMinimum(pdef.getOptionMin());
|
||||
ui->optionValue->setMaximum(pdef.getOptionMax());
|
||||
ui->optionValue->setValue(module.multi.optionValue);
|
||||
ui->label_option->setText(pdef.optionsstr);
|
||||
}
|
||||
ui->multiSubType->setCurrentIndex(module.subType);
|
||||
|
||||
ui->autoBind->setVisible(mask & MASK_MULTIMODULE);
|
||||
@@ -592,8 +611,8 @@ void ModulePanel::on_multiProtocol_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
lock=true;
|
||||
module.multi.rfProtocol = index;
|
||||
unsigned int maxSubTypes = getNumSubtypes(static_cast<MultiModuleRFProtocols>(index));
|
||||
module.multi.rfProtocol = (unsigned int) index;
|
||||
unsigned int maxSubTypes = multiProtocols.getProtocol(index).numSubytes();
|
||||
if (module.multi.customProto)
|
||||
maxSubTypes=8;
|
||||
module.subType = std::min(module.subType, maxSubTypes -1);
|
||||
@@ -603,6 +622,12 @@ void ModulePanel::on_multiProtocol_currentIndexChanged(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void ModulePanel::on_optionValue_editingFinished()
|
||||
{
|
||||
module.multi.optionValue = ui->optionValue->value();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void ModulePanel::on_multiSubType_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
|
||||
Reference in New Issue
Block a user