From de49d155c6c0f6d270dd7b83f2c791f2a0a79189 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 24 Jan 2017 22:06:28 +0100 Subject: [PATCH] [Companion] Compilation fix --- companion/src/boards.cpp | 94 +++++------ companion/src/boards.h | 116 ++++++++------ companion/src/burnconfigdialog.cpp | 4 +- companion/src/eeprominterface.cpp | 119 +++++++------- companion/src/eeprominterface.h | 16 +- .../src/firmwares/er9x/er9xinterface.cpp | 6 +- .../firmwares/ersky9x/ersky9xinterface.cpp | 4 +- .../src/firmwares/opentx/opentxeeprom.cpp | 104 +++++++------ companion/src/firmwares/opentx/opentxeeprom.h | 10 +- .../src/firmwares/opentx/opentxinterface.cpp | 10 +- .../src/firmwares/opentx/opentxinterface.h | 6 +- companion/src/generaledit/hardware.cpp | 80 +++++----- companion/src/generaledit/hardware.h | 8 +- companion/src/helpers.cpp | 10 +- companion/src/mainwindow.cpp | 2 +- companion/src/mdichild.cpp | 8 +- companion/src/mdichild.h | 2 +- companion/src/modeledit/channels.cpp | 2 +- companion/src/modeledit/flightmodes.cpp | 6 +- companion/src/modeledit/logicalswitches.cpp | 4 +- companion/src/modeledit/setup.cpp | 18 +-- companion/src/modeledit/templates.cpp | 146 +++++++++--------- companion/src/modelprinter.cpp | 2 +- companion/src/modelslist.cpp | 4 +- companion/src/radiodata.cpp | 8 +- companion/src/radiodata.h | 20 +-- companion/src/radiointerface.cpp | 24 +-- companion/src/simulation/simulateduiwidget.h | 2 +- companion/src/simulation/simulatordialog.cpp | 20 +-- companion/src/simulation/simulatordialog.h | 2 +- companion/src/simulation/simulatorinterface.h | 2 +- .../src/simulation/widgets/radioknobwidget.h | 12 +- .../simulation/widgets/radioswitchwidget.h | 8 +- companion/src/storage/rlefile.cpp | 6 +- companion/src/storage/rlefile.h | 6 +- companion/src/storage/storage.h | 6 +- companion/src/storage/xmlinterface.cpp | 2 +- companion/src/wizarddata.cpp | 2 +- radio/src/targets/simu/opentxsimulator.cpp | 12 +- 39 files changed, 461 insertions(+), 452 deletions(-) diff --git a/companion/src/boards.cpp b/companion/src/boards.cpp index 00db08bbb..10270a9f5 100644 --- a/companion/src/boards.cpp +++ b/companion/src/boards.cpp @@ -21,77 +21,79 @@ #include "boards.h" #include "macros.h" -int getEEpromSize(BoardEnum board) +using namespace Board; + +int getEEpromSize(Board::Type board) { switch (board) { - case BOARD_STOCK: + case Board::BOARD_STOCK: return EESIZE_STOCK; - case BOARD_M128: + case Board::BOARD_M128: return EESIZE_M128; - case BOARD_MEGA2560: - case BOARD_GRUVIN9X: + case Board::BOARD_MEGA2560: + case Board::BOARD_GRUVIN9X: return EESIZE_GRUVIN9X; - case BOARD_SKY9X: + case Board::BOARD_SKY9X: return EESIZE_SKY9X; - case BOARD_9XRPRO: - case BOARD_AR9X: + case Board::BOARD_9XRPRO: + case Board::BOARD_AR9X: return EESIZE_9XRPRO; - case BOARD_TARANIS_X7: - case BOARD_TARANIS_X9D: - case BOARD_TARANIS_X9DP: - case BOARD_TARANIS_X9E: - case BOARD_FLAMENCO: + case Board::BOARD_TARANIS_X7: + case Board::BOARD_TARANIS_X9D: + case Board::BOARD_TARANIS_X9DP: + case Board::BOARD_TARANIS_X9E: + case Board::BOARD_FLAMENCO: return EESIZE_TARANIS; default: return 0; // unlimited } } -SwitchInfo getSwitchInfo(BoardEnum board, unsigned index) +Board::SwitchInfo getSwitchInfo(Board::Type board, unsigned index) { if (IS_TARANIS_X7(board)) { - const SwitchInfo switches[] = {{SWITCH_3POS, "SA"}, - {SWITCH_3POS, "SB"}, - {SWITCH_3POS, "SC"}, - {SWITCH_3POS, "SD"}, - {SWITCH_2POS, "SF"}, - {SWITCH_TOGGLE, "SH"}}; + const Board::SwitchInfo switches[] = {{Board::SWITCH_3POS, "SA"}, + {Board::SWITCH_3POS, "SB"}, + {Board::SWITCH_3POS, "SC"}, + {Board::SWITCH_3POS, "SD"}, + {Board::SWITCH_2POS, "SF"}, + {Board::SWITCH_TOGGLE, "SH"}}; if (index < DIM(switches)) return switches[index]; } else if (IS_HORUS_OR_TARANIS(board)) { - const SwitchInfo switches[] = {{SWITCH_3POS, "SA"}, - {SWITCH_3POS, "SB"}, - {SWITCH_3POS, "SC"}, - {SWITCH_3POS, "SD"}, - {SWITCH_3POS, "SE"}, - {SWITCH_2POS, "SF"}, - {SWITCH_3POS, "SG"}, - {SWITCH_TOGGLE, "SH"}, - {SWITCH_3POS, "SI"}, - {SWITCH_3POS, "SJ"}, - {SWITCH_3POS, "SK"}, - {SWITCH_3POS, "SL"}, - {SWITCH_3POS, "SM"}, - {SWITCH_3POS, "SN"}, - {SWITCH_3POS, "SO"}, - {SWITCH_3POS, "SP"}, - {SWITCH_3POS, "SQ"}, - {SWITCH_3POS, "SR"}}; + const Board::SwitchInfo switches[] = {{Board::SWITCH_3POS, "SA"}, + {Board::SWITCH_3POS, "SB"}, + {Board::SWITCH_3POS, "SC"}, + {Board::SWITCH_3POS, "SD"}, + {Board::SWITCH_3POS, "SE"}, + {Board::SWITCH_2POS, "SF"}, + {Board::SWITCH_3POS, "SG"}, + {Board::SWITCH_TOGGLE, "SH"}, + {Board::SWITCH_3POS, "SI"}, + {Board::SWITCH_3POS, "SJ"}, + {Board::SWITCH_3POS, "SK"}, + {Board::SWITCH_3POS, "SL"}, + {Board::SWITCH_3POS, "SM"}, + {Board::SWITCH_3POS, "SN"}, + {Board::SWITCH_3POS, "SO"}, + {Board::SWITCH_3POS, "SP"}, + {Board::SWITCH_3POS, "SQ"}, + {Board::SWITCH_3POS, "SR"}}; if (index < DIM(switches)) return switches[index]; } else { - const SwitchInfo switches[] = {{SWITCH_2POS, "THR"}, - {SWITCH_2POS, "RUD"}, - {SWITCH_2POS, "ELE"}, - {SWITCH_3POS, "3POS"}, - {SWITCH_2POS, "AIL"}, - {SWITCH_2POS, "GEA"}, - {SWITCH_TOGGLE, "TRN"}}; + const Board::SwitchInfo switches[] = {{Board::SWITCH_2POS, "THR"}, + {Board::SWITCH_2POS, "RUD"}, + {Board::SWITCH_2POS, "ELE"}, + {Board::SWITCH_3POS, "3POS"}, + {Board::SWITCH_2POS, "AIL"}, + {Board::SWITCH_2POS, "GEA"}, + {Board::SWITCH_TOGGLE, "TRN"}}; if (index < DIM(switches)) return switches[index]; } - return {SWITCH_NOT_AVAILABLE, "???"}; + return {Board::SWITCH_NOT_AVAILABLE, "???"}; } \ No newline at end of file diff --git a/companion/src/boards.h b/companion/src/boards.h index 2c94f1170..247fd6dc3 100644 --- a/companion/src/boards.h +++ b/companion/src/boards.h @@ -23,46 +23,64 @@ // TODO create a Board class with all these functions -enum BoardEnum { - BOARD_STOCK, - BOARD_M128, - BOARD_MEGA2560, - BOARD_GRUVIN9X, - BOARD_SKY9X, - BOARD_9XRPRO, - BOARD_AR9X, - BOARD_TARANIS_X7, - BOARD_TARANIS_X9D, - BOARD_TARANIS_X9DP, - BOARD_TARANIS_X9E, - BOARD_FLAMENCO, - BOARD_HORUS, - BOARD_UNKNOWN = -1 -}; +namespace Board { -enum PotConfig { - POT_NONE, - POT_WITH_DETENT, - POT_MULTIPOS_SWITCH, - POT_WITHOUT_DETENT -}; + enum Type + { + BOARD_STOCK, + BOARD_M128, + BOARD_MEGA2560, + BOARD_GRUVIN9X, + BOARD_SKY9X, + BOARD_9XRPRO, + BOARD_AR9X, + BOARD_TARANIS_X7, + BOARD_TARANIS_X9D, + BOARD_TARANIS_X9DP, + BOARD_TARANIS_X9E, + BOARD_FLAMENCO, + BOARD_HORUS, + BOARD_UNKNOWN = -1 + }; -enum SliderConfig { - SLIDER_NONE, - SLIDER_WITH_DETENT -}; + enum PotType + { + POT_NONE, + POT_WITH_DETENT, + POT_MULTIPOS_SWITCH, + POT_WITHOUT_DETENT + }; -enum SwitchConfig { - SWITCH_NOT_AVAILABLE, - SWITCH_TOGGLE, - SWITCH_2POS, - SWITCH_3POS -}; + enum SliderType + { + SLIDER_NONE, + SLIDER_WITH_DETENT + }; -struct SwitchInfo { - SwitchConfig config; - const char * name; -}; + enum SwitchType + { + SWITCH_NOT_AVAILABLE, + SWITCH_TOGGLE, + SWITCH_2POS, + SWITCH_3POS + }; + + struct SwitchInfo + { + SwitchType config; + const char * name; + }; + + struct SwitchPosition { + SwitchPosition(unsigned int index, unsigned int position): + index(index), + position(position) + { + } + unsigned int index; + unsigned int position; + }; +} // TODO remove all those constants #define EESIZE_STOCK 2048 @@ -83,22 +101,22 @@ struct SwitchInfo { #define FSIZE_HORUS (2048*1024) #define FSIZE_MAX FSIZE_HORUS -int getEEpromSize(BoardEnum board); -SwitchInfo getSwitchInfo(BoardEnum board, unsigned index); +int getEEpromSize(Board::Type board); +Board::SwitchInfo getSwitchInfo(Board::Type board, unsigned index); -#define IS_9X(board) (board==BOARD_STOCK || board==BOARD_M128) -#define IS_STOCK(board) (board==BOARD_STOCK) -#define IS_2560(board) (board==BOARD_GRUVIN9X || board==BOARD_MEGA2560) -#define IS_SKY9X(board) (board==BOARD_SKY9X || board==BOARD_9XRPRO || board==BOARD_AR9X) -#define IS_9XRPRO(board) (board==BOARD_9XRPRO) -#define IS_TARANIS_X7(board) (board==BOARD_TARANIS_X7) -#define IS_TARANIS_X9(board) (board==BOARD_TARANIS_X9D || board==BOARD_TARANIS_X9DP || board==BOARD_TARANIS_X9E) -#define IS_TARANIS_PLUS(board) (board==BOARD_TARANIS_X9DP || board==BOARD_TARANIS_X9E) -#define IS_TARANIS_X9E(board) (board==BOARD_TARANIS_X9E) +#define IS_9X(board) (board==Board::BOARD_STOCK || board==Board::BOARD_M128) +#define IS_STOCK(board) (board==Board::BOARD_STOCK) +#define IS_2560(board) (board==Board::BOARD_GRUVIN9X || board==Board::BOARD_MEGA2560) +#define IS_SKY9X(board) (board==Board::BOARD_SKY9X || board==Board::BOARD_9XRPRO || board==Board::BOARD_AR9X) +#define IS_9XRPRO(board) (board==Board::BOARD_9XRPRO) +#define IS_TARANIS_X7(board) (board==Board::BOARD_TARANIS_X7) +#define IS_TARANIS_X9(board) (board==Board::BOARD_TARANIS_X9D || board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E) +#define IS_TARANIS_PLUS(board) (board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E) +#define IS_TARANIS_X9E(board) (board==Board::BOARD_TARANIS_X9E) #define IS_TARANIS(board) (IS_TARANIS_X9(board) || IS_TARANIS_X7(board)) -#define IS_HORUS(board) (board==BOARD_HORUS) +#define IS_HORUS(board) (board==Board::BOARD_HORUS) #define IS_HORUS_OR_TARANIS(board) (IS_HORUS(board) || IS_TARANIS(board)) -#define IS_FLAMENCO(board) (board==BOARD_FLAMENCO) +#define IS_FLAMENCO(board) (board==Board::BOARD_FLAMENCO) #define IS_STM32(board) (IS_TARANIS(board) || IS_HORUS(board) || IS_FLAMENCO(board)) #define IS_ARM(board) (IS_STM32(board) || IS_SKY9X(board)) #define HAS_LARGE_LCD(board) (IS_HORUS(board) || (IS_TARANIS(board) && !IS_TARANIS_X7(board))) diff --git a/companion/src/burnconfigdialog.cpp b/companion/src/burnconfigdialog.cpp index 6b341fd49..2d7771006 100644 --- a/companion/src/burnconfigdialog.cpp +++ b/companion/src/burnconfigdialog.cpp @@ -40,7 +40,7 @@ burnConfigDialog::burnConfigDialog(QWidget *parent) : getSettings(); populateProgrammers(); - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (IS_STM32(board)) { setWindowTitle(tr("DFU-UTIL Configuration")); ui->avrArgs->hide(); @@ -328,7 +328,7 @@ void burnConfigDialog::on_pushButton_4_clicked() void burnConfigDialog::on_advCtrChkB_toggled(bool checked) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (checked) { if (IS_STM32(board)) { ui->label_dfu2->show(); diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index cd4b9a169..79cf9e952 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -592,9 +592,9 @@ bool RawSource::isSlider() const index < CPN_MAX_STICKS+getCurrentFirmware()->getCapability(Pots)+getCurrentFirmware()->getCapability(Sliders)); } -QString RawSwitch::toString(BoardEnum board) const +QString RawSwitch::toString(Board::Type board) const { - if (board == BOARD_UNKNOWN) { + if (board == Board::BOARD_UNKNOWN) { board = getCurrentBoard(); } @@ -638,7 +638,7 @@ QString RawSwitch::toString(BoardEnum board) const case SWITCH_TYPE_SWITCH: if (IS_HORUS_OR_TARANIS(board)) { div_t qr = div(index-1, 3); - SwitchInfo switchInfo = getSwitchInfo(board, qr.quot); + Board::SwitchInfo switchInfo = getSwitchInfo(board, qr.quot); const char * positions[] = { ARROW_UP, "-", ARROW_DOWN }; return QString(switchInfo.name) + QString(positions[qr.rem]); } @@ -843,7 +843,7 @@ void CustomFunctionData::populateResetParams(const ModelData * model, QComboBox { int val = 0; Firmware * firmware = getCurrentFirmware(); - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); b->addItem(QObject::tr("Timer1"), val++); b->addItem(QObject::tr("Timer2"), val++); @@ -1023,39 +1023,36 @@ void LimitData::clear() max = +1000; } -GeneralSettings::SwitchInfo GeneralSettings::switchInfoFromSwitchPositionTaranis(unsigned int index) -{ - return SwitchInfo((index-1)/3, (index-1)%3); -} - bool GeneralSettings::switchPositionAllowedTaranis(int index) const { if (index == 0) return true; - SwitchInfo info = switchInfoFromSwitchPositionTaranis(abs(index)); - if (index < 0 && switchConfig[info.index] != SWITCH_3POS) + + div_t qr = div(index-1, 3); + + if (index < 0 && switchConfig[qr.quot] != Board::SWITCH_3POS) return false; - else if (info.position == 1) - return switchConfig[info.index] == SWITCH_3POS; + else if (qr.rem == 1) + return switchConfig[qr.quot] == Board::SWITCH_3POS; else - return switchConfig[info.index] != SWITCH_NONE; + return switchConfig[qr.quot] != Board::SWITCH_NOT_AVAILABLE; } bool GeneralSettings::switchSourceAllowedTaranis(int index) const { - return switchConfig[index] != SWITCH_NONE; + return switchConfig[index] != Board::SWITCH_NOT_AVAILABLE; } bool GeneralSettings::isPotAvailable(int index) const { if (index<0 || index>getCurrentFirmware()->getCapability(Pots)) return false; - return potConfig[index] != POT_NONE; + return potConfig[index] != Board::POT_NONE; } bool GeneralSettings::isSliderAvailable(int index) const { if (index<0 || index>getCurrentFirmware()->getCapability(Sliders)) return false; - return sliderConfig[index] != SLIDER_NONE; + return sliderConfig[index] != Board::SLIDER_NONE; } GeneralSettings::GeneralSettings() @@ -1072,40 +1069,40 @@ GeneralSettings::GeneralSettings() } Firmware * firmware = getCurrentFirmware(); - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); for (int i=0; igetCapability(FactoryInstalledSwitches); i++) { switchConfig[i] = getSwitchInfo(board, i).config; } if (IS_HORUS(board)) { - potConfig[0] = POT_WITH_DETENT; - potConfig[1] = POT_MULTIPOS_SWITCH; - potConfig[2] = POT_WITH_DETENT; + potConfig[0] = Board::POT_WITH_DETENT; + potConfig[1] = Board::POT_MULTIPOS_SWITCH; + potConfig[2] = Board::POT_WITH_DETENT; } else if (IS_TARANIS_X7(board)) { - potConfig[0] = POT_WITHOUT_DETENT; - potConfig[1] = POT_WITH_DETENT; + potConfig[0] = Board::POT_WITHOUT_DETENT; + potConfig[1] = Board::POT_WITH_DETENT; } else if (IS_TARANIS(board)) { - potConfig[0] = POT_WITH_DETENT; - potConfig[1] = POT_WITH_DETENT; + potConfig[0] = Board::POT_WITH_DETENT; + potConfig[1] = Board::POT_WITH_DETENT; } else { - potConfig[0] = POT_WITHOUT_DETENT; - potConfig[1] = POT_WITHOUT_DETENT; - potConfig[2] = POT_WITHOUT_DETENT; + potConfig[0] = Board::POT_WITHOUT_DETENT; + potConfig[1] = Board::POT_WITHOUT_DETENT; + potConfig[2] = Board::POT_WITHOUT_DETENT; } if (IS_HORUS(board) || IS_TARANIS_X9E(board)) { - sliderConfig[0] = SLIDER_WITH_DETENT; - sliderConfig[1] = SLIDER_WITH_DETENT; - sliderConfig[2] = SLIDER_WITH_DETENT; - sliderConfig[3] = SLIDER_WITH_DETENT; + sliderConfig[0] = Board::SLIDER_WITH_DETENT; + sliderConfig[1] = Board::SLIDER_WITH_DETENT; + sliderConfig[2] = Board::SLIDER_WITH_DETENT; + sliderConfig[3] = Board::SLIDER_WITH_DETENT; } else if (IS_TARANIS(board) && !IS_TARANIS_X7(board)) { - sliderConfig[0] = SLIDER_WITH_DETENT; - sliderConfig[1] = SLIDER_WITH_DETENT; + sliderConfig[0] = Board::SLIDER_WITH_DETENT; + sliderConfig[1] = Board::SLIDER_WITH_DETENT; } if (IS_ARM(board)) { @@ -1506,7 +1503,7 @@ QString removeAccents(const QString & str) void ModelData::setDefaultInputs(const GeneralSettings & settings) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (IS_ARM(board)) { for (int i=0; igetEEpromInterface(); } -inline BoardEnum getCurrentBoard() +inline Board::Type getCurrentBoard() { return getCurrentFirmware()->getBoard(); } diff --git a/companion/src/firmwares/er9x/er9xinterface.cpp b/companion/src/firmwares/er9x/er9xinterface.cpp index bdee523a4..0947c77e2 100644 --- a/companion/src/firmwares/er9x/er9xinterface.cpp +++ b/companion/src/firmwares/er9x/er9xinterface.cpp @@ -32,7 +32,7 @@ #define FILE_MODEL(n) (1+n) Er9xInterface::Er9xInterface(): - EEPROMInterface(BOARD_STOCK), + EEPROMInterface(Board::BOARD_STOCK), efile(new RleFile()) { } @@ -116,13 +116,13 @@ unsigned long Er9xInterface::load(RadioData &radioData, const uint8_t *eeprom, i std::bitset errors; - if (size != getEEpromSize(BOARD_STOCK)) { + if (size != getEEpromSize(Board::BOARD_STOCK)) { std::cout << "wrong size\n"; errors.set(WRONG_SIZE); return errors.to_ulong(); } - if (!efile->EeFsOpen((uint8_t *)eeprom, size, BOARD_STOCK)) { + if (!efile->EeFsOpen((uint8_t *)eeprom, size, Board::BOARD_STOCK)) { std::cout << "wrong file system\n"; errors.set(WRONG_FILE_SYSTEM); return errors.to_ulong(); diff --git a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp index c5b50c88b..8aefef92e 100644 --- a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp @@ -34,7 +34,7 @@ #define FILE_TMP (1+16) Ersky9xInterface::Ersky9xInterface(): -EEPROMInterface(BOARD_SKY9X), +EEPROMInterface(Board::BOARD_SKY9X), efile(new RleFile()) { } @@ -164,7 +164,7 @@ unsigned long Ersky9xInterface::load(RadioData &radioData, const uint8_t *eeprom return errors.to_ulong(); } - if (!efile->EeFsOpen((uint8_t *)eeprom, size, BOARD_SKY9X)) { + if (!efile->EeFsOpen((uint8_t *)eeprom, size, Board::BOARD_SKY9X)) { std::cout << "wrong file system\n"; errors.set(WRONG_FILE_SYSTEM); return errors.to_ulong(); diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 570db6931..5f9d5984f 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -24,6 +24,8 @@ #include #include +using namespace Board; + #define IS_DBLEEPROM(board, version) ((IS_2560(board) || board==BOARD_M128) && version >= 213) // Macro used for Gruvin9x board and M128 board between versions 213 and 214 (when there were stack overflows!) #define IS_DBLRAM(board, version) ((IS_2560(board) && version >= 213) || (board==BOARD_M128 && version >= 213 && version <= 214)) @@ -56,7 +58,7 @@ #define IS_AFTER_RELEASE_21_MARCH_2013(board, version) (version >= 214 || (!IS_ARM(board) && version >= 213)) #define IS_AFTER_RELEASE_23_MARCH_2013(board, version) (version >= 214 || (board==BOARD_STOCK && version >= 213)) -inline int switchIndex(int i, BoardEnum board, unsigned int version) +inline int switchIndex(int i, Board::Type board, unsigned int version) { bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version); if (!IS_HORUS_OR_TARANIS(board) && afterrelease21March2013) @@ -68,7 +70,7 @@ inline int switchIndex(int i, BoardEnum board, unsigned int version) class SwitchesConversionTable: public ConversionTable { public: - SwitchesConversionTable(BoardEnum board, unsigned int version, bool timer=false) + SwitchesConversionTable(Board::Type board, unsigned int version, bool timer=false) { int val=0; int offset=0; @@ -177,14 +179,14 @@ class SwitchesConversionTable: public ConversionTable { class Cache { public: - Cache(BoardEnum board, unsigned int version, unsigned long flags, SwitchesConversionTable * table): + Cache(Board::Type board, unsigned int version, unsigned long flags, SwitchesConversionTable * table): board(board), version(version), flags(flags), table(table) { } - BoardEnum board; + Board::Type board; unsigned int version; unsigned long flags; SwitchesConversionTable * table; @@ -194,7 +196,7 @@ class SwitchesConversionTable: public ConversionTable { public: - static SwitchesConversionTable * getInstance(BoardEnum board, unsigned int version, unsigned long flags=0) + static SwitchesConversionTable * getInstance(Board::Type board, unsigned int version, unsigned long flags=0) { for (std::list::iterator it=internalCache.begin(); it!=internalCache.end(); it++) { Cache element = *it; @@ -225,7 +227,7 @@ std::list SwitchesConversionTable::internalCache class SourcesConversionTable: public ConversionTable { public: - SourcesConversionTable(BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0) + SourcesConversionTable(Board::Type board, unsigned int version, unsigned int variant, unsigned long flags=0) { bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version); @@ -363,7 +365,7 @@ class SourcesConversionTable: public ConversionTable { class Cache { public: - Cache(BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags, SourcesConversionTable * table): + Cache(Board::Type board, unsigned int version, unsigned int variant, unsigned long flags, SourcesConversionTable * table): board(board), version(version), variant(variant), @@ -371,7 +373,7 @@ class SourcesConversionTable: public ConversionTable { table(table) { } - BoardEnum board; + Board::Type board; unsigned int version; unsigned int variant; unsigned long flags; @@ -381,7 +383,7 @@ class SourcesConversionTable: public ConversionTable { public: - static SourcesConversionTable * getInstance(BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0) + static SourcesConversionTable * getInstance(Board::Type board, unsigned int version, unsigned int variant, unsigned long flags=0) { for (std::list::iterator it=internalCache.begin(); it!=internalCache.end(); it++) { Cache element = *it; @@ -414,7 +416,7 @@ void OpenTxEepromCleanup(void) template class SwitchField: public ConversionField< SignedField > { public: - SwitchField(RawSwitch & sw, BoardEnum board, unsigned int version, unsigned long flags=0): + SwitchField(RawSwitch & sw, Board::Type board, unsigned int version, unsigned long flags=0): ConversionField< SignedField >(_switch, SwitchesConversionTable::getInstance(board, version, flags), QObject::tr("Switch").toLatin1(), QObject::tr("Switch ").toLatin1()+ sw.toString(board) + QObject::tr(" cannot be exported on this board!").toLatin1()), sw(sw), @@ -443,13 +445,13 @@ class SwitchField: public ConversionField< SignedField > { protected: RawSwitch & sw; int _switch; - BoardEnum board; + Board::Type board; }; class TelemetrySourcesConversionTable: public ConversionTable { public: - TelemetrySourcesConversionTable(BoardEnum board, unsigned int version) + TelemetrySourcesConversionTable(Board::Type board, unsigned int version) { int val = 0; @@ -539,7 +541,7 @@ class TelemetrySourcesConversionTable: public ConversionTable { template class TelemetrySourceField: public ConversionField< UnsignedField > { public: - TelemetrySourceField(RawSource & source, BoardEnum board, unsigned int version): + TelemetrySourceField(RawSource & source, Board::Type board, unsigned int version): ConversionField< UnsignedField >(_source, &conversionTable, "Telemetry source"), conversionTable(board, version), source(source), @@ -569,7 +571,7 @@ class TelemetrySourceField: public ConversionField< UnsignedField > { protected: TelemetrySourcesConversionTable conversionTable; RawSource & source; - BoardEnum board; + Board::Type board; unsigned int version; unsigned int _source; }; @@ -577,7 +579,7 @@ class TelemetrySourceField: public ConversionField< UnsignedField > { template class SourceField: public ConversionField< UnsignedField > { public: - SourceField(RawSource & source, BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0): + SourceField(RawSource & source, Board::Type board, unsigned int version, unsigned int variant, unsigned long flags=0): ConversionField< UnsignedField >(_source, SourcesConversionTable::getInstance(board, version, variant, flags), "Source", QObject::tr("Source %1 cannot be exported on this board!").arg(source.toString())), source(source), @@ -630,7 +632,7 @@ int smallGvarToC9x(int gvar) return gvar; } -void splitGvarParam(const int gvar, int & _gvar, unsigned int & _gvarParam, const BoardEnum board, const int version) +void splitGvarParam(const int gvar, int & _gvar, unsigned int & _gvarParam, const Board::Type board, const int version) { if (version >= 214 || (!IS_ARM(board) && version >= 213)) { if (gvar < -10000) { @@ -663,7 +665,7 @@ void splitGvarParam(const int gvar, int & _gvar, unsigned int & _gvarParam, cons } } -void concatGvarParam(int & gvar, const int _gvar, const unsigned int _gvarParam, const BoardEnum board, const int version) +void concatGvarParam(int & gvar, const int _gvar, const unsigned int _gvarParam, const Board::Type board, const int version) { if (version >= 214 || (!IS_ARM(board) && version >= 213)) { gvar = _gvar; @@ -731,7 +733,7 @@ void importGvarParam(int & gvar, const int _gvar, int version) class CurveReferenceField: public TransformedField { public: - CurveReferenceField(CurveReference & curve, BoardEnum board, unsigned int version): + CurveReferenceField(CurveReference & curve, Board::Type board, unsigned int version): TransformedField(internalField), curve(curve), _curve_type(0), @@ -777,7 +779,7 @@ static int importHeliInversionWeight(int source) { class HeliField: public StructField { public: - HeliField(SwashRingData & heli, BoardEnum board, unsigned int version, unsigned int variant) + HeliField(SwashRingData & heli, Board::Type board, unsigned int version, unsigned int variant) { if ((IS_ARM(board) && version >= 218) || (IS_STM32(board) && version >= 217)) { Append(new UnsignedField<8>(heli.type)); @@ -803,7 +805,7 @@ class HeliField: public StructField { class FlightModeField: public TransformedField { public: - FlightModeField(FlightModeData & phase, int index, BoardEnum board, unsigned int version): + FlightModeField(FlightModeData & phase, int index, Board::Type board, unsigned int version): TransformedField(internalField), internalField("FlightMode"), phase(phase), @@ -945,7 +947,7 @@ class FlightModeField: public TransformedField { StructField internalField; FlightModeData & phase; int index; - BoardEnum board; + Board::Type board; unsigned int version; int rotencCount; int trimBase[CPN_MAX_STICKS+CPN_MAX_AUX_TRIMS]; @@ -955,7 +957,7 @@ class FlightModeField: public TransformedField { class MixField: public TransformedField { public: - MixField(MixData & mix, BoardEnum board, unsigned int version, ModelData * model): + MixField(MixData & mix, Board::Type board, unsigned int version, ModelData * model): TransformedField(internalField), internalField("Mix"), mix(mix), @@ -1233,7 +1235,7 @@ class MixField: public TransformedField { protected: StructField internalField; MixData & mix; - BoardEnum board; + Board::Type board; unsigned int version; ModelData * model; unsigned int _destCh; @@ -1247,7 +1249,7 @@ class MixField: public TransformedField { class InputField: public TransformedField { public: - InputField(ExpoData & expo, BoardEnum board, unsigned int version): + InputField(ExpoData & expo, Board::Type board, unsigned int version): TransformedField(internalField), internalField("Input"), expo(expo), @@ -1414,7 +1416,7 @@ class InputField: public TransformedField { protected: StructField internalField; ExpoData & expo; - BoardEnum board; + Board::Type board; unsigned int version; bool _curveMode; int _weight; @@ -1454,7 +1456,7 @@ class LimitField: public StructField { return value - shift; } - LimitField(LimitData & limit, BoardEnum board, unsigned int version): + LimitField(LimitData & limit, Board::Type board, unsigned int version): StructField("Limit") { if (IS_ARM(board) && version >= 218) { @@ -1509,7 +1511,7 @@ class LimitField: public StructField { class CurvesField: public TransformedField { public: - CurvesField(CurveData * curves, BoardEnum board, unsigned int version): + CurvesField(CurveData * curves, Board::Type board, unsigned int version): TransformedField(internalField), internalField("Curves"), curves(curves), @@ -1629,7 +1631,7 @@ class CurvesField: public TransformedField { protected: StructField internalField; CurveData * curves; - BoardEnum board; + Board::Type board; unsigned int version; int maxCurves; int maxPoints; @@ -1640,7 +1642,7 @@ class CurvesField: public TransformedField { class LogicalSwitchesFunctionsTable: public ConversionTable { public: - LogicalSwitchesFunctionsTable(BoardEnum board, unsigned int version) + LogicalSwitchesFunctionsTable(Board::Type board, unsigned int version) { int val=0; bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version); @@ -1678,7 +1680,7 @@ class LogicalSwitchesFunctionsTable: public ConversionTable { class AndSwitchesConversionTable: public ConversionTable { public: - AndSwitchesConversionTable(BoardEnum board, unsigned int version) + AndSwitchesConversionTable(Board::Type board, unsigned int version) { int val=0; addConversion(RawSwitch(SWITCH_TYPE_NONE), val++); @@ -1723,7 +1725,7 @@ class AndSwitchesConversionTable: public ConversionTable { } } - static ConversionTable * getInstance(BoardEnum board, unsigned int version) + static ConversionTable * getInstance(Board::Type board, unsigned int version) { if (IS_ARM(board) && version >= 216) return new SwitchesConversionTable(board, version); @@ -1756,7 +1758,7 @@ class AndSwitchesConversionTable: public ConversionTable { class LogicalSwitchField: public TransformedField { public: - LogicalSwitchField(LogicalSwitchData & csw, BoardEnum board, unsigned int version, unsigned int variant, ModelData * model=NULL): + LogicalSwitchField(LogicalSwitchData & csw, Board::Type board, unsigned int version, unsigned int variant, ModelData * model=NULL): TransformedField(internalField), internalField("LogicalSwitch"), csw(csw), @@ -1957,7 +1959,7 @@ class LogicalSwitchField: public TransformedField { protected: StructField internalField; LogicalSwitchData & csw; - BoardEnum board; + Board::Type board; unsigned int version; unsigned int variant; ModelData * model; @@ -1973,7 +1975,7 @@ class LogicalSwitchField: public TransformedField { class CustomFunctionsConversionTable: public ConversionTable { public: - CustomFunctionsConversionTable(BoardEnum board, unsigned int version) + CustomFunctionsConversionTable(Board::Type board, unsigned int version) { int val=0; @@ -2085,7 +2087,7 @@ class CustomFunctionsConversionTable: public ConversionTable { template class SwitchesWarningField: public TransformedField { public: - SwitchesWarningField(uint64_t & sw, BoardEnum board, unsigned int version): + SwitchesWarningField(uint64_t & sw, Board::Type board, unsigned int version): TransformedField(internalField), internalField(_sw, "SwitchesWarning"), sw(sw), @@ -2118,13 +2120,13 @@ class SwitchesWarningField: public TransformedField { BaseUnsignedField internalField; uint64_t & sw; uint64_t _sw; - BoardEnum board; + Board::Type board; unsigned int version; }; class ArmCustomFunctionField: public TransformedField { public: - ArmCustomFunctionField(CustomFunctionData & fn, BoardEnum board, unsigned int version, unsigned int variant): + ArmCustomFunctionField(CustomFunctionData & fn, Board::Type board, unsigned int version, unsigned int variant): TransformedField(internalField), internalField("CustomFunction"), fn(fn), @@ -2352,7 +2354,7 @@ class ArmCustomFunctionField: public TransformedField { protected: StructField internalField; CustomFunctionData & fn; - BoardEnum board; + Board::Type board; unsigned int version; unsigned int variant; CustomFunctionsConversionTable functionsConversionTable; @@ -2365,7 +2367,7 @@ class ArmCustomFunctionField: public TransformedField { class AvrCustomFunctionField: public TransformedField { public: - AvrCustomFunctionField(CustomFunctionData & fn, BoardEnum board, unsigned int version, unsigned int variant): + AvrCustomFunctionField(CustomFunctionData & fn, Board::Type board, unsigned int version, unsigned int variant): TransformedField(internalField), internalField("CustomFunction"), fn(fn), @@ -2541,7 +2543,7 @@ class AvrCustomFunctionField: public TransformedField { protected: StructField internalField; CustomFunctionData & fn; - BoardEnum board; + Board::Type board; unsigned int version; unsigned int variant; CustomFunctionsConversionTable functionsConversionTable; @@ -2554,7 +2556,7 @@ class AvrCustomFunctionField: public TransformedField { class FrskyScreenField: public DataField { public: - FrskyScreenField(FrSkyScreenData & screen, BoardEnum board, unsigned int version, unsigned int variant): + FrskyScreenField(FrSkyScreenData & screen, Board::Type board, unsigned int version, unsigned int variant): DataField("Frsky Screen"), screen(screen), board(board), @@ -2670,7 +2672,7 @@ class FrskyScreenField: public DataField { protected: FrSkyScreenData & screen; - BoardEnum board; + Board::Type board; unsigned int version; StructField none; StructField bars; @@ -2697,7 +2699,7 @@ class RSSIConversionTable: public ConversionTable class TelemetryVarioSourceConversionTable: public ConversionTable { public: - TelemetryVarioSourceConversionTable(BoardEnum board, unsigned int version) + TelemetryVarioSourceConversionTable(Board::Type board, unsigned int version) { int val = 0; if (!IS_TARANIS(board)) { @@ -2716,7 +2718,7 @@ class TelemetryVarioSourceConversionTable: public ConversionTable class TelemetryVoltsSourceConversionTable: public ConversionTable { public: - TelemetryVoltsSourceConversionTable(BoardEnum board, unsigned int version) + TelemetryVoltsSourceConversionTable(Board::Type board, unsigned int version) { int val = 0; addConversion(TELEMETRY_VOLTS_SOURCE_A1, val++); @@ -2733,7 +2735,7 @@ class TelemetryVoltsSourceConversionTable: public ConversionTable class ScreenTypesConversionTable: public ConversionTable { public: - ScreenTypesConversionTable(BoardEnum board, unsigned int version) + ScreenTypesConversionTable(Board::Type board, unsigned int version) { int val = 0; if (IS_ARM(board)) { @@ -2747,7 +2749,7 @@ class ScreenTypesConversionTable: public ConversionTable class TelemetryCurrentSourceConversionTable: public ConversionTable { public: - TelemetryCurrentSourceConversionTable(BoardEnum board, unsigned int version) + TelemetryCurrentSourceConversionTable(Board::Type board, unsigned int version) { int val = 0; addConversion(TELEMETRY_CURRENT_SOURCE_NONE, val++); @@ -2763,7 +2765,7 @@ class TelemetryCurrentSourceConversionTable: public ConversionTable class FrskyField: public StructField { public: - FrskyField(FrSkyData & frsky, BoardEnum board, unsigned int version, unsigned int variant): + FrskyField(FrSkyData & frsky, Board::Type board, unsigned int version, unsigned int variant): StructField("FrSky"), telemetryVarioSourceConversionTable(board, version), screenTypesConversionTable(board, version), @@ -2893,7 +2895,7 @@ class FrskyField: public StructField { class MavlinkField: public StructField { public: - MavlinkField(MavlinkData & mavlink, BoardEnum board, unsigned int version): + MavlinkField(MavlinkData & mavlink, Board::Type board, unsigned int version): StructField("MavLink") { Append(new UnsignedField<4>(mavlink.rc_rssi_scale, "Rc_rssi_scale")); @@ -2924,7 +2926,7 @@ class CustomScreenField: public StructField { class SensorField: public TransformedField { public: - SensorField(SensorData & sensor, BoardEnum board, unsigned int version): + SensorField(SensorData & sensor, Board::Type board, unsigned int version): TransformedField(internalField), internalField("Sensor"), sensor(sensor), @@ -3022,7 +3024,7 @@ class SensorField: public TransformedField { int exportPpmDelay(int delay) { return (delay - 300) / 50; } int importPpmDelay(int delay) { return 300 + 50 * delay; } -OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigned int version, unsigned int variant): +OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsigned int version, unsigned int variant): TransformedField(internalField), internalField("ModelData"), modelData(modelData), @@ -3500,7 +3502,7 @@ void OpenTxModelData::afterImport() } } -OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant): +OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type board, unsigned int version, unsigned int variant): TransformedField(internalField), internalField("General Settings"), generalData(generalData), diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index 8110ff76b..8fd3c8f46 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -38,7 +38,7 @@ class OpenTxGeneralData: public TransformedField { public: - OpenTxGeneralData(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant=0); + OpenTxGeneralData(GeneralSettings & generalData, Board::Type board, unsigned int version, unsigned int variant=0); protected: virtual void beforeExport(); @@ -46,7 +46,7 @@ class OpenTxGeneralData: public TransformedField { StructField internalField; GeneralSettings & generalData; - BoardEnum board; + Board::Type board; unsigned int version; int inputsCount; unsigned int chkSum; @@ -56,7 +56,7 @@ class OpenTxGeneralData: public TransformedField { class ProtocolsConversionTable: public ConversionTable { public: - ProtocolsConversionTable(BoardEnum board) + ProtocolsConversionTable(Board::Type board) { int val = 0; if (IS_ARM(board)) { @@ -105,7 +105,7 @@ class ChannelsConversionTable: public ConversionTable class OpenTxModelData: public TransformedField { public: - OpenTxModelData(ModelData & modelData, BoardEnum board, unsigned int version, unsigned int variant); + OpenTxModelData(ModelData & modelData, Board::Type board, unsigned int version, unsigned int variant); const char * getName() { return name; } @@ -115,7 +115,7 @@ class OpenTxModelData: public TransformedField { StructField internalField; ModelData & modelData; - BoardEnum board; + Board::Type board; unsigned int version; unsigned int variant; diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index b1cd7d1ce..c3b333cab 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -27,6 +27,8 @@ #include #include +using namespace Board; + #define OPENTX_FIRMWARE_DOWNLOADS "http://downloads-22.open-tx.org/firmware" #define OPENTX_NIGHT_FIRMWARE_DOWNLOADS "http://downloads-22.open-tx.org/nightly/firmware" @@ -195,7 +197,7 @@ bool OpenTxEepromInterface::loadFromByteArray(T & dest, const QByteArray & data) template bool -OpenTxEepromInterface::saveRadioSettings(GeneralSettings &settings, BoardEnum board, uint8_t version, uint32_t variant) +OpenTxEepromInterface::saveRadioSettings(GeneralSettings &settings, Board::Type board, uint8_t version, uint32_t variant) { T open9xSettings(settings, board, version, variant); // open9xSettings.Dump(); @@ -302,7 +304,7 @@ unsigned long OpenTxEepromInterface::load(RadioData &radioData, const uint8_t * return errors.to_ulong(); } -uint8_t OpenTxEepromInterface::getLastDataVersion(BoardEnum board) +uint8_t OpenTxEepromInterface::getLastDataVersion(Board::Type board) { switch (board) { case BOARD_STOCK: @@ -1055,7 +1057,7 @@ unsigned long OpenTxEepromInterface::loadBackup(RadioData &radioData, const uint return errors.to_ulong(); } - BoardEnum backupBoard = (BoardEnum) -1; + Type backupBoard = (Type) -1; switch (eeprom[3]) { case 0x33: backupBoard = BOARD_TARANIS_X9D; @@ -1532,7 +1534,7 @@ OpenTxEepromInterface * loadFromByteArray(T & dest, const QByteArray & data) template bool saveToByteArray(const T & dest, QByteArray & data) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); foreach(OpenTxEepromInterface * eepromInterface, opentxEEpromInterfaces) { if (eepromInterface->getBoard() == board) { return eepromInterface->saveToByteArray(dest, data); diff --git a/companion/src/firmwares/opentx/opentxinterface.h b/companion/src/firmwares/opentx/opentxinterface.h index d892fb326..a13b731c5 100644 --- a/companion/src/firmwares/opentx/opentxinterface.h +++ b/companion/src/firmwares/opentx/opentxinterface.h @@ -72,9 +72,9 @@ class OpenTxEepromInterface : public EEPROMInterface bool saveModel(unsigned int index, ModelData & model, uint8_t version, uint32_t variant); template - bool saveRadioSettings(GeneralSettings & settings, BoardEnum board, uint8_t version, uint32_t variant); + bool saveRadioSettings(GeneralSettings & settings, Board::Type board, uint8_t version, uint32_t variant); - uint8_t getLastDataVersion(BoardEnum board); + uint8_t getLastDataVersion(Board::Type board); uint32_t getFourCC(); @@ -93,7 +93,7 @@ class OpenTxFirmware: public Firmware setEEpromInterface(parent->getEEpromInterface()); } - OpenTxFirmware(const QString & id, const QString & name, const BoardEnum board): + OpenTxFirmware(const QString & id, const QString & name, const Board::Type board): Firmware(id, name, board) { addLanguage("en"); diff --git a/companion/src/generaledit/hardware.cpp b/companion/src/generaledit/hardware.cpp index 87e5dbcf1..f08bb71e6 100644 --- a/companion/src/generaledit/hardware.cpp +++ b/companion/src/generaledit/hardware.cpp @@ -21,14 +21,14 @@ #include "hardware.h" #include "ui_hardware.h" -void HardwarePanel::setupSwitchConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type, bool threePos = true) +void HardwarePanel::setupSwitchType(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type, bool threePos = true) { if (IS_STM32(firmware->getBoard()) && index < firmware->getCapability(Switches)) { - type->addItem(tr("None"), SWITCH_NONE); - type->addItem(tr("2 Positions Toggle"), SWITCH_TOGGLE); - type->addItem(tr("2 Positions"), SWITCH_2POS); + type->addItem(tr("None"), Board::SWITCH_NOT_AVAILABLE); + type->addItem(tr("2 Positions Toggle"), Board::SWITCH_TOGGLE); + type->addItem(tr("2 Positions"), Board::SWITCH_2POS); if (threePos) { - type->addItem(tr("3 Positions"), SWITCH_3POS); + type->addItem(tr("3 Positions"), Board::SWITCH_3POS); } name->setField(generalSettings.switchName[index], 3, this); type->setField(generalSettings.switchConfig[index], this); @@ -40,14 +40,14 @@ void HardwarePanel::setupSwitchConfig(int index, QLabel *label, AutoLineEdit *na } } -void HardwarePanel::setupPotConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type) +void HardwarePanel::setupPotType(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type) { if (IS_STM32(firmware->getBoard()) && index < firmware->getCapability(Pots)) { label->setText(RawSource(SOURCE_TYPE_STICK, CPN_MAX_STICKS+index).toString()); - type->addItem(tr("None"), POT_NONE); - type->addItem(tr("Pot with detent"), POT_WITH_DETENT); - type->addItem(tr("Multipos switch"), POT_MULTIPOS_SWITCH); - type->addItem(tr("Pot without detent"), POT_WITHOUT_DETENT); + type->addItem(tr("None"), Board::POT_NONE); + type->addItem(tr("Pot with detent"), Board::POT_WITH_DETENT); + type->addItem(tr("Multipos switch"), Board::POT_MULTIPOS_SWITCH); + type->addItem(tr("Pot without detent"), Board::POT_WITHOUT_DETENT); name->setField(generalSettings.potName[index], 3, this); type->setField(generalSettings.potConfig[index], this); } @@ -58,12 +58,12 @@ void HardwarePanel::setupPotConfig(int index, QLabel *label, AutoLineEdit *name, } } -void HardwarePanel::setupSliderConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type) +void HardwarePanel::setupSliderType(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type) { if (IS_STM32(firmware->getBoard()) && index < firmware->getCapability(Sliders)) { label->setText(RawSource(SOURCE_TYPE_STICK, CPN_MAX_STICKS+firmware->getCapability(Pots)+index).toString()); - type->addItem(tr("None"), SLIDER_NONE); - type->addItem(tr("Slider with detent"), SLIDER_WITH_DETENT); + type->addItem(tr("None"), Board::SLIDER_NONE); + type->addItem(tr("Slider with detent"), Board::SLIDER_WITH_DETENT); name->setField(generalSettings.sliderName[index], 3, this); type->setField(generalSettings.sliderConfig[index], this); } @@ -80,7 +80,7 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings { ui->setupUi(this); - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); if (IS_STM32(board)) { ui->rudName->setField(generalSettings.stickName[0], 3, this); @@ -99,34 +99,34 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings ui->ailName->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); + setupPotType(0, ui->pot1Label, ui->pot1Name, ui->pot1Type); + setupPotType(1, ui->pot2Label, ui->pot2Name, ui->pot2Type); + setupPotType(2, ui->pot3Label, ui->pot3Name, ui->pot3Type); + setupPotType(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); + setupSliderType(0, ui->lsLabel, ui->lsName, ui->lsType); + setupSliderType(1, ui->rsLabel, ui->rsName, ui->rsType); + setupSliderType(2, ui->ls2Label, ui->ls2Name, ui->ls2Type); + setupSliderType(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, false); //switch does not support 3POS - setupSwitchConfig(6, ui->sgLabel, ui->sgName, ui->sgType); - setupSwitchConfig(7, ui->shLabel, ui->shName, ui->shType, false); //switch does not support 3POS - 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); + setupSwitchType(0, ui->saLabel, ui->saName, ui->saType); + setupSwitchType(1, ui->sbLabel, ui->sbName, ui->sbType); + setupSwitchType(2, ui->scLabel, ui->scName, ui->scType); + setupSwitchType(3, ui->sdLabel, ui->sdName, ui->sdType); + setupSwitchType(4, ui->seLabel, ui->seName, ui->seType); + setupSwitchType(5, ui->sfLabel, ui->sfName, ui->sfType, false); //switch does not support 3POS + setupSwitchType(6, ui->sgLabel, ui->sgName, ui->sgType); + setupSwitchType(7, ui->shLabel, ui->shName, ui->shType, false); //switch does not support 3POS + setupSwitchType(8, ui->siLabel, ui->siName, ui->siType); + setupSwitchType(9, ui->sjLabel, ui->sjName, ui->sjType); + setupSwitchType(10, ui->skLabel, ui->skName, ui->skType); + setupSwitchType(11, ui->slLabel, ui->slName, ui->slType); + setupSwitchType(12, ui->smLabel, ui->smName, ui->smType); + setupSwitchType(13, ui->snLabel, ui->snName, ui->snType); + setupSwitchType(14, ui->soLabel, ui->soName, ui->soType); + setupSwitchType(15, ui->spLabel, ui->spName, ui->spType); + setupSwitchType(16, ui->sqLabel, ui->sqName, ui->sqType); + setupSwitchType(17, ui->srLabel, ui->srName, ui->srType); if (IS_HORUS_OR_TARANIS(board) && !IS_TARANIS_X7(board)) { ui->serialPortMode->setCurrentIndex(generalSettings.hw_uartMode); diff --git a/companion/src/generaledit/hardware.h b/companion/src/generaledit/hardware.h index 430ad600a..a067e4431 100644 --- a/companion/src/generaledit/hardware.h +++ b/companion/src/generaledit/hardware.h @@ -36,7 +36,7 @@ class HardwarePanel : public GeneralPanel Q_OBJECT public: - HardwarePanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware); + HardwarePanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware); virtual ~HardwarePanel(); private slots: @@ -54,9 +54,9 @@ class HardwarePanel : public GeneralPanel 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, bool threePos); + void setupPotType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type); + void setupSliderType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type); + void setupSwitchType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type, bool threePos); private: Ui::Hardware *ui; diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index bb474af33..95ea61f8f 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -376,7 +376,7 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase) void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, SwitchContext context) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); RawSwitch item; b->clear(); @@ -413,7 +413,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=getCurrentFirmware()->getCapability(MultiposPots)-1; i>=0; i--) { - if (generalSettings.potConfig[i] == POT_MULTIPOS_SWITCH) { + if (generalSettings.potConfig[i] == Board::POT_MULTIPOS_SWITCH) { for (int j=-getCurrentFirmware()->getCapability(MultiposPotsPositions); j<0; j++) { item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i*getCurrentFirmware()->getCapability(MultiposPotsPositions)+j); b->addItem(item.toString(), item.toValue()); @@ -454,7 +454,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=0; igetCapability(MultiposPots); i++) { - if (generalSettings.potConfig[i] == POT_MULTIPOS_SWITCH) { + if (generalSettings.potConfig[i] == Board::POT_MULTIPOS_SWITCH) { for (int j=1; j<=getCurrentFirmware()->getCapability(MultiposPotsPositions); j++) { item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*getCurrentFirmware()->getCapability(MultiposPotsPositions)+j); b->addItem(item.toString(), item.toValue()); @@ -546,7 +546,7 @@ void populateGVCB(QComboBox & b, int value, const ModelData & model) void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); RawSource item; b->clear(); @@ -824,7 +824,7 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx) #endif Firmware * firmware = getCurrentFirmware(); RadioData * simuData = new RadioData(radioData); - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); QByteArray eeprom = QByteArray(); QString sdPath = g.profile[g.id()].sdPath(); QString settingsPath = ""; diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index d0c8e6b06..c0bc3c11e 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -727,7 +727,7 @@ void MainWindow::loadBackup() void MainWindow::readEeprom() { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); QString tempFile; if (IS_HORUS(board)) tempFile = generateProcessUniqueTempFileName("temp.otx"); diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 668d79cb5..545a31355 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -166,7 +166,7 @@ void MdiChild::onFirmwareChanged() convertStorage(previous->getBoard(), firmware->getBoard()); } -void MdiChild::convertStorage(BoardEnum from, BoardEnum to) +void MdiChild::convertStorage(Board::Type from, Board::Type to) { QMessageBox::warning(this, "Companion", tr("Models and settings will be automatically converted.\nIf that is not what you intended, please close the file\nand choose the correct radio type/profile before reopening it."), QMessageBox::Ok); radioData.convert(from, to); @@ -179,7 +179,7 @@ void MdiChild::convertStorage(BoardEnum from, BoardEnum to) void MdiChild::initModelsList() { - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); delete modelsListModel; modelsListModel = new TreeModel(&radioData, this); @@ -625,8 +625,8 @@ void MdiChild::setCurrentFile(const QString & fileName) void MdiChild::writeEeprom() // write to Tx { - BoardEnum board = getCurrentBoard(); - if (board == BOARD_HORUS) { + Board::Type board = getCurrentBoard(); + if (board == Board::BOARD_HORUS) { QString radioPath = findMassstoragePath("RADIO", true); qDebug() << "Searching for SD card, found" << radioPath; if (radioPath.isEmpty()) { diff --git a/companion/src/mdichild.h b/companion/src/mdichild.h index 680c7e9ac..64985ae32 100644 --- a/companion/src/mdichild.h +++ b/companion/src/mdichild.h @@ -59,7 +59,7 @@ class MdiChild : public QWidget void copyAvailable(bool val); protected: - void convertStorage(BoardEnum from, BoardEnum to); + void convertStorage(Board::Type from, Board::Type to); void forceNewFilename(const QString & suffix, const QString & ext); void closeEvent(QCloseEvent * event); diff --git a/companion/src/modeledit/channels.cpp b/companion/src/modeledit/channels.cpp index 49bf42654..011d6e2a0 100644 --- a/companion/src/modeledit/channels.cpp +++ b/companion/src/modeledit/channels.cpp @@ -27,7 +27,7 @@ LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row value(value), displayStep(0.1) { - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); bool allowGVars = IS_HORUS_OR_TARANIS(board); int internalStep = 1; diff --git a/companion/src/modeledit/flightmodes.cpp b/companion/src/modeledit/flightmodes.cpp index c24dba156..0bf47eebb 100644 --- a/companion/src/modeledit/flightmodes.cpp +++ b/companion/src/modeledit/flightmodes.cpp @@ -87,7 +87,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI trimsValue << ui->trim1Value << ui->trim2Value << ui->trim3Value << ui->trim4Value; trimsSlider << ui->trim1Slider << ui->trim2Slider << ui->trim3Slider << ui->trim4Slider; - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); for (int i=0; i<4; i++) { trimsLabel[i]->setText(labels[CONVERT_MODE(i+1)-1]); @@ -305,7 +305,7 @@ void FlightModePanel::trimUpdate(unsigned int trim) trimsSlider[trim]->setEnabled(false); } else { - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); if (IS_HORUS_OR_TARANIS(board)) trimsUse[trim]->setCurrentIndex(1 + 2*phase.trimRef[chn] + phase.trimMode[chn] - (phase.trimRef[chn] > phaseIdx ? 1 : 0)); else @@ -410,7 +410,7 @@ void FlightModePanel::phaseTrimUse_currentIndexChanged(int index) phase.trim[chn] = 0; } else { - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); if (IS_HORUS_OR_TARANIS(board)) { phase.trimMode[chn] = data % 2; phase.trimRef[chn] = data / 2; diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 60dd0a76e..187e93e81 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -523,8 +523,8 @@ void LogicalSwitchesPanel::csw_customContextMenuRequested(QPoint pos) QPoint globalPos = label->mapToGlobal(pos); - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); + const QClipboard * clipboard = QApplication::clipboard(); + const QMimeData * mimeData = clipboard->mimeData(); bool hasData = mimeData->hasFormat("application/x-companion-csw"); QMenu contextMenu; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 067761094..93fb4bf0c 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -31,7 +31,7 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge timer(timer), ui(new Ui::Timer) { - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); ui->setupUi(this); @@ -569,7 +569,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::Setup) { - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); lock = true; @@ -709,11 +709,11 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge // Startup switches warnings for (int i=0; igetCapability(Switches); i++) { - SwitchInfo switchInfo = getSwitchInfo(board, i); + Board::SwitchInfo switchInfo = getSwitchInfo(board, i); if (IS_HORUS_OR_TARANIS(board)) { - switchInfo.config = SwitchConfig(generalSettings.switchConfig[i]); + switchInfo.config = Board::SwitchType(generalSettings.switchConfig[i]); } - if (switchInfo.config == SWITCH_NOT_AVAILABLE || switchInfo.config == SWITCH_TOGGLE) { + if (switchInfo.config == Board::SWITCH_NOT_AVAILABLE || switchInfo.config == Board::SWITCH_TOGGLE) { continue; } QLabel * label = new QLabel(this); @@ -730,7 +730,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge slider->setPageStep(1); slider->setTickInterval(1); label->setText(switchInfo.name); - slider->setMaximum(switchInfo.config == SWITCH_3POS ? 2 : 1); + slider->setMaximum(switchInfo.config == Board::SWITCH_3POS ? 2 : 1); cb->setProperty("index", i); ui->switchesStartupLayout->addWidget(label, 0, i+1); ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter); @@ -855,7 +855,7 @@ void SetupPanel::on_name_editingFinished() void SetupPanel::on_image_currentIndexChanged(int index) { if (!lock) { - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); strncpy(model->bitmap, ui->image->currentText().toLatin1(), 10); QString path = g.profile[g.id()].sdPath(); path.append("/IMAGES/"); @@ -960,7 +960,7 @@ void SetupPanel::updateStartupSwitches() bool enabled = !(model->switchWarningEnable & (1 << index)); if (IS_HORUS_OR_TARANIS(firmware->getBoard())) { value = (switchStates >> 2*index) & 0x03; - if (generalSettings.switchConfig[index] != SWITCH_3POS && value == 2) { + if (generalSettings.switchConfig[index] != Board::SWITCH_3POS && value == 2) { value = 1; } } @@ -999,7 +999,7 @@ void SetupPanel::startupSwitchEdited(int value) model->switchWarningStates &= ~mask; - if (IS_HORUS_OR_TARANIS(firmware->getBoard()) && generalSettings.switchConfig[index] != SWITCH_3POS) { + if (IS_HORUS_OR_TARANIS(firmware->getBoard()) && generalSettings.switchConfig[index] != Board::SWITCH_3POS) { if (value == 1) { value = 2; } diff --git a/companion/src/modeledit/templates.cpp b/companion/src/modeledit/templates.cpp index ad4294e4f..00c63d4f0 100644 --- a/companion/src/modeledit/templates.cpp +++ b/companion/src/modeledit/templates.cpp @@ -242,8 +242,8 @@ void Templates::applyNumericTemplate(uint64_t tpl) } } if (flaps>0) { - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; } sign=-1; for (uint8_t i=0; i< flaps; i++) { @@ -304,18 +304,18 @@ void Templates::applyNumericTemplate(uint64_t tpl) md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); } md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; switch (gyro) { case 1: - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); break; case 2: - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); break; } } else { @@ -329,25 +329,25 @@ void Templates::applyNumericTemplate(uint64_t tpl) md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); } md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; switch (gyro) { case 1: - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); break; case 2: - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); break; } } // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; break; case 2: ailerons=ailerontype; @@ -433,8 +433,8 @@ void Templates::applyNumericTemplate(uint64_t tpl) } } if (flaps>0) { - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; } sign=-1; for (uint8_t i=0; i< flaps; i++) { @@ -458,8 +458,8 @@ void Templates::applyNumericTemplate(uint64_t tpl) } } if (spoilers>0) { - md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6); md->speedUp=4;;md->speedDown=4; - md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6);md->speedUp=4;md->speedDown=4; + md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6); md->speedUp=4;;md->speedDown=4; + md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6);md->speedUp=4;md->speedDown=4; } sign=-1; for (uint8_t i=0; i< spoilers; i++) { @@ -528,8 +528,8 @@ void Templates::applyNumericTemplate(uint64_t tpl) } } if (flaps>0) { - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; } sign=-1; for (uint8_t i=0; i< flaps; i++) { @@ -597,15 +597,15 @@ void Templates::applyTemplate(uint8_t idx) //T-Cut if(idx==j++) { - md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; } //sticky t-cut if(idx==j++) { - md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 12); md->mltpx=MLTPX_REP; + md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_VIRTUAL, 12); md->mltpx=MLTPX_REP; md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; - md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; + md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; setSwitch(0xB, LS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); setSwitch(0xC, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); updateSwitchesTab(); @@ -648,19 +648,19 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); // throttle - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; // gyro gain - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; model.swashRingData.type = HELI_SWASH_TYPE_120; model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); @@ -694,19 +694,19 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); // throttle - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; // gyro gain - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); md->sOffset=100; - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); md->sOffset=100; + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100; // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; model.swashRingData.type = HELI_SWASH_TYPE_120; model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); @@ -741,8 +741,8 @@ void Templates::applyTemplate(uint8_t idx) } } } - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); md->sOffset=100; - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); md->sOffset=100; + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100; } //Heli Setup futaba style @@ -760,19 +760,19 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); // throttle - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; // gyro gain - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; model.swashRingData.type = HELI_SWASH_TYPE_120; model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); @@ -806,19 +806,19 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); // throttle - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; // gyro gain - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); md->sOffset=100; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); md->sOffset=100; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100; // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; model.swashRingData.type = HELI_SWASH_TYPE_120; model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); @@ -853,16 +853,16 @@ void Templates::applyTemplate(uint8_t idx) } } } - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-SWITCH_GEA); md->sOffset=100; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_GEA); md->sOffset=100; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100; } //Servo Test if(idx==j++) { md=setDest(15); md->srcRaw=RawSource(SOURCE_TYPE_CH, 15); md->weight= 100; md->speedUp = 8; md->speedDown = 8; md->swtch=RawSwitch(); md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch(); - md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; - md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; + md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(Board::SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; + md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(Board::SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; setSwitch(1, LS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); setSwitch(2, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); setSwitch(3, LS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); diff --git a/companion/src/modelprinter.cpp b/companion/src/modelprinter.cpp index 48c0a4552..fc7db2206 100644 --- a/companion/src/modelprinter.cpp +++ b/companion/src/modelprinter.cpp @@ -422,7 +422,7 @@ QString ModelPrinter::printInputLine(const ExpoData & input) QString flightModesStr = printFlightModes(input.flightModes); if (!flightModesStr.isEmpty()) str += " " + flightModesStr.toHtmlEscaped(); - if (input.swtch.type != SWITCH_TYPE_NONE) + if (input.swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch").toHtmlEscaped() + QString("(%1)").arg(input.swtch.toString().toHtmlEscaped()); diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index 008ba1e8d..5d0c0692c 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -106,7 +106,7 @@ TreeModel::TreeModel(RadioData * radioData, QObject * parent): radioData(radioData), availableEEpromSize(-1) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); QVector labels; if (!IS_HORUS(board)) labels << tr("Index"); @@ -244,7 +244,7 @@ bool TreeModel::setData(const QModelIndex & index, const QVariant & value, int r void TreeModel::refresh() { EEPROMInterface * eepromInterface = getCurrentEEpromInterface(); - BoardEnum board = eepromInterface->getBoard(); + Board::Type board = eepromInterface->getBoard(); if (!IS_SKY9X(board) && !IS_HORUS(board)) { availableEEpromSize = getEEpromSize(board) - 64; // let's consider fat diff --git a/companion/src/radiodata.cpp b/companion/src/radiodata.cpp index 626e6236f..5f89b9d5f 100644 --- a/companion/src/radiodata.cpp +++ b/companion/src/radiodata.cpp @@ -23,12 +23,12 @@ // TODO here we will move a lot of functions from eeprominterface.cpp when no merge risk -void ModelData::convert(BoardEnum before, BoardEnum after) +void ModelData::convert(Board::Type before, Board::Type after) { // Here we can add explicit conversions when moving from one board to another } -void GeneralSettings::convert(BoardEnum before, BoardEnum after) +void GeneralSettings::convert(Board::Type before, Board::Type after) { // Here we can add explicit conversions when moving from one board to another } @@ -88,7 +88,7 @@ QString RadioData::getNextModelFilename() return filename; } -void RadioData::convert(BoardEnum before, BoardEnum after) +void RadioData::convert(Board::Type before, Board::Type after) { generalSettings.convert(before, after); for (unsigned i=0; i= 0 ? (type * 256 + index) : -(type * 256 - index); } - QString toString(BoardEnum board = BOARD_UNKNOWN) const; + QString toString(Board::Type board = Board::BOARD_UNKNOWN) const; bool operator== ( const RawSwitch& other) { return (this->type == other.type) && (this->index == other.index); @@ -1008,7 +1007,7 @@ class ModelData { ModelData(const ModelData & src); ModelData & operator = (const ModelData & src); - void convert(BoardEnum before, BoardEnum after); + void convert(Board::Type before, Board::Type after); ExpoData * insertInput(const int idx); void removeInput(const int idx); @@ -1130,7 +1129,7 @@ class GeneralSettings { }; GeneralSettings(); - void convert(BoardEnum before, BoardEnum after); + void convert(Board::Type before, Board::Type after); int getDefaultStick(unsigned int channel) const; RawSource getDefaultSource(unsigned int channel) const; @@ -1224,17 +1223,6 @@ class GeneralSettings { typedef uint8_t ThemeOptionData[8+1]; ThemeOptionData themeOptionValue[5]; - struct SwitchInfo { - SwitchInfo(unsigned int index, unsigned int position): - index(index), - position(position) - { - } - unsigned int index; - unsigned int position; - }; - - static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index); bool switchPositionAllowedTaranis(int index) const; bool switchSourceAllowedTaranis(int index) const; bool isPotAvailable(int index) const; @@ -1257,7 +1245,7 @@ class RadioData { std::vector categories; std::vector models; - void convert(BoardEnum before, BoardEnum after); + void convert(Board::Type before, Board::Type after); void setCurrentModel(unsigned int index); void fixModelFilenames(); diff --git a/companion/src/radiointerface.cpp b/companion/src/radiointerface.cpp index 1fdbaab20..22acedb32 100644 --- a/companion/src/radiointerface.cpp +++ b/companion/src/radiointerface.cpp @@ -36,7 +36,7 @@ QString getRadioInterfaceCmd() { burnConfigDialog bcd; - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (IS_STM32(board)) { return bcd.getDFU(); } @@ -54,12 +54,12 @@ QStringList getAvrdudeArgs(const QString & cmd, const QString & filename) burnConfigDialog bcd; QString programmer = bcd.getProgrammer(); QString mcu = bcd.getMCU(); - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); args << "-c" << programmer << "-p"; if (IS_2560(board)) args << "m2560"; - else if (board == BOARD_M128) + else if (board == Board::BOARD_M128) args << "m128"; else args << mcu; @@ -137,7 +137,7 @@ QStringList getReadEEpromCmd(const QString & filename) QStringList getWriteEEpromCmd(const QString & filename) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (IS_STM32(board)) { // impossible return QStringList(); @@ -152,14 +152,14 @@ QStringList getWriteEEpromCmd(const QString & filename) QStringList getWriteFirmwareArgs(const QString & filename) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (IS_STM32(board)) { return getDfuArgs("-D", filename); } - else if (board == BOARD_SKY9X) { + else if (board == Board::BOARD_SKY9X) { return getSambaArgs(QString("send_file {Flash} \"") + filename + "\" 0x400000 0\n" + "FLASH::ScriptGPNMV 2\n"); } - else if (board == BOARD_9XRPRO || board == BOARD_AR9X) { + else if (board == Board::BOARD_9XRPRO || board == Board::BOARD_AR9X) { return getSambaArgs(QString("send_file {Flash} \"") + filename + "\" 0x400000 0\n" + "FLASH::ScriptGPNMV 2\n"); } else { @@ -169,14 +169,14 @@ QStringList getWriteFirmwareArgs(const QString & filename) QStringList getReadFirmwareArgs(const QString & filename) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (IS_STM32(board)) { return getDfuArgs("-U", filename); } - else if (board == BOARD_SKY9X) { + else if (board == Board::BOARD_SKY9X) { return getSambaArgs(QString("receive_file {Flash} \"") + filename + "\" 0x400000 0x40000 0\n"); } - else if (board == BOARD_9XRPRO) { + else if (board == Board::BOARD_9XRPRO) { return getSambaArgs(QString("receive_file {Flash} \"") + filename + "\" 0x400000 0x80000 0\n"); } else { @@ -309,7 +309,7 @@ bool writeFirmware(const QString & filename, ProgressWidget * progress) bool readEeprom(const QString & filename, ProgressWidget * progress) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); QFile file(filename); if (file.exists() && !file.remove()) { @@ -373,7 +373,7 @@ bool readEeprom(const QString & filename, ProgressWidget * progress) bool writeEeprom(const QString & filename, ProgressWidget * progress) { - BoardEnum board = getCurrentBoard(); + Board::Type board = getCurrentBoard(); if (IS_ARM(board)) { QString path = findMassstoragePath("EEPROM.BIN"); diff --git a/companion/src/simulation/simulateduiwidget.h b/companion/src/simulation/simulateduiwidget.h index d957c3081..f9f267ca8 100644 --- a/companion/src/simulation/simulateduiwidget.h +++ b/companion/src/simulation/simulateduiwidget.h @@ -84,7 +84,7 @@ class SimulatedUIWidget : public QWidget RadioUiAction * m_scrollDnAction; RadioUiAction * m_rotEncClickAction; RadioUiAction * m_screenshotAction; - BoardEnum m_board; + Board::Type m_board; unsigned int m_backLight; bool m_lightOn; int m_beepShow; diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 43e4b7d67..0ea74a6fe 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -204,15 +204,15 @@ void SimulatorDialog::setupUi() setWindowTitle(windowName); switch(m_board) { - case BOARD_TARANIS_X7 : + case Board::BOARD_TARANIS_X7 : radioUiWidget = new SimulatedUIWidgetX7(simulator, this); break; - case BOARD_TARANIS_X9D : - case BOARD_TARANIS_X9DP : - case BOARD_TARANIS_X9E : + case Board::BOARD_TARANIS_X9D : + case Board::BOARD_TARANIS_X9DP : + case Board::BOARD_TARANIS_X9E : radioUiWidget = new SimulatedUIWidgetX9(simulator, this); break; - case BOARD_HORUS : + case Board::BOARD_HORUS : radioUiWidget = new SimulatedUIWidgetX12(simulator, this); break; default: @@ -312,7 +312,7 @@ void SimulatorDialog::setupRadioWidgets() { int i, midpos, aIdx; QString wname; - BoardEnum board = firmware->getBoard(); + Board::Type board = firmware->getBoard(); // First clear out any existing widgets. if (switches.size()) { @@ -334,17 +334,17 @@ void SimulatorDialog::setupRadioWidgets() // Now set up new widgets. // switches - SwitchInfo switchInfo; + Board::SwitchInfo switchInfo; // FIXME : CPN_MAX_SWITCHES == 32 but GeneralSettings::switchConfig[18] !! for (i = 0; i < firmware->getCapability(Capability(Switches)) && i < 18 /*CPN_MAX_SWITCHES*/; ++i) { - if (radioSettings.switchConfig[i] == SWITCH_NONE) + if (radioSettings.switchConfig[i] == Board::SWITCH_NOT_AVAILABLE) continue; if ((wname = QString(radioSettings.switchName[i])).isEmpty()) { switchInfo = getSwitchInfo(board, i); wname = QString(switchInfo.name); } - RadioSwitchWidget * sw = new RadioSwitchWidget(SwitchConfig(radioSettings.switchConfig[i]), wname, 0, ui->radioWidgetsHT); + RadioSwitchWidget * sw = new RadioSwitchWidget(Board::SwitchType(radioSettings.switchConfig[i]), wname, 0, ui->radioWidgetsHT); sw->setIndex(i); ui->radioWidgetsHTLayout->addWidget(sw); switches.append(sw); @@ -361,7 +361,7 @@ void SimulatorDialog::setupRadioWidgets() if ((wname = QString(radioSettings.potName[i])).isEmpty()) wname = firmware->getAnalogInputName(4 + aIdx + i); - RadioKnobWidget * pot = new RadioKnobWidget(PotConfig(radioSettings.potConfig[i]), wname, 0, ui->radioWidgetsHT); + RadioKnobWidget * pot = new RadioKnobWidget(Board::PotType(radioSettings.potConfig[i]), wname, 0, ui->radioWidgetsHT); pot->setIndex(aIdx + i); // FIXME : total hack here -- this needs to follow the exception in radio/src/mixer.cpp:evalInputs() if (i == 0 && IS_TARANIS(board) && !IS_TARANIS_X7(board)) diff --git a/companion/src/simulation/simulatordialog.h b/companion/src/simulation/simulatordialog.h index 3c9ff35f1..af0ecc786 100644 --- a/companion/src/simulation/simulatordialog.h +++ b/companion/src/simulation/simulatordialog.h @@ -126,7 +126,7 @@ class SimulatorDialog : public QDialog QString sdCardPath; QString radioDataPath; QByteArray eepromData; - BoardEnum m_board; + Board::Type m_board; quint8 flags; int radioProfileId; int lastPhase; diff --git a/companion/src/simulation/simulatorinterface.h b/companion/src/simulation/simulatorinterface.h index 9f84557ec..d9c35d832 100644 --- a/companion/src/simulation/simulatorinterface.h +++ b/companion/src/simulation/simulatorinterface.h @@ -115,7 +115,7 @@ class SimulatorFactory { virtual QString name() = 0; - virtual BoardEnum type() = 0; + virtual Board::Type type() = 0; virtual SimulatorInterface *create() = 0; }; diff --git a/companion/src/simulation/widgets/radioknobwidget.h b/companion/src/simulation/widgets/radioknobwidget.h index b7637dc0a..2343c8c9f 100644 --- a/companion/src/simulation/widgets/radioknobwidget.h +++ b/companion/src/simulation/widgets/radioknobwidget.h @@ -35,13 +35,13 @@ class RadioKnobWidget : public RadioWidget public: - explicit RadioKnobWidget(PotConfig type = POT_WITH_DETENT, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : + explicit RadioKnobWidget(Board::PotType type = Board::POT_WITH_DETENT, QWidget * parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : RadioWidget(parent, f), m_potType(type) { init(); } - explicit RadioKnobWidget(PotConfig type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : + explicit RadioKnobWidget(Board::PotType type, const QString & labelText, int value = 0, QWidget * parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : RadioWidget(labelText, value, parent, f), m_potType(type) { @@ -63,7 +63,7 @@ class RadioKnobWidget : public RadioWidget private: - PotConfig m_potType; + Board::PotType m_potType; class KnobWidget : public QDial @@ -72,10 +72,10 @@ class RadioKnobWidget : public RadioWidget public: - explicit KnobWidget(PotConfig type, QWidget * parent = 0): + explicit KnobWidget(Board::PotType type, QWidget * parent = 0): QDial(parent), m_type(type), - m_positions(type == POT_MULTIPOS_SWITCH ? 5 : 0) + m_positions(type == Board::POT_MULTIPOS_SWITCH ? 5 : 0) { setToolTip(tr("Right-double-click to reset to center.")); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -114,7 +114,7 @@ class RadioKnobWidget : public RadioWidget QDial::mousePressEvent(event); } - PotConfig m_type; + Board::PotType m_type; quint8 m_positions; }; diff --git a/companion/src/simulation/widgets/radioswitchwidget.h b/companion/src/simulation/widgets/radioswitchwidget.h index 929bd1eb5..2aee3a435 100644 --- a/companion/src/simulation/widgets/radioswitchwidget.h +++ b/companion/src/simulation/widgets/radioswitchwidget.h @@ -33,13 +33,13 @@ class RadioSwitchWidget : public RadioWidget public: - explicit RadioSwitchWidget(SwitchConfig type = SWITCH_3POS, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : + explicit RadioSwitchWidget(Board::SwitchType type = Board::SWITCH_3POS, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : RadioWidget(parent, f), switchConfig(type) { init(); } - explicit RadioSwitchWidget(SwitchConfig type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : + explicit RadioSwitchWidget(Board::SwitchType type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : RadioWidget(labelText, value, parent, f), switchConfig(type) { @@ -58,7 +58,7 @@ class RadioSwitchWidget : public RadioWidget sl->setInvertedControls(true); sl->setTickPosition(QSlider::TicksBothSides); sl->setPageStep(1); - sl->setMinimum((switchConfig == SWITCH_3POS ? -1 : 0)); + sl->setMinimum((switchConfig == Board::SWITCH_3POS ? -1 : 0)); sl->setMaximum(1); sl->setTickInterval(1); sl->setValue(m_value); @@ -70,7 +70,7 @@ class RadioSwitchWidget : public RadioWidget } private: - SwitchConfig switchConfig; + Board::SwitchType switchConfig; }; diff --git a/companion/src/storage/rlefile.cpp b/companion/src/storage/rlefile.cpp index 2c1c4b649..c19723d2a 100644 --- a/companion/src/storage/rlefile.cpp +++ b/companion/src/storage/rlefile.cpp @@ -44,7 +44,7 @@ eepromFatHeader(NULL) #define EEPROM_MAX_FILES (EEPROM_MAX_ZONES - 1) #define FIRST_FILE_AVAILABLE (1+MAX_MODELS) -void RleFile::EeFsCreate(uint8_t *eeprom, int size, BoardEnum board, unsigned int version) +void RleFile::EeFsCreate(uint8_t *eeprom, int size, Board::Type board, unsigned int version) { this->eeprom = eeprom; this->eeprom_size = size; @@ -86,7 +86,7 @@ void RleFile::EeFsCreate(uint8_t *eeprom, int size, BoardEnum board, unsigned in } else { eeFs = (EeFs *)eeprom; - eeFsVersion = (IS_2560(board) || board==BOARD_M128) ? 5 : 4; + eeFsVersion = (IS_2560(board) || board==Board::BOARD_M128) ? 5 : 4; eeFsBlockSize = 16; eeFsLinkSize = 1; @@ -136,7 +136,7 @@ bool RleFile::searchFat() return (eepromFatHeader != NULL); } -bool RleFile::EeFsOpen(uint8_t *eeprom, int size, BoardEnum board) +bool RleFile::EeFsOpen(uint8_t *eeprom, int size, Board::Type board) { this->eeprom = eeprom; this->eeprom_size = size; diff --git a/companion/src/storage/rlefile.h b/companion/src/storage/rlefile.h index 6b5d01551..803b3ad00 100644 --- a/companion/src/storage/rlefile.h +++ b/companion/src/storage/rlefile.h @@ -90,7 +90,7 @@ class RleFile unsigned int m_err; //error reasons uint16_t m_size; - BoardEnum board; + Board::Type board; unsigned int version; uint8_t *eeprom; unsigned int eeprom_size; @@ -125,9 +125,9 @@ public: RleFile(); - void EeFsCreate(uint8_t *eeprom, int size, BoardEnum board, unsigned int version); + void EeFsCreate(uint8_t *eeprom, int size, Board::Type board, unsigned int version); - bool EeFsOpen(uint8_t *eeprom, int size, BoardEnum board); + bool EeFsOpen(uint8_t *eeprom, int size, Board::Type board); ///open file for reading, no close necessary ///for writing use writeRlc() or create() diff --git a/companion/src/storage/storage.h b/companion/src/storage/storage.h index d6f3bc64f..f48ae8b0a 100644 --- a/companion/src/storage/storage.h +++ b/companion/src/storage/storage.h @@ -45,7 +45,7 @@ class StorageFormat StorageFormat(const QString & filename, uint8_t version=0): filename(filename), version(version), - board(BOARD_UNKNOWN) + board(Board::BOARD_UNKNOWN) { } @@ -62,7 +62,7 @@ class StorageFormat virtual QString name() = 0; - virtual BoardEnum getBoard() { + virtual Board::Type getBoard() { return board; } @@ -83,7 +83,7 @@ class StorageFormat uint8_t version; QString _error; QString _warning; - BoardEnum board; + Board::Type board; }; class StorageFactory diff --git a/companion/src/storage/xmlinterface.cpp b/companion/src/storage/xmlinterface.cpp index 225e23ca8..cface43c0 100644 --- a/companion/src/storage/xmlinterface.cpp +++ b/companion/src/storage/xmlinterface.cpp @@ -157,7 +157,7 @@ void saveModel(ModelData & m, model & xm) phases::phase_sequence & phases_sequence (xphases.phase()); for (int i=0; i= 0) diff --git a/companion/src/wizarddata.cpp b/companion/src/wizarddata.cpp index 9002402dd..0b5f4c39e 100644 --- a/companion/src/wizarddata.cpp +++ b/companion/src/wizarddata.cpp @@ -53,7 +53,7 @@ void WizMix::maxMixSwitch(char *name, MixData &mix, int channel, int sw, int wei mix.name[MIXDATA_NAME_LEN] = '\0'; mix.destCh = channel; mix.srcRaw = RawSource(SOURCE_TYPE_MAX); - mix.swtch = RawSwitch(SWITCH_TYPE_SWITCH, sw); + mix.swtch = RawSwitch(SWITCH_TYPE_SWITCH, sw); mix.weight = weight; } diff --git a/radio/src/targets/simu/opentxsimulator.cpp b/radio/src/targets/simu/opentxsimulator.cpp index f02981916..7691545dc 100644 --- a/radio/src/targets/simu/opentxsimulator.cpp +++ b/radio/src/targets/simu/opentxsimulator.cpp @@ -254,18 +254,18 @@ class OpenTxSimulatorFactory: public SimulatorFactory return QString(SIMULATOR_FLAVOUR); } - virtual BoardEnum type() + virtual Board::Type type() { #if defined(PCBHORUS) - return BOARD_HORUS; + return Board::BOARD_HORUS; #elif defined(PCBFLAMENCO) - return BOARD_FLAMENCO; + return Board::BOARD_FLAMENCO; #elif defined(PCBX7) - return BOARD_TARANIS_X7; + return Board::BOARD_TARANIS_X7; #elif defined(PCBTARANIS) - return BOARD_TARANIS_X9D; + return Board::BOARD_TARANIS_X9D; #else - return BOARD_STOCK; + return Board::BOARD_STOCK; #endif } };