From b66096107f39df3867f9b685ded139baad790952 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 11 Dec 2014 20:07:43 +0100 Subject: [PATCH] MEGA2560 board added to Companion --- .../firmwares/gruvin9x/gruvin9xinterface.cpp | 3 +- .../src/firmwares/opentx/opentxinterface.cpp | 28 +++++++++++++------ companion/src/modeledit/setup.cpp | 6 ++-- radio/src/myeeprom.h | 6 ++-- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp index 2db16ebcc..25b79f7bb 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp @@ -53,7 +53,8 @@ const int Gruvin9xInterface::getEEpromSize() return EESIZE_STOCK*2; } return EESIZE_STOCK; - } else { + } + else { return EESIZE_GRUVIN9X; } } diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index c145fa60e..1d216f495 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -62,6 +62,8 @@ const char * OpenTxEepromInterface::getName() return "OpenTX for 9X board"; case BOARD_M128: return "OpenTX for M128 / 9X board"; + case BOARD_MEGA2560: + return "OpenTX for MEGA2560 board"; case BOARD_GRUVIN9X: return "OpenTX for Gruvin9x board / 9X"; case BOARD_TARANIS: @@ -86,6 +88,7 @@ const int OpenTxEepromInterface::getEEpromSize() return EESIZE_STOCK; case BOARD_M128: return EESIZE_M128; + case BOARD_MEGA2560: case BOARD_GRUVIN9X: return EESIZE_GRUVIN9X; case BOARD_SKY9X: @@ -107,7 +110,7 @@ const int OpenTxEepromInterface::getMaxModels() return 60; else if (board == BOARD_M128) return 30; - else if (board == BOARD_GRUVIN9X) + else if (IS_2560(board)) return 30; else return 16; @@ -530,7 +533,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case FlightModes: if (IS_ARM(board)) return 9; - else if (board==BOARD_GRUVIN9X) + else if (IS_2560(board)) return 6; else return 5; @@ -559,7 +562,7 @@ int OpenTxFirmware::getCapability(const Capability capability) return 1; case GvarsAreNamed: case GvarsFlightModes: - return ((IS_ARM(board) || board==BOARD_GRUVIN9X) ? 1 : 0); + return ((IS_ARM(board) || IS_2560(board)) ? 1 : 0); case Mixes: return (IS_TARANIS(board) ? 64 : (IS_ARM(board) ? 60 : 32)); case OffsetWeight: @@ -569,7 +572,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case TimersName: return (IS_TARANIS(board) ? 8 : (IS_ARM(board) ? 3 : 0)); case PermTimers: - if (board == BOARD_GRUVIN9X || IS_ARM(board)) + if (IS_2560(board) || IS_ARM(board)) return 1; else return 0; @@ -584,7 +587,7 @@ int OpenTxFirmware::getCapability(const Capability capability) return 64; else if (IS_ARM(board)) return 60; - else if (board==BOARD_GRUVIN9X||board==BOARD_M128) + else if (IS_2560(board) || board==BOARD_M128) return 24; else return 16; @@ -622,7 +625,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case SoundPitch: return 1; case Haptic: - return (board == BOARD_GRUVIN9X || IS_SKY9X(board) || IS_TARANIS_PLUS(board) || id.contains("haptic")); + return (IS_2560(board) || IS_SKY9X(board) || IS_TARANIS_PLUS(board) || id.contains("haptic")); case ModelTrainerEnable: if (IS_ARM(board)) return 1; @@ -653,7 +656,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case HasCvNames: return (IS_TARANIS(board) ? 1 : 0); case Telemetry: - if (board == BOARD_GRUVIN9X || IS_ARM(board) || id.contains("frsky") || id.contains("telemetrez")) + if (IS_2560(board) || IS_ARM(board) || id.contains("frsky") || id.contains("telemetrez")) return TM_HASTELEMETRY|TM_HASOFFSET|TM_HASWSHH; else return 0; @@ -682,7 +685,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case HasVario: return 1; case HasVarioSink: - return ((board == BOARD_GRUVIN9X || IS_ARM(board)) ? true : false); + return ((IS_2560(board) || IS_ARM(board)) ? true : false); case HasFailsafe: return (IS_ARM(board) ? 32 : 0); case NumModules: @@ -704,7 +707,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case CSFunc: return 18; case HasSDLogs: - return ((board == BOARD_GRUVIN9X || IS_ARM(board)) ? true : false); + return ((IS_2560(board) || IS_ARM(board)) ? true : false); case LCDWidth: return (IS_TARANIS(board) ? 212 : 128) ; case GetThrSwitch: @@ -1012,6 +1015,7 @@ QString OpenTxFirmware::getFirmwareUrl() case BOARD_STOCK: case BOARD_M128: case BOARD_GRUVIN9X: + case BOARD_MEGA2560: url.append(QString("/getfw.php?fw=%1.hex").arg(id)); break; case BOARD_SKY9X: @@ -1050,6 +1054,7 @@ SimulatorInterface * OpenTxFirmware::getSimulator() case BOARD_M128: return new OpenTxM128Simulator(); case BOARD_GRUVIN9X: + case BOARD_MEGA2560: return new Open9xGruvin9xSimulator(); case BOARD_SKY9X: case BOARD_9XRPRO: @@ -1234,6 +1239,11 @@ void registerOpenTxFirmwares() addOpenTxCommonOptions(openTx); firmwares.push_back(openTx); + /* MEGA2560 board */ + openTx = new OpenTxFirmware("opentx-mega2560", QObject::tr("OpenTX for MEGA2560 board"), BOARD_MEGA2560); + addOpenTxCommonOptions(openTx); + firmwares.push_back(openTx); + /* Sky9x board */ openTx = new OpenTxFirmware("opentx-sky9x", QObject::tr("OpenTX for Sky9x board / 9X"), BOARD_SKY9X); openTx->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support")); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 53eef2007..c28effe7b 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -694,6 +694,8 @@ void SetupPanel::updateStartupSwitches() unsigned int switchStates = model->switchWarningStates; for (int i=0; igetCapability(Switches); i++) { + if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1) + continue; QSlider * slider = startupSwitchesSliders[i]; QCheckBox * cb = startupSwitchesCheckboxes[i]; bool enabled = !(model->switchWarningEnable & (1 << i)); @@ -704,10 +706,6 @@ void SetupPanel::updateStartupSwitches() switchStates >>= 2; } else { - if (i == firmware->getCapability(Switches)-1) { - // Trainer switch, no switch warning - continue; - } slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1); switchStates >>= (i==0 ? 2 : 1); } diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index a88207f7d..bd1f18778 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1680,7 +1680,7 @@ enum SwitchSources { #if defined(PCBSKY9X) SWSRC_REa, -#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) +#elif defined(CPUM2560) SWSRC_REa, SWSRC_REb, #endif @@ -1760,7 +1760,7 @@ enum MixSources { #if defined(PCBSKY9X) MIXSRC_REa, MIXSRC_LAST_ROTARY_ENCODER = MIXSRC_REa, -#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) +#elif defined(CPUM2560) MIXSRC_REa, MIXSRC_REb, #if ROTARY_ENCODERS > 2 @@ -1997,7 +1997,7 @@ enum FailsafeModes { #define TELEMETRY_DATA #endif -#if defined(CPUARM) || defined(PCBGRUVIN9X) || defined(PCBMEGA2560) +#if defined(CPUARM) || defined(CPUM2560) #define BeepANACenter uint16_t #else #define BeepANACenter uint8_t