1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-18 22:05:10 +03:00

[Companion] Latest changes taken into account

This commit is contained in:
bsongis 2015-03-10 22:58:51 +01:00
parent 8dfeb9826e
commit a61a7228da
13 changed files with 973 additions and 832 deletions

View file

@ -104,10 +104,10 @@ class ProxyField: public DataField {
}; };
template<int N> template<class container, int N>
class UnsignedField: public DataField { class BaseUnsignedField: public DataField {
public: public:
explicit UnsignedField(unsigned int & field): explicit BaseUnsignedField(container & field):
DataField("Unsigned"), DataField("Unsigned"),
field(field), field(field),
min(0), min(0),
@ -115,7 +115,7 @@ class UnsignedField: public DataField {
{ {
} }
UnsignedField(unsigned int & field, const char *name): BaseUnsignedField(container & field, const char *name):
DataField(name), DataField(name),
field(field), field(field),
min(0), min(0),
@ -123,7 +123,7 @@ class UnsignedField: public DataField {
{ {
} }
UnsignedField(unsigned int & field, unsigned int min, unsigned int max, const char *name="Unsigned"): BaseUnsignedField(container & field, unsigned int min, unsigned int max, const char *name="Unsigned"):
DataField(name), DataField(name),
field(field), field(field),
min(min), min(min),
@ -133,7 +133,7 @@ class UnsignedField: public DataField {
virtual void ExportBits(QBitArray & output) virtual void ExportBits(QBitArray & output)
{ {
unsigned int value = field; container value = field;
if (value > max) value = max; if (value > max) value = max;
if (value < min) value = min; if (value < min) value = min;
@ -159,12 +159,32 @@ class UnsignedField: public DataField {
} }
protected: protected:
unsigned int & field; container & field;
unsigned int min; container min;
unsigned int max; container max;
private: private:
UnsignedField(); BaseUnsignedField();
};
template <int N>
class UnsignedField : public BaseUnsignedField<unsigned int, N>
{
public:
explicit UnsignedField(unsigned int & field):
BaseUnsignedField<unsigned int, N>(field)
{
}
UnsignedField(unsigned int & field, const char *name):
BaseUnsignedField<unsigned int, N>(field, name)
{
}
UnsignedField(unsigned int & field, unsigned int min, unsigned int max, const char *name="Unsigned"):
BaseUnsignedField<unsigned int, N>(field, min, max, name)
{
}
}; };
template<int N> template<int N>

View file

@ -16,7 +16,7 @@
std::list<QString> EEPROMWarnings; std::list<QString> EEPROMWarnings;
const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" }; const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" };
const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN" }; const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SP", "SQ", "SR" };
const char leftArrow[] = {(char)0xE2, (char)0x86, (char)0x90, 0}; const char leftArrow[] = {(char)0xE2, (char)0x86, (char)0x90, 0};
const char rightArrow[] = {(char)0xE2, (char)0x86, (char)0x92, 0}; const char rightArrow[] = {(char)0xE2, (char)0x86, (char)0x92, 0};
const char upArrow[] = {(char)0xE2, (char)0x86, (char)0x91, 0}; const char upArrow[] = {(char)0xE2, (char)0x86, (char)0x91, 0};
@ -405,12 +405,16 @@ QString AnalogString(int index)
{ {
static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") }; static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") };
static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") }; static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") };
static const QString potsTaranisX9E[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("S4"), QObject::tr("LS"), QObject::tr("RS"), QObject::tr("LS2"), QObject::tr("RS2") };
static const QString potsTaranis[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("LS"), QObject::tr("RS") }; static const QString potsTaranis[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("LS"), QObject::tr("RS") };
if (index < 4) if (index < 4)
return CHECK_IN_ARRAY(sticks, index); return CHECK_IN_ARRAY(sticks, index);
else if (IS_TARANIS_X9E(GetEepromInterface()->getBoard()))
return CHECK_IN_ARRAY(potsTaranisX9E, index-4);
else if (IS_TARANIS(GetEepromInterface()->getBoard()))
return CHECK_IN_ARRAY(potsTaranis, index-4);
else else
return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsTaranis, index-4) : CHECK_IN_ARRAY(pots9X, index-4)); return CHECK_IN_ARRAY(pots9X, index-4);
} }
QString RotaryEncoderString(int index) QString RotaryEncoderString(int index)
@ -1002,12 +1006,10 @@ bool GeneralSettings::switchPositionAllowedTaranis(int index) const
if (index == 0) if (index == 0)
return true; return true;
SwitchInfo info = switchInfoFromSwitchPositionTaranis(abs(index)); SwitchInfo info = switchInfoFromSwitchPositionTaranis(abs(index));
if (index < 0 && switchConfigTaranis(info.index) != SWITCH_3POS) if (index < 0 && switchConfig[info.index] != SWITCH_3POS)
return false; return false;
else if (info.index >= 8)
return switchConfigTaranis(info.index-8) == SWITCH_2x2POS;
else if (info.position == 1) else if (info.position == 1)
return switchConfigTaranis(info.index) == SWITCH_3POS; return switchConfig[info.index] == SWITCH_3POS;
else else
return true; return true;
} }
@ -1027,8 +1029,18 @@ GeneralSettings::GeneralSettings()
BoardEnum board = GetEepromInterface()->getBoard(); BoardEnum board = GetEepromInterface()->getBoard();
if (IS_TARANIS(board)) { if (IS_TARANIS(board)) {
potsType[0] = 1; potConfig[0] = POT_WITH_DETENT;
potsType[1] = 1; potConfig[1] = POT_WITH_DETENT;
sliderConfig[0] = SLIDER_WITH_DETENT;
sliderConfig[1] = SLIDER_WITH_DETENT;
switchConfig[0] = SWITCH_3POS;
switchConfig[1] = SWITCH_3POS;
switchConfig[2] = SWITCH_3POS;
switchConfig[3] = SWITCH_3POS;
switchConfig[4] = SWITCH_3POS;
switchConfig[5] = SWITCH_2POS;
switchConfig[6] = SWITCH_3POS;
switchConfig[7] = SWITCH_TOGGLE;
} }
if (IS_ARM(board)) { if (IS_ARM(board)) {

View file

@ -62,6 +62,7 @@ QString getBoardName(BoardEnum board);
#define IS_9XRPRO(board) (board==BOARD_9XRPRO) #define IS_9XRPRO(board) (board==BOARD_9XRPRO)
#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E) #define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E)
#define IS_TARANIS_PLUS(board) (board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E) #define IS_TARANIS_PLUS(board) (board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E)
#define IS_TARANIS_X9E(board) (board==BOARD_TARANIS_X9E)
#define IS_ARM(board) (IS_TARANIS(board) || IS_SKY9X(board)) #define IS_ARM(board) (IS_TARANIS(board) || IS_SKY9X(board))
const uint8_t modn12x3[4][4]= { const uint8_t modn12x3[4][4]= {
@ -198,7 +199,7 @@ enum HeliSwashTypes {
#define NUM_STICKS 4 #define NUM_STICKS 4
#define BOARD_9X_NUM_POTS 3 #define BOARD_9X_NUM_POTS 3
#define C9X_NUM_POTS 5 #define C9X_NUM_POTS 8
#define NUM_CAL_PPM 4 #define NUM_CAL_PPM 4
#define NUM_CYC 3 #define NUM_CYC 3
#define C9X_NUM_SWITCHES 10 #define C9X_NUM_SWITCHES 10
@ -1013,9 +1014,10 @@ class ModelData {
SwashRingData swashRingData; SwashRingData swashRingData;
unsigned int thrTraceSrc; unsigned int thrTraceSrc;
unsigned int modelId; unsigned int modelId;
unsigned int switchWarningStates; uint64_t switchWarningStates;
unsigned int switchWarningEnable; unsigned int switchWarningEnable;
unsigned int nPotsToWarn; unsigned int potsWarningMode;
bool potsWarningEnabled[C9X_NUM_POTS];
int potPosition[C9X_NUM_POTS]; int potPosition[C9X_NUM_POTS];
bool displayChecklist; bool displayChecklist;
// TODO structure // TODO structure
@ -1087,12 +1089,23 @@ class GeneralSettings {
BEEPER_ALL = 1 BEEPER_ALL = 1
}; };
enum PotConfig {
POT_NONE,
POT_WITH_DETENT,
POT_MULTIPOS_SWITCH,
POT_WITHOUT_DETENT
};
enum SliderConfig {
SLIDER_NONE,
SLIDER_WITH_DETENT
};
enum SwitchConfig { enum SwitchConfig {
SWITCH_DEFAULT, SWITCH_NONE,
SWITCH_TOGGLE, SWITCH_TOGGLE,
SWITCH_2POS, SWITCH_2POS,
SWITCH_3POS, SWITCH_3POS,
SWITCH_2x2POS
}; };
GeneralSettings(); GeneralSettings();
@ -1179,12 +1192,15 @@ class GeneralSettings {
unsigned int mavbaud; unsigned int mavbaud;
unsigned int switchUnlockStates; unsigned int switchUnlockStates;
unsigned int hw_uartMode; unsigned int hw_uartMode;
unsigned int potsType[8];
unsigned int backlightColor; unsigned int backlightColor;
CustomFunctionData customFn[C9X_MAX_CUSTOM_FUNCTIONS]; CustomFunctionData customFn[C9X_MAX_CUSTOM_FUNCTIONS];
unsigned int switchConfig[8]; char switchName[18][3+1];
char switchNames[32][3+1]; unsigned int switchConfig[18];
char anaNames[32][3+1]; char stickName[4][3+1];
char potName[4][3+1];
unsigned int potConfig[4];
char sliderName[4][3+1];
unsigned int sliderConfig[4];
struct SwitchInfo { struct SwitchInfo {
SwitchInfo(unsigned int index, unsigned int position): SwitchInfo(unsigned int index, unsigned int position):
@ -1198,33 +1214,6 @@ class GeneralSettings {
static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index); static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index);
bool switchPositionAllowedTaranis(int index) const; bool switchPositionAllowedTaranis(int index) const;
static unsigned int switchDefaultConfigTaranis(unsigned int index)
{
if (index == 5)
return SWITCH_2POS;
else if (index == 7)
return SWITCH_TOGGLE;
else
return SWITCH_3POS;
}
unsigned int switchConfigTaranis(unsigned int index) const
{
unsigned int result = switchConfig[index];
if (result == SWITCH_DEFAULT)
result = switchDefaultConfigTaranis(index);
return result;
}
bool isSwitchWarningAllowedTaranis(unsigned int index) const
{
if (index < 8)
return switchConfigTaranis(index) != SWITCH_TOGGLE;
else
return switchConfig[index-8] == SWITCH_2x2POS;
}
}; };
class RadioData { class RadioData {
@ -1250,6 +1239,7 @@ enum Capability {
MultiLangVoice, MultiLangVoice,
ModelImage, ModelImage,
Pots, Pots,
Sliders,
Switches, Switches,
SwitchesPositions, SwitchesPositions,
LogicalSwitches, LogicalSwitches,

View file

@ -11,8 +11,9 @@
#define HAS_PERSISTENT_TIMERS(board) (IS_ARM(board) || IS_2560(board)) #define HAS_PERSISTENT_TIMERS(board) (IS_ARM(board) || IS_2560(board))
#define HAS_LARGE_LCD(board) IS_TARANIS(board) #define HAS_LARGE_LCD(board) IS_TARANIS(board)
#define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256) #define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256)
#define MAX_POTS(board) (IS_TARANIS(board) ? 5 : 3) #define MAX_POTS(board) (IS_TARANIS(board) ? (IS_TARANIS_X9E(board) ? 4 : 3) : 3)
#define MAX_SWITCHES(board, version) (version >= 217 ? (IS_TARANIS(board) ? 8+6 : 7) : (IS_TARANIS(board) ? 8 : 7)) #define MAX_SLIDERS(board) (IS_TARANIS(board) ? (IS_TARANIS_X9E(board) ? 4 : 2) : 0)
#define MAX_SWITCHES(board, version) (IS_TARANIS(board) ? (IS_TARANIS_X9E(board) ? 18 : 8) : 7)
#define MAX_SWITCHES_POSITION(board, version) (IS_TARANIS(board) ? (version >= 217 ? 22+12 : 22) : 9) #define MAX_SWITCHES_POSITION(board, version) (IS_TARANIS(board) ? (version >= 217 ? 22+12 : 22) : 9)
#define MAX_ROTARY_ENCODERS(board) (IS_2560(board) ? 2 : (IS_SKY9X(board) ? 1 : 0)) #define MAX_ROTARY_ENCODERS(board) (IS_2560(board) ? 2 : (IS_SKY9X(board) ? 1 : 0))
#define MAX_FLIGHT_MODES(board, version) (IS_ARM(board) ? 9 : (IS_DBLRAM(board, version) ? 6 : 5)) #define MAX_FLIGHT_MODES(board, version) (IS_ARM(board) ? 9 : (IS_DBLRAM(board, version) ? 6 : 5))
@ -211,9 +212,7 @@ class SourcesConversionTable: public ConversionTable {
} }
} }
for (int i=0; i<4+MAX_POTS(board); i++) { for (int i=0; i<NUM_STICKS+MAX_POTS(board)+MAX_SLIDERS(board); i++) {
if (IS_TARANIS(board) && version < 216 && i==6)
continue;
addConversion(RawSource(SOURCE_TYPE_STICK, i), val++); addConversion(RawSource(SOURCE_TYPE_STICK, i), val++);
} }
@ -1942,7 +1941,7 @@ class CustomFunctionsConversionTable: public ConversionTable {
template <int N> template <int N>
class SwitchesWarningField: public TransformedField { class SwitchesWarningField: public TransformedField {
public: public:
SwitchesWarningField(unsigned int & sw, BoardEnum board, unsigned int version): SwitchesWarningField(uint64_t & sw, BoardEnum board, unsigned int version):
TransformedField(internalField), TransformedField(internalField),
internalField(_sw, "SwitchesWarning"), internalField(_sw, "SwitchesWarning"),
sw(sw), sw(sw),
@ -1971,9 +1970,9 @@ class SwitchesWarningField: public TransformedField {
} }
protected: protected:
UnsignedField<N> internalField; BaseUnsignedField<uint64_t, N> internalField;
unsigned int &sw; uint64_t &sw;
unsigned int _sw; uint64_t _sw;
BoardEnum board; BoardEnum board;
unsigned int version; unsigned int version;
}; };
@ -2903,16 +2902,16 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
internalField.Append(new UnsignedField<8>(modelData.modelId)); internalField.Append(new UnsignedField<8>(modelData.modelId));
} }
if (IS_TARANIS(board) && version >= 217) if (IS_TARANIS_X9E(board) && version >= 217)
internalField.Append(new SwitchesWarningField<32>(modelData.switchWarningStates, board, version)); internalField.Append(new SwitchesWarningField<64>(modelData.switchWarningStates, board, version));
else if (IS_TARANIS(board)) else if (IS_TARANIS(board))
internalField.Append(new SwitchesWarningField<16>(modelData.switchWarningStates, board, version)); internalField.Append(new SwitchesWarningField<16>(modelData.switchWarningStates, board, version));
else else
internalField.Append(new SwitchesWarningField<8>(modelData.switchWarningStates, board, version)); internalField.Append(new SwitchesWarningField<8>(modelData.switchWarningStates, board, version));
if (IS_TARANIS(board) && version >= 217) if (IS_TARANIS_X9E(board) && version >= 217)
internalField.Append(new UnsignedField<16>(modelData.switchWarningEnable)); internalField.Append(new UnsignedField<32>(modelData.switchWarningEnable));
else if (version >= 216) else if (version >= 216)
internalField.Append(new UnsignedField<8>(modelData.switchWarningEnable)); internalField.Append(new UnsignedField<8>(modelData.switchWarningEnable));
@ -2948,9 +2947,16 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
if (IS_TARANIS(board)) { if (IS_TARANIS(board)) {
modulesCount = 3; modulesCount = 3;
if (version >= 217) {
internalField.Append(new ConversionField< SignedField<3> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol")));
internalField.Append(new UnsignedField<3>(modelData.trainerMode));
internalField.Append(new UnsignedField<2>(modelData.potsWarningMode));
}
else {
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol"))); internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol")));
internalField.Append(new UnsignedField<8>(modelData.trainerMode)); internalField.Append(new UnsignedField<8>(modelData.trainerMode));
} }
}
else if (IS_ARM(board) && version >= 216) { else if (IS_ARM(board) && version >= 216) {
modulesCount = 3; modulesCount = 3;
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol"))); internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol")));
@ -3005,8 +3011,26 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
} }
} }
if (IS_ARM(board) && version >= 217) {
int size = IS_TARANIS_X9E(board) ? 32 : 8;
for (int i=0; i<size; i++) {
if (i < MAX_POTS(board)+MAX_SLIDERS(board))
internalField.Append(new BoolField<1>(modelData.potsWarningEnabled[i]));
else
internalField.Append(new SpareBitsField<1>());
}
}
else if (IS_ARM(board) && version >= 216) {
for (int i=0; i<6; i++) {
if (i < MAX_POTS(board)+MAX_SLIDERS(board))
internalField.Append(new BoolField<1>(modelData.potsWarningEnabled[i]));
else
internalField.Append(new SpareBitsField<1>());
}
internalField.Append(new UnsignedField<2>(modelData.potsWarningMode));
}
if (IS_ARM(board) && version >= 216) { if (IS_ARM(board) && version >= 216) {
internalField.Append(new UnsignedField<8>(modelData.nPotsToWarn));
for (int i=0; i < GetCurrentFirmware()->getCapability(Pots); i++) { for (int i=0; i < GetCurrentFirmware()->getCapability(Pots); i++) {
internalField.Append(new SignedField<8>(modelData.potPosition[i])); internalField.Append(new SignedField<8>(modelData.potPosition[i]));
} }
@ -3076,7 +3100,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
generalData(generalData), generalData(generalData),
board(board), board(board),
version(version), version(version),
inputsCount(4 + MAX_POTS(board)) inputsCount(NUM_STICKS+MAX_POTS(board)+MAX_SLIDERS(board))
{ {
generalData.version = version; generalData.version = version;
generalData.variant = variant; generalData.variant = variant;
@ -3219,19 +3243,32 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
internalField.Append(new SignedField<8>(generalData.backgroundVolume)); internalField.Append(new SignedField<8>(generalData.backgroundVolume));
} }
if (IS_TARANIS(board) && version >= 216) { if (IS_TARANIS(board) && version >= 216) {
if (version >= 217) {
internalField.Append(new UnsignedField<6>(generalData.hw_uartMode));
if (IS_TARANIS_X9E(board)) {
internalField.Append(new UnsignedField<1>(generalData.sliderConfig[2]));
internalField.Append(new UnsignedField<1>(generalData.sliderConfig[3]));
}
else {
internalField.Append(new SpareBitsField<2>());
}
}
else {
internalField.Append(new UnsignedField<8>(generalData.hw_uartMode)); internalField.Append(new UnsignedField<8>(generalData.hw_uartMode));
}
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
internalField.Append(new UnsignedField<2>(potsType[i])); if (i < MAX_POTS(board))
internalField.Append(new UnsignedField<2>(generalData.potConfig[i]));
else
internalField.Append(new SpareBitsField<2>());
} }
internalField.Append(new UnsignedField<8>(generalData.backlightColor)); internalField.Append(new UnsignedField<8>(generalData.backlightColor));
} }
if (IS_TARANIS(board)) { if (IS_TARANIS_X9E(board))
if (version >= 217) internalField.Append(new SpareBitsField<64>());
internalField.Append(new SpareBitsField<32>()); else if (IS_TARANIS(board))
else
internalField.Append(new SpareBitsField<16>()); internalField.Append(new SpareBitsField<16>());
}
if (version >= 217) { if (version >= 217) {
for (int i=0; i<MAX_CUSTOM_FUNCTIONS(board, version); i++) { for (int i=0; i<MAX_CUSTOM_FUNCTIONS(board, version); i++) {
@ -3240,14 +3277,23 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
} }
if (IS_TARANIS(board) && version >= 217) { if (IS_TARANIS(board) && version >= 217) {
for (int i=0; i<8; i++) { for (int i=0; i<MAX_SWITCHES(board, version); i++) {
internalField.Append(new UnsignedField<4>(generalData.switchConfig[i])); internalField.Append(new UnsignedField<2>(generalData.switchConfig[i]));
}
if (IS_TARANIS_X9E(board)) {
internalField.Append(new SpareBitsField<64-2*18>());
} }
for (int i=0; i<MAX_SWITCHES(board, version); ++i) { for (int i=0; i<MAX_SWITCHES(board, version); ++i) {
internalField.Append(new ZCharField<3>(generalData.switchNames[i])); internalField.Append(new ZCharField<3>(generalData.switchName[i]));
} }
for (int i=0; i<NUM_STICKS+MAX_POTS(board); ++i) { for (int i=0; i<NUM_STICKS; ++i) {
internalField.Append(new ZCharField<3>(generalData.anaNames[i])); internalField.Append(new ZCharField<3>(generalData.stickName[i]));
}
for (int i=0; i<MAX_POTS(board); ++i) {
internalField.Append(new ZCharField<3>(generalData.potName[i]));
}
for (int i=0; i<MAX_SLIDERS(board); ++i) {
internalField.Append(new ZCharField<3>(generalData.sliderName[i]));
} }
} }
} }
@ -3266,13 +3312,6 @@ void OpenTxGeneralData::beforeExport()
sum += generalData.calibSpanPos[i]; sum += generalData.calibSpanPos[i];
if (++count == 12) break; if (++count == 12) break;
} }
if (IS_TARANIS(board)) {
for (int i=0; i<4; i++) {
potsType[i] = generalData.potsType[i];
if (i<2 && potsType[i] == 1)
potsType[i] = 0;
}
}
} }
else { else {
for (int i=0; i<inputsCount; i++) for (int i=0; i<inputsCount; i++)
@ -3285,11 +3324,4 @@ void OpenTxGeneralData::beforeExport()
void OpenTxGeneralData::afterImport() void OpenTxGeneralData::afterImport()
{ {
if (IS_TARANIS(board)) {
for (int i=0; i<4; i++) {
generalData.potsType[i] = potsType[i];
if (i<2 && potsType[i] == 0)
generalData.potsType[i] = 1;
}
}
} }

View file

@ -45,7 +45,7 @@ class OpenTxGeneralData: public TransformedField {
unsigned int version; unsigned int version;
int inputsCount; int inputsCount;
unsigned int chkSum; unsigned int chkSum;
unsigned int potsType[4]; // unsigned int potsType[4];
}; };
class ProtocolsConversionTable: public ConversionTable class ProtocolsConversionTable: public ConversionTable

View file

@ -577,11 +577,33 @@ int OpenTxFirmware::getCapability(const Capability capability)
else else
return 0; return 0;
case Pots: case Pots:
return (IS_TARANIS(board) ? 5 : 3); if (IS_TARANIS_X9E(board))
return 4;
else if (IS_TARANIS(board))
return 3;
else
return 3;
case Sliders:
if (IS_TARANIS_X9E(board))
return 4;
else if (IS_TARANIS(board))
return 2;
else
return 0;
case Switches: case Switches:
return (IS_TARANIS(board) ? 8+6 : 7); if (IS_TARANIS_X9E(board))
return 18;
else if (IS_TARANIS(board))
return 8;
else
return 7;
case SwitchesPositions: case SwitchesPositions:
return (IS_TARANIS(board) ? 22+12 : 9); if (IS_TARANIS_X9E(board))
return 18*3;
else if (IS_TARANIS(board))
return 22;
else
return 9;
case CustomFunctions: case CustomFunctions:
if (IS_TARANIS(board)) if (IS_TARANIS(board))
return 64; return 64;

View file

@ -1,67 +1,103 @@
#include "calibration.h" #include "calibration.h"
#include "ui_calibration.h" #include "ui_calibration.h"
void CalibrationPanel::setupSwitchConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type)
{
bool enabled = false;
if (IS_TARANIS(firmware->getBoard())) {
if (IS_TARANIS_X9E(firmware->getBoard())) {
enabled = true;
type->addItem(tr("None"), GeneralSettings::SWITCH_NONE);
}
else if (index < 8) {
enabled = true;
}
}
if (enabled) {
type->addItem(tr("2 Positions Toggle"), GeneralSettings::SWITCH_TOGGLE);
type->addItem(tr("2 Positions"), GeneralSettings::SWITCH_2POS);
type->addItem(tr("3 Positions"), GeneralSettings::SWITCH_3POS);
name->setField(generalSettings.switchName[index], 3, this);
type->setField(generalSettings.switchConfig[index], this);
}
else {
label->hide();
name->hide();
type->hide();
}
}
void CalibrationPanel::setupPotConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type)
{
bool enabled = false;
if (IS_TARANIS_X9E(firmware->getBoard()) && index < 4) {
enabled = true;
}
else if (IS_TARANIS_PLUS(firmware->getBoard()) && index < 3) {
enabled = true;
}
else if (IS_TARANIS(firmware->getBoard()) && index < 2) {
enabled = true;
}
if (enabled) {
type->addItem(tr("None"), GeneralSettings::POT_NONE);
type->addItem(tr("Pot with detent"), GeneralSettings::POT_WITH_DETENT);
type->addItem(tr("Multipos switch"), GeneralSettings::POT_MULTIPOS_SWITCH);
type->addItem(tr("Pot without detent"), GeneralSettings::POT_WITHOUT_DETENT);
name->setField(generalSettings.potName[index], 3, this);
type->setField(generalSettings.potConfig[index], this);
}
else {
label->hide();
name->hide();
type->hide();
}
}
void CalibrationPanel::setupSliderConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type)
{
bool enabled = false;
if (IS_TARANIS(firmware->getBoard()) && index < 2) {
type->setEnabled(false);
enabled = true;
}
else if (IS_TARANIS_X9E(firmware->getBoard()) && index < 4) {
enabled = true;
}
if (enabled) {
type->addItem(tr("None"), GeneralSettings::SLIDER_NONE);
type->addItem(tr("Slider with detent"), GeneralSettings::SLIDER_WITH_DETENT);
name->setField(generalSettings.sliderName[index], 3, this);
type->setField(generalSettings.sliderConfig[index], this);
}
else {
label->hide();
name->hide();
type->hide();
}
}
CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
GeneralPanel(parent, generalSettings, firmware), GeneralPanel(parent, generalSettings, firmware),
ui(new Ui::Calibration) ui(new Ui::Calibration)
{ {
ui->setupUi(this); ui->setupUi(this);
if (firmware->getCapability(MultiposPots)) { if (!firmware->getCapability(MultiposPots)) {
ui->pot1Type->setCurrentIndex(generalSettings.potsType[0]);
ui->pot2Type->setCurrentIndex(generalSettings.potsType[1]);
ui->pot3Type->setCurrentIndex(generalSettings.potsType[2]);
}
else {
ui->potsTypeSeparator->hide(); ui->potsTypeSeparator->hide();
ui->pot1Type->hide();
ui->pot1TypeLabel->hide();
ui->pot2Type->hide();
ui->pot2TypeLabel->hide();
ui->pot3Type->hide();
ui->pot3TypeLabel->hide();
ui->pot4Label->hide();
ui->pot5Label->hide();
} }
if (IS_TARANIS(firmware->getBoard())) { if (IS_TARANIS(firmware->getBoard())) {
ui->rudName->setField(generalSettings.anaNames[0], 3, this); ui->rudName->setField(generalSettings.stickName[0], 3, this);
ui->eleName->setField(generalSettings.anaNames[1], 3, this); ui->eleName->setField(generalSettings.stickName[1], 3, this);
ui->thrName->setField(generalSettings.anaNames[2], 3, this); ui->thrName->setField(generalSettings.stickName[2], 3, this);
ui->ailName->setField(generalSettings.anaNames[3], 3, this); ui->ailName->setField(generalSettings.stickName[3], 3, this);
ui->pot1Name->setField(generalSettings.anaNames[4], 3, this);
ui->pot2Name->setField(generalSettings.anaNames[5], 3, this);
ui->pot3Name->setField(generalSettings.anaNames[6], 3, this);
ui->pot4Name->setField(generalSettings.anaNames[7], 3, this);
ui->pot5Name->setField(generalSettings.anaNames[8], 3, this);
ui->saName->setField(generalSettings.switchNames[0], 3, this);
ui->saType->setField(generalSettings.switchConfig[0], this);
ui->sbName->setField(generalSettings.switchNames[1], 3, this);
ui->sbType->setField(generalSettings.switchConfig[1], this);
ui->scName->setField(generalSettings.switchNames[2], 3, this);
ui->scType->setField(generalSettings.switchConfig[2], this);
ui->sdName->setField(generalSettings.switchNames[3], 3, this);
ui->sdType->setField(generalSettings.switchConfig[3], this);
ui->seName->setField(generalSettings.switchNames[4], 3, this);
ui->seType->setField(generalSettings.switchConfig[4], this);
ui->sfName->setField(generalSettings.switchNames[5], 3, this);
ui->sfType->setField(generalSettings.switchConfig[5], this);
ui->sgName->setField(generalSettings.switchNames[6], 3, this);
ui->sgType->setField(generalSettings.switchConfig[6], this);
ui->shName->setField(generalSettings.switchNames[7], 3, this);
ui->shType->setField(generalSettings.switchConfig[7], this);
ui->siName->setField(generalSettings.switchNames[8], 3, this);
ui->sjName->setField(generalSettings.switchNames[9], 3, this);
ui->skName->setField(generalSettings.switchNames[10], 3, this);
ui->slName->setField(generalSettings.switchNames[11], 3, this);
ui->smName->setField(generalSettings.switchNames[12], 3, this);
ui->snName->setField(generalSettings.switchNames[13], 3, this);
connect(ui->saType, SIGNAL(currentIndexChanged(int)), this, SLOT(update()));
connect(ui->sbType, SIGNAL(currentIndexChanged(int)), this, SLOT(update()));
connect(ui->scType, SIGNAL(currentIndexChanged(int)), this, SLOT(update()));
connect(ui->sdType, SIGNAL(currentIndexChanged(int)), this, SLOT(update()));
connect(ui->seType, SIGNAL(currentIndexChanged(int)), this, SLOT(update()));
connect(ui->sgType, SIGNAL(currentIndexChanged(int)), this, SLOT(update()));
} }
else { else {
ui->rudLabel->hide(); ui->rudLabel->hide();
@ -72,46 +108,39 @@ CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSe
ui->thrName->hide(); ui->thrName->hide();
ui->ailLabel->hide(); ui->ailLabel->hide();
ui->ailName->hide(); ui->ailName->hide();
ui->pot1Name->hide();
ui->pot2Name->hide();
ui->pot3Name->hide();
ui->pot4Name->hide();
ui->pot5Name->hide();
ui->saLabel->hide();
ui->saName->hide();
ui->saType->hide();
ui->sbLabel->hide();
ui->sbName->hide();
ui->sbType->hide();
ui->scLabel->hide();
ui->scName->hide();
ui->scType->hide();
ui->sdLabel->hide();
ui->sdName->hide();
ui->sdType->hide();
ui->seLabel->hide();
ui->seName->hide();
ui->seType->hide();
ui->sfLabel->hide();
ui->sfName->hide();
ui->sfType->hide();
ui->sgLabel->hide();
ui->sgName->hide();
ui->sgType->hide();
ui->shLabel->hide();
ui->shName->hide();
ui->shType->hide();
ui->siName->hide();
ui->sjName->hide();
ui->skName->hide();
ui->slName->hide();
ui->smName->hide();
ui->snName->hide();
} }
setupPotConfig(0, ui->pot1Label, ui->pot1Name, ui->pot1Type);
setupPotConfig(1, ui->pot2Label, ui->pot2Name, ui->pot2Type);
setupPotConfig(2, ui->pot3Label, ui->pot3Name, ui->pot3Type);
setupPotConfig(3, ui->pot4Label, ui->pot4Name, ui->pot4Type);
setupSliderConfig(0, ui->lsLabel, ui->lsName, ui->lsType);
setupSliderConfig(1, ui->rsLabel, ui->rsName, ui->rsType);
setupSliderConfig(2, ui->ls2Label, ui->ls2Name, ui->ls2Type);
setupSliderConfig(3, ui->rs2Label, ui->rs2Name, ui->rs2Type);
setupSwitchConfig(0, ui->saLabel, ui->saName, ui->saType);
setupSwitchConfig(1, ui->sbLabel, ui->sbName, ui->sbType);
setupSwitchConfig(2, ui->scLabel, ui->scName, ui->scType);
setupSwitchConfig(3, ui->sdLabel, ui->sdName, ui->sdType);
setupSwitchConfig(4, ui->seLabel, ui->seName, ui->seType);
setupSwitchConfig(5, ui->sfLabel, ui->sfName, ui->sfType);
setupSwitchConfig(6, ui->sgLabel, ui->sgName, ui->sgType);
setupSwitchConfig(7, ui->shLabel, ui->shName, ui->shType);
setupSwitchConfig(8, ui->siLabel, ui->siName, ui->siType);
setupSwitchConfig(9, ui->sjLabel, ui->sjName, ui->sjType);
setupSwitchConfig(10, ui->skLabel, ui->skName, ui->skType);
setupSwitchConfig(11, ui->slLabel, ui->slName, ui->slType);
setupSwitchConfig(12, ui->smLabel, ui->smName, ui->smType);
setupSwitchConfig(13, ui->snLabel, ui->snName, ui->snType);
setupSwitchConfig(14, ui->soLabel, ui->soName, ui->soType);
setupSwitchConfig(15, ui->spLabel, ui->spName, ui->spType);
setupSwitchConfig(16, ui->sqLabel, ui->sqName, ui->sqType);
setupSwitchConfig(17, ui->srLabel, ui->srName, ui->srType);
int potsCount = GetCurrentFirmware()->getCapability(Pots); int potsCount = GetCurrentFirmware()->getCapability(Pots);
if (potsCount == 3) { if (potsCount == 3) {
ui->label_pot4->hide();
ui->ana8Neg->hide(); ui->ana8Neg->hide();
ui->ana8Mid->hide(); ui->ana8Mid->hide();
ui->ana8Pos->hide(); ui->ana8Pos->hide();
@ -133,22 +162,10 @@ CalibrationPanel::~CalibrationPanel()
delete ui; delete ui;
} }
void CalibrationPanel::update() /*void CalibrationPanel::update()
{ {
ui->siLabel->setVisible(generalSettings.switchConfig[0] == GeneralSettings::SWITCH_2x2POS);
ui->siName->setVisible(generalSettings.switchConfig[0] == GeneralSettings::SWITCH_2x2POS);
ui->sjLabel->setVisible(generalSettings.switchConfig[1] == GeneralSettings::SWITCH_2x2POS);
ui->sjName->setVisible(generalSettings.switchConfig[1] == GeneralSettings::SWITCH_2x2POS);
ui->skLabel->setVisible(generalSettings.switchConfig[2] == GeneralSettings::SWITCH_2x2POS);
ui->skName->setVisible(generalSettings.switchConfig[2] == GeneralSettings::SWITCH_2x2POS);
ui->slLabel->setVisible(generalSettings.switchConfig[3] == GeneralSettings::SWITCH_2x2POS);
ui->slName->setVisible(generalSettings.switchConfig[3] == GeneralSettings::SWITCH_2x2POS);
ui->smLabel->setVisible(generalSettings.switchConfig[4] == GeneralSettings::SWITCH_2x2POS);
ui->smName->setVisible(generalSettings.switchConfig[4] == GeneralSettings::SWITCH_2x2POS);
ui->snLabel->setVisible(generalSettings.switchConfig[6] == GeneralSettings::SWITCH_2x2POS);
ui->snName->setVisible(generalSettings.switchConfig[6] == GeneralSettings::SWITCH_2x2POS);
} }
*/
void CalibrationPanel::on_PPM_MultiplierDSB_editingFinished() void CalibrationPanel::on_PPM_MultiplierDSB_editingFinished()
{ {
generalSettings.PPM_Multiplier = (int)(ui->PPM_MultiplierDSB->value()*10)-10; generalSettings.PPM_Multiplier = (int)(ui->PPM_MultiplierDSB->value()*10)-10;
@ -377,24 +394,6 @@ void CalibrationPanel::on_ana8Pos_editingFinished()
emit modified(); emit modified();
} }
void CalibrationPanel::on_pot1Type_currentIndexChanged(int index)
{
generalSettings.potsType[0] = index;
emit modified();
}
void CalibrationPanel::on_pot2Type_currentIndexChanged(int index)
{
generalSettings.potsType[1] = index;
emit modified();
}
void CalibrationPanel::on_pot3Type_currentIndexChanged(int index)
{
generalSettings.potsType[2] = index;
emit modified();
}
void CalibrationPanel::on_serialPortMode_currentIndexChanged(int index) void CalibrationPanel::on_serialPortMode_currentIndexChanged(int index)
{ {
generalSettings.hw_uartMode = index; generalSettings.hw_uartMode = index;

View file

@ -7,6 +7,10 @@ namespace Ui {
class Calibration; class Calibration;
} }
class QLabel;
class AutoLineEdit;
class AutoComboBox;
class CalibrationPanel : public GeneralPanel class CalibrationPanel : public GeneralPanel
{ {
Q_OBJECT Q_OBJECT
@ -14,7 +18,7 @@ class CalibrationPanel : public GeneralPanel
public: public:
CalibrationPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware); CalibrationPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware);
virtual ~CalibrationPanel(); virtual ~CalibrationPanel();
virtual void update(); // virtual void update();
private slots: private slots:
void on_battCalibDSB_editingFinished(); void on_battCalibDSB_editingFinished();
@ -53,12 +57,13 @@ class CalibrationPanel : public GeneralPanel
void on_ana7Pos_editingFinished(); void on_ana7Pos_editingFinished();
void on_ana8Pos_editingFinished(); void on_ana8Pos_editingFinished();
void on_pot1Type_currentIndexChanged(int index);
void on_pot2Type_currentIndexChanged(int index);
void on_pot3Type_currentIndexChanged(int index);
void on_serialPortMode_currentIndexChanged(int index); void on_serialPortMode_currentIndexChanged(int index);
protected:
void setupPotConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type);
void setupSliderConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type);
void setupSwitchConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type);
private: private:
Ui::Calibration *ui; Ui::Calibration *ui;

File diff suppressed because it is too large Load diff

View file

@ -43,7 +43,7 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
addTab(new CustomFunctionsPanel(this, NULL, generalSettings, firmware), tr("Global Functions")); addTab(new CustomFunctionsPanel(this, NULL, generalSettings, firmware), tr("Global Functions"));
} }
addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer")); addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer"));
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration")); addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Hardware / Calibration"));
} }
GeneralEdit::~GeneralEdit() GeneralEdit::~GeneralEdit()

View file

@ -402,7 +402,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
} }
for (int i=GetCurrentFirmware()->getCapability(MultiposPots)-1; i>=0; i--) { for (int i=GetCurrentFirmware()->getCapability(MultiposPots)-1; i>=0; i--) {
if (generalSettings.potsType[i] == 2/* TODO constant*/) { if (generalSettings.potConfig[i] == GeneralSettings::POT_MULTIPOS_SWITCH) {
for (int j=-GetCurrentFirmware()->getCapability(MultiposPotsPositions); j<0; j++) { for (int j=-GetCurrentFirmware()->getCapability(MultiposPotsPositions); j<0; j++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j); item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
@ -441,7 +441,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
} }
for (int i=0; i<GetCurrentFirmware()->getCapability(MultiposPots); i++) { for (int i=0; i<GetCurrentFirmware()->getCapability(MultiposPots); i++) {
if (generalSettings.potsType[i] == 2/* TODO constant*/) { if (generalSettings.potConfig[i] == GeneralSettings::POT_MULTIPOS_SWITCH) {
for (int j=1; j<=GetCurrentFirmware()->getCapability(MultiposPotsPositions); j++) { for (int j=1; j<=GetCurrentFirmware()->getCapability(MultiposPotsPositions); j++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j); item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());

View file

@ -447,7 +447,7 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
// Beep Center checkboxes // Beep Center checkboxes
prevFocus = ui->trimsDisplay; prevFocus = ui->trimsDisplay;
int analogs = 4 + firmware->getCapability(Pots); int analogs = NUM_STICKS + firmware->getCapability(Pots) + firmware->getCapability(Sliders);
for (int i=0; i<analogs+firmware->getCapability(RotaryEncoders); i++) { for (int i=0; i<analogs+firmware->getCapability(RotaryEncoders); i++) {
QCheckBox * checkbox = new QCheckBox(this); QCheckBox * checkbox = new QCheckBox(this);
checkbox->setProperty("index", i); checkbox->setProperty("index", i);
@ -455,44 +455,59 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
ui->centerBeepLayout->addWidget(checkbox, 0, i+1); ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool))); connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
centerBeepCheckboxes << checkbox; centerBeepCheckboxes << checkbox;
if (!IS_TARANIS_PLUS(board) && i==6) { if (IS_TARANIS(board)) {
if (i >= NUM_STICKS && i < NUM_STICKS + firmware->getCapability(Pots)) {
if (generalSettings.potConfig[i-NUM_STICKS] == GeneralSettings::POT_NONE) {
checkbox->hide(); checkbox->hide();
} }
}
else if (i >= NUM_STICKS + firmware->getCapability(Pots) && i < analogs) {
if (generalSettings.sliderConfig[i-NUM_STICKS-firmware->getCapability(Pots)] == GeneralSettings::SLIDER_NONE) {
checkbox->hide();
}
}
}
QWidget::setTabOrder(prevFocus, checkbox); QWidget::setTabOrder(prevFocus, checkbox);
prevFocus = checkbox; prevFocus = checkbox;
} }
// Startup switches warnings // Startup switches warnings
for (int i=0; i<firmware->getCapability(Switches); i++) { for (int i=0; i<firmware->getCapability(Switches); i++) {
if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1) if (IS_TARANIS(firmware->getBoard())) {
if (generalSettings.switchConfig[i] == GeneralSettings::SWITCH_NONE || generalSettings.switchConfig[i] == GeneralSettings::SWITCH_TOGGLE) {
continue; continue;
}
}
else {
if (i==firmware->getCapability(Switches)-1) {
continue;
}
}
QLabel * label = new QLabel(this); QLabel * label = new QLabel(this);
QSlider * slider = new QSlider(this); QSlider * slider = new QSlider(this);
QCheckBox * cb = new QCheckBox(this); QCheckBox * cb = new QCheckBox(this);
if (IS_TARANIS(firmware->getBoard()) && !generalSettings.isSwitchWarningAllowedTaranis(i)) { slider->setProperty("index", i);
label->hide();
slider->hide();
cb->hide();
}
slider->setProperty("index", i+1);
slider->setOrientation(Qt::Vertical); slider->setOrientation(Qt::Vertical);
slider->setMinimum(0); slider->setMinimum(0);
slider->setSingleStep(1);
slider->setPageStep(1);
slider->setInvertedAppearance(true); slider->setInvertedAppearance(true);
slider->setTickPosition(QSlider::TicksBothSides); slider->setTickPosition(QSlider::TicksBothSides);
slider->setTickInterval(1);
slider->setMinimumSize(QSize(30, 50)); slider->setMinimumSize(QSize(30, 50));
slider->setMaximumSize(QSize(50, 50)); slider->setMaximumSize(QSize(50, 50));
if (IS_TARANIS(board)) { if (IS_TARANIS(board)) {
label->setText(switchesX9D[i]); label->setText(switchesX9D[i]);
slider->setMaximum((i==5 || i>=7) ? 1 : 2); slider->setMaximum(2);
slider->setSingleStep(generalSettings.switchConfig[i] == GeneralSettings::SWITCH_3POS ? 1 : 2);
slider->setPageStep(slider->singleStep());
slider->setTickInterval(slider->singleStep());
} }
else { else {
label->setText(switches9X[i]); label->setText(switches9X[i]);
slider->setMaximum(i==0 ? 2 : 1); slider->setMaximum(i==0 ? 2 : 1);
slider->setSingleStep(1);
slider->setPageStep(1);
slider->setTickInterval(1);
} }
cb->setProperty("index", i+1); cb->setProperty("index", i);
ui->switchesStartupLayout->addWidget(label, 0, i+1); ui->switchesStartupLayout->addWidget(label, 0, i+1);
ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter); ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter);
ui->switchesStartupLayout->addWidget(slider, 1, i+1); ui->switchesStartupLayout->addWidget(slider, 1, i+1);
@ -512,16 +527,23 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
// Pot warnings // Pot warnings
prevFocus = ui->potWarningMode; prevFocus = ui->potWarningMode;
if (IS_TARANIS(board)) { if (IS_TARANIS(board)) {
for (int i=0; i<firmware->getCapability(Pots); i++) { for (int i=0; i<firmware->getCapability(Pots)+firmware->getCapability(Sliders); i++) {
QCheckBox * cb = new QCheckBox(this); QCheckBox * cb = new QCheckBox(this);
cb->setProperty("index", i+1); cb->setProperty("index", i);
cb->setText(AnalogString(i+4)); cb->setText(AnalogString(i+4));
ui->potWarningLayout->addWidget(cb, 0, i+1); ui->potWarningLayout->addWidget(cb, 0, i+1);
connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool))); connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool)));
potWarningCheckboxes << cb; potWarningCheckboxes << cb;
if (!IS_TARANIS_PLUS(board) && i==2) { if (i < firmware->getCapability(Pots)) {
if (generalSettings.potConfig[i] == GeneralSettings::POT_NONE) {
cb->hide(); cb->hide();
} }
}
else {
if (generalSettings.sliderConfig[i-firmware->getCapability(Pots)] == GeneralSettings::SLIDER_NONE) {
cb->hide();
}
}
QWidget::setTabOrder(prevFocus, cb); QWidget::setTabOrder(prevFocus, cb);
prevFocus = cb; prevFocus = cb;
} }
@ -712,24 +734,13 @@ void SetupPanel::updateStartupSwitches()
{ {
lock = true; lock = true;
unsigned int switchStates = model->switchWarningStates; for (int i=0; i<startupSwitchesSliders.size(); i++) {
for (int i=0; i<firmware->getCapability(Switches); i++) {
if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1)
continue;
QSlider *slider = startupSwitchesSliders[i]; QSlider *slider = startupSwitchesSliders[i];
QCheckBox * cb = startupSwitchesCheckboxes[i]; QCheckBox * cb = startupSwitchesCheckboxes[i];
bool enabled = !(model->switchWarningEnable & (1 << i)); int index = slider->property("index").toInt();
bool enabled = !(model->switchWarningEnable & (1 << index));
slider->setEnabled(enabled); slider->setEnabled(enabled);
cb->setChecked(enabled); cb->setChecked(enabled);
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
slider->setValue((i==5 || i>=7) ? (switchStates & 0x3)/2 : switchStates & 0x3);
switchStates >>= 2;
}
else {
slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1);
switchStates >>= (i==0 ? 2 : 1);
}
} }
lock = false; lock = false;
@ -743,16 +754,9 @@ void SetupPanel::startupSwitchEdited(int value)
int index = sender()->property("index").toInt(); int index = sender()->property("index").toInt();
if (IS_TARANIS(GetEepromInterface()->getBoard())) { if (IS_TARANIS(GetEepromInterface()->getBoard())) {
if (index == 6 || index >= 8) { shift = index * 2;
shift = (index - 1) * 2;
mask = 0x02 << shift;
shift++;
}
else {
shift = (index - 1) * 2;
mask = 0x03 << shift; mask = 0x03 << shift;
} }
}
else { else {
if (index == 1) { if (index == 1) {
mask = 0x03; mask = 0x03;
@ -777,7 +781,7 @@ void SetupPanel::startupSwitchEdited(int value)
void SetupPanel::startupSwitchToggled(bool checked) void SetupPanel::startupSwitchToggled(bool checked)
{ {
if (!lock) { if (!lock) {
int index = sender()->property("index").toInt()-1; int index = sender()->property("index").toInt();
if (checked) if (checked)
model->switchWarningEnable &= ~(1 << index); model->switchWarningEnable &= ~(1 << index);
@ -792,17 +796,12 @@ void SetupPanel::startupSwitchToggled(bool checked)
void SetupPanel::updatePotWarnings() void SetupPanel::updatePotWarnings()
{ {
lock = true; lock = true;
int mode = model->nPotsToWarn >> 6; ui->potWarningMode->setCurrentIndex(model->potsWarningMode);
ui->potWarningMode->setCurrentIndex(mode);
if (mode == 0)
model->nPotsToWarn = 0x3F;
for (int i=0; i<potWarningCheckboxes.size(); i++) { for (int i=0; i<potWarningCheckboxes.size(); i++) {
bool enabled = !(model->nPotsToWarn & (1 << i)); QCheckBox *checkbox = potWarningCheckboxes[i];
int index = checkbox->property("index").toInt();
potWarningCheckboxes[i]->setChecked(enabled); checkbox->setChecked(!model->potsWarningEnabled[index]);
potWarningCheckboxes[i]->setDisabled(mode == 0); checkbox->setDisabled(model->potsWarningMode == 0);
} }
lock = false; lock = false;
} }
@ -810,13 +809,8 @@ void SetupPanel::updatePotWarnings()
void SetupPanel::potWarningToggled(bool checked) void SetupPanel::potWarningToggled(bool checked)
{ {
if (!lock) { if (!lock) {
int index = sender()->property("index").toInt()-1; int index = sender()->property("index").toInt();
model->potsWarningEnabled[index] = !checked;
if(checked)
model->nPotsToWarn &= ~(1 << index);
else
model->nPotsToWarn |= (1 << index);
updatePotWarnings(); updatePotWarnings();
emit modified(); emit modified();
} }
@ -825,10 +819,7 @@ void SetupPanel::potWarningToggled(bool checked)
void SetupPanel::on_potWarningMode_currentIndexChanged(int index) void SetupPanel::on_potWarningMode_currentIndexChanged(int index)
{ {
if (!lock) { if (!lock) {
int mask = 0xC0; model->potsWarningMode = index;
model->nPotsToWarn = model->nPotsToWarn & ~mask;
model->nPotsToWarn = model->nPotsToWarn | ((index << 6) & mask);
updatePotWarnings(); updatePotWarnings();
emit modified(); emit modified();
} }

View file

@ -40,8 +40,7 @@ class AutoComboBox: public QComboBox
this->field = (int *)&field; this->field = (int *)&field;
this->panel = panel; this->panel = panel;
for (int i=0; i<count(); ++i) { for (int i=0; i<count(); ++i) {
setItemData(i, i); if ((int)field == itemData(i))
if ((int)field == i)
setCurrentIndex(i); setCurrentIndex(i);
} }
} }
@ -50,9 +49,17 @@ class AutoComboBox: public QComboBox
{ {
this->field = &field; this->field = &field;
this->panel = panel; this->panel = panel;
for (int i=0; i<count(); ++i) {
if ((int)field == itemData(i))
setCurrentIndex(i);
}
}
void setAutoIndexes()
{
for (int i=0; i<count(); ++i) { for (int i=0; i<count(); ++i) {
setItemData(i, i); setItemData(i, i);
if ((int)field == i) if (*this->field == i)
setCurrentIndex(i); setCurrentIndex(i);
} }
} }