Issue #592 - 422bytes saved on 9x stock!!!
This commit is contained in:
@@ -268,31 +268,47 @@ QString RawSwitch::toString()
|
||||
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26")
|
||||
};
|
||||
|
||||
static const QString trimsSwitches[] = {
|
||||
QObject::tr("RudTrim Left"), QObject::tr("RudTrim Right"),
|
||||
QObject::tr("EleTrim Down"), QObject::tr("EleTrim Up"),
|
||||
QObject::tr("ThrTrim Down"), QObject::tr("ThrTrim Up"),
|
||||
QObject::tr("AilTrim Left"), QObject::tr("AilTrim Right")
|
||||
};
|
||||
|
||||
static const QString rotaryEncoders[] = {
|
||||
QObject::tr("REa"), QObject::tr("REb")
|
||||
};
|
||||
|
||||
switch(type) {
|
||||
case SWITCH_TYPE_SWITCH:
|
||||
if (IS_TARANIS(GetEepromInterface()->getBoard()))
|
||||
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1) : QString("!") + CHECK_IN_ARRAY(switchesX9D, -index-1);
|
||||
else
|
||||
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1);
|
||||
case SWITCH_TYPE_VIRTUAL:
|
||||
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1);
|
||||
case SWITCH_TYPE_MULTIPOS_POT:
|
||||
return CHECK_IN_ARRAY(multiposPots, index);
|
||||
case SWITCH_TYPE_ROTARY_ENCODER:
|
||||
return CHECK_IN_ARRAY(rotaryEncoders, index);
|
||||
case SWITCH_TYPE_ON:
|
||||
return QObject::tr("ON");
|
||||
case SWITCH_TYPE_OFF:
|
||||
return QObject::tr("OFF");
|
||||
default:
|
||||
break;
|
||||
if (index == 0) {
|
||||
return QObject::tr("----");
|
||||
}
|
||||
else if (index < 0) {
|
||||
return QString("!") + RawSwitch(type, -index).toString();
|
||||
}
|
||||
else {
|
||||
index = index - 1;
|
||||
switch(type) {
|
||||
case SWITCH_TYPE_SWITCH:
|
||||
if (IS_TARANIS(GetEepromInterface()->getBoard()))
|
||||
return CHECK_IN_ARRAY(switchesX9D, index);
|
||||
else
|
||||
return CHECK_IN_ARRAY(switches9X, index);
|
||||
case SWITCH_TYPE_VIRTUAL:
|
||||
return CHECK_IN_ARRAY(virtualSwitches, index);
|
||||
case SWITCH_TYPE_MULTIPOS_POT:
|
||||
return CHECK_IN_ARRAY(multiposPots, index);
|
||||
case SWITCH_TYPE_TRIM:
|
||||
return CHECK_IN_ARRAY(trimsSwitches, index);
|
||||
case SWITCH_TYPE_ROTARY_ENCODER:
|
||||
return CHECK_IN_ARRAY(rotaryEncoders, index);
|
||||
case SWITCH_TYPE_ON:
|
||||
return QObject::tr("ON");
|
||||
case SWITCH_TYPE_OFF:
|
||||
return QObject::tr("OFF");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::tr("----");
|
||||
}
|
||||
|
||||
QString CurveReference::toString()
|
||||
|
||||
@@ -318,6 +318,7 @@ enum RawSwitchType {
|
||||
SWITCH_TYPE_SWITCH,
|
||||
SWITCH_TYPE_VIRTUAL,
|
||||
SWITCH_TYPE_MULTIPOS_POT,
|
||||
SWITCH_TYPE_TRIM,
|
||||
SWITCH_TYPE_ROTARY_ENCODER,
|
||||
SWITCH_TYPE_ON,
|
||||
SWITCH_TYPE_OFF
|
||||
|
||||
+54
-24
@@ -427,46 +427,52 @@ void populateBacklightCB(QComboBox *b, const uint8_t value)
|
||||
}
|
||||
}
|
||||
|
||||
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
|
||||
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
|
||||
{
|
||||
RawSwitch item;
|
||||
|
||||
b->clear();
|
||||
|
||||
if (attr & POPULATE_AND_SWITCHES) {
|
||||
if (GetEepromInterface()->getCapability(HasNegAndSwitches)) {
|
||||
for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
item = RawSwitch(SWITCH_TYPE_NONE);
|
||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
||||
if (GetEepromInterface()->getCapability(HasNegAndSwitches)) {
|
||||
for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
|
||||
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
||||
}
|
||||
|
||||
item = RawSwitch(SWITCH_TYPE_NONE);
|
||||
|
||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
|
||||
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
|
||||
{
|
||||
RawSwitch item;
|
||||
|
||||
b->clear();
|
||||
|
||||
if (attr & POPULATE_ONOFF) {
|
||||
item = RawSwitch(SWITCH_TYPE_OFF);
|
||||
@@ -484,6 +490,24 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
for (int i=-8; i<0; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_TRIM, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
for (int i=-GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i<0; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
||||
@@ -506,13 +530,19 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
|
||||
for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(RotaryEncoders); i++) {
|
||||
for (int i=1; i<=8; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_TRIM, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
for (int i=1; i<=GetEepromInterface()->getCapability(RotaryEncoders); i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
|
||||
@@ -80,7 +80,7 @@ class CurveGroup : public QObject {
|
||||
};
|
||||
|
||||
#define POPULATE_ONOFF 0x01
|
||||
#define POPULATE_AND_SWITCHES 0x02
|
||||
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
|
||||
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
|
||||
void populatePhasesCB(QComboBox *b, int value);
|
||||
void populateTrimUseCB(QComboBox *b, unsigned int phase);
|
||||
|
||||
Reference in New Issue
Block a user