diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b0040f5d0..20ae50cac 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -4,17 +4,17 @@ #include "opentxeeprom.h" #include -#define IS_DBLEEPROM(board, version) ((board==BOARD_GRUVIN9X || board==BOARD_M128) && version >= 213) +#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) ((board==BOARD_GRUVIN9X && version >= 213) || (board==BOARD_M128 && version >= 213 && version <= 214)) +#define IS_DBLRAM(board, version) ((IS_2560(board) && version >= 213) || (board==BOARD_M128 && version >= 213 && version <= 214)) -#define HAS_PERSISTENT_TIMERS(board) (IS_ARM(board) || board == BOARD_GRUVIN9X) +#define HAS_PERSISTENT_TIMERS(board) (IS_ARM(board) || IS_2560(board)) #define HAS_LARGE_LCD(board) IS_TARANIS(board) #define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256) #define MAX_POTS(board) (IS_TARANIS(board) ? 5 : 3) #define MAX_SWITCHES(board, version) (version >= 217 ? (IS_TARANIS(board) ? 8+6 : 7) : (IS_TARANIS(board) ? 8 : 7)) #define MAX_SWITCHES_POSITION(board, version) (IS_TARANIS(board) ? (version >= 217 ? 22+12 : 22) : 9) -#define MAX_ROTARY_ENCODERS(board) (board==BOARD_GRUVIN9X ? 2 : (IS_SKY9X(board) ? 1 : 0)) +#define MAX_ROTARY_ENCODERS(board) (IS_2560(board) ? 2 : (IS_SKY9X(board) ? 1 : 0)) #define MAX_FLIGHT_MODES(board, version) (IS_ARM(board) ? 9 : (IS_DBLRAM(board, version) ? 6 : 5)) #define MAX_TIMERS(board, version) ((IS_ARM(board) && version >= 217) ? 3 : 2) #define MAX_MIXERS(board, version) (IS_ARM(board) ? 64 : 32) @@ -763,7 +763,7 @@ class FlightModeField: public TransformedField { index(index), board(board), version(version), - rotencCount(IS_ARM(board) ? 1 : (board == BOARD_GRUVIN9X ? 2 : 0)) + rotencCount(IS_ARM(board) ? 1 : (IS_2560(board) ? 2 : 0)) { if (board == BOARD_STOCK || (board==BOARD_M128 && version>=215)) { // On stock we use 10bits per trim @@ -1908,7 +1908,7 @@ class CustomFunctionsConversionTable: public ConversionTable { } addConversion(FuncVario, val++); addConversion(FuncPlayHaptic, val++); - if (board == BOARD_GRUVIN9X || IS_ARM(board) ) + if (IS_2560(board) || IS_ARM(board) ) addConversion(FuncLogs, val++); addConversion(FuncBacklight, val++); if (IS_TARANIS(board)) @@ -1924,7 +1924,7 @@ class CustomFunctionsConversionTable: public ConversionTable { if (version >= 213 && !IS_ARM(board)) addConversion(FuncPlayBoth, val++); addConversion(FuncPlayValue, val++); - if (board == BOARD_GRUVIN9X || IS_ARM(board) ) + if (IS_2560(board) || IS_ARM(board) ) addConversion(FuncLogs, val++); if (IS_ARM(board)) addConversion(FuncVolume, val++); @@ -2207,7 +2207,15 @@ class AvrCustomFunctionField: public TransformedField { _union_param(0), _active(0) { - if (version >= 216) { + if (version >= 217 && IS_2560(board)) { + internalField.Append(new SwitchField<8>(fn.swtch, board, version)); + internalField.Append(new ConversionField< UnsignedField<8> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); + internalField.Append(new UnsignedField<2>(fn.adjustMode)); + internalField.Append(new UnsignedField<4>(_union_param)); + internalField.Append(new UnsignedField<1>(_active)); + internalField.Append(new SpareBitsField<1>()); + } + else if (version >= 216) { internalField.Append(new SwitchField<6>(fn.swtch, board, version)); internalField.Append(new ConversionField< UnsignedField<4> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); internalField.Append(new UnsignedField<5>(_union_param)); @@ -2242,7 +2250,14 @@ class AvrCustomFunctionField: public TransformedField { _union_param = fn.func - FuncTrainer; } else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { - if (version >= 216) { + if (version >= 217 && IS_2560(board)) { + _union_param = (fn.func - FuncAdjustGV1); + if (fn.adjustMode == 1) + sourcesConversionTable->exportValue(fn.param, (int &)_param); + else if (fn.adjustMode == 2) + _param = RawSource(fn.param).index; + } + else if (version >= 216) { _union_param = fn.adjustMode; _union_param += (fn.func - FuncAdjustGV1) << 2; if (fn.adjustMode == 1) @@ -2303,7 +2318,14 @@ class AvrCustomFunctionField: public TransformedField { fn.func = AssignFunc(fn.func + _union_param); } else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { - if (version >= 216) { + if (version >= 217 && IS_2560(board)) { + fn.func = AssignFunc(fn.func + _union_param); + if (fn.adjustMode == 1) + sourcesConversionTable->importValue(_param, (int &)fn.param); + else if (fn.adjustMode == 2) + fn.param = RawSource(SOURCE_TYPE_GVAR, _param).toValue(); + } + else if (version >= 216) { fn.func = AssignFunc(fn.func + (_union_param >> 2)); fn.adjustMode = (_union_param & 0x03); if (fn.adjustMode == 1) @@ -2847,7 +2869,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].ppmDelay, exportPpmDelay, importPpmDelay)); } - if (IS_ARM(board) || board==BOARD_GRUVIN9X) + if (IS_ARM(board) || IS_2560(board)) internalField.Append(new UnsignedField<16>(modelData.beepANACenter)); else internalField.Append(new UnsignedField<8>(modelData.beepANACenter)); diff --git a/radio/src/Makefile b/radio/src/Makefile index e01540b52..51466a8d1 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -1297,19 +1297,6 @@ ifeq ($(IRPROTOS), YES) CPPDEFS += -DIRPROTOS endif -ifeq ($(3POS), POT1) - CPPDEFS += -DEXTRA_3POS=1 - # EEPROM_VARIANT += ${3POS_VARIANT} -endif -ifeq ($(3POS), POT2) - CPPDEFS += -DEXTRA_3POS=2 - # EEPROM_VARIANT += ${3POS_VARIANT} -endif -ifeq ($(3POS), POT3) - CPPDEFS += -DEXTRA_3POS=3 - # EEPROM_VARIANT += ${3POS_VARIANT} -endif - #---------------- Compiler Options C++ ---------------- # -g*: generate debugging information # -O*: optimization level diff --git a/radio/src/gui/9X/lcd.cpp b/radio/src/gui/9X/lcd.cpp index 1e32de5b6..41654e39d 100755 --- a/radio/src/gui/9X/lcd.cpp +++ b/radio/src/gui/9X/lcd.cpp @@ -665,7 +665,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att) if (idx < MIXSRC_THR) lcd_putsiAtt(x, y, STR_VSRCRAW, idx, att); else if (idx < MIXSRC_SW1) - putsSwitches(x, y, idx-MIXSRC_THR+1+3*(1/*+EXTRA_3POS*/), att); + putsSwitches(x, y, idx-MIXSRC_THR+1+3*(1), att); else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) putsSwitches(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att); else if (idx < MIXSRC_CH1) diff --git a/radio/src/keys.h b/radio/src/keys.h index 3d910a229..59bd20bf3 100644 --- a/radio/src/keys.h +++ b/radio/src/keys.h @@ -150,12 +150,6 @@ enum EnumKeys { SW_ID0=SW_BASE, SW_ID1, SW_ID2, -#if defined(EXTRA_3POS) - SW_ID3, - SW_ID4, - SW_ID5, -#endif - SW_THR, SW_RUD, SW_ELE, diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index d74682ad2..abac6e89a 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -313,10 +313,6 @@ getvalue_t getValue(mixsrc_t i) #else else if (i==MIXSRC_3POS) return (getSwitch(SW_ID0-SW_BASE+1) ? -1024 : (getSwitch(SW_ID1-SW_BASE+1) ? 0 : 1024)); // don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning -#if defined(EXTRA_3POS) - else if (i==MIXSRC_3POS2) return (getSwitch(SW_ID3-SW_BASE+1) ? -1024 : (getSwitch(SW_ID4-SW_BASE+1) ? 0 : 1024)); - // don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning -#endif else if (i +RESX/2) - v = +RESX; - else - v = 0; - } -#endif - BeepANACenter mask = (BeepANACenter)1 << ch; if (i < NUM_STICKS+NUM_POTS) { diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 91c594b28..a7ad88a9c 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -82,7 +82,7 @@ #define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) #endif -#if defined (CPUARM) +#if defined(CPUARM) #define ARM_FIELD(x) x; #define AVR_FIELD(x) #else @@ -602,6 +602,28 @@ PACK(typedef struct { #define CFN_PARAM(p) ((p)->all.val) #define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0) #define CFN_GVAR_CST_MAX GVAR_LIMIT +#elif defined(CPUM2560) +PACK(typedef struct { + int8_t swtch; + uint8_t func; + uint8_t mode:2; + uint8_t param:4; + uint8_t active:1; + uint8_t spare:1; + uint8_t value; +}) CustomFunctionData; +#define CFN_SWITCH(p) ((p)->swtch) +#define CFN_FUNC(p) ((p)->func) +#define CFN_ACTIVE(p) ((p)->active) +#define CFN_CH_INDEX(p) ((p)->param) +#define CFN_TIMER_INDEX(p) ((p)->param) +#define CFN_GVAR_INDEX(p) ((p)->param) +#define CFN_PLAY_REPEAT(p) ((p)->param) +#define CFN_PLAY_REPEAT_MUL 10 +#define CFN_GVAR_MODE(p) ((p)->mode) +#define CFN_PARAM(p) ((p)->value) +#define CFN_RESET(p) ((p)->active = 0, CFN_PARAM(p) = 0) +#define CFN_GVAR_CST_MAX 125 #else PACK(typedef struct { PACK(union { @@ -1674,11 +1696,6 @@ enum SwitchSources { SWSRC_ID0 = SWSRC_FIRST_SWITCH, SWSRC_ID1, SWSRC_ID2, -#if defined(EXTRA_3POS) - SWSRC_ID3, - SWSRC_ID4, - SWSRC_ID5, -#endif SWSRC_THR, SWSRC_RUD, SWSRC_ELE, diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.cpp b/radio/src/targets/gruvin9x/board_gruvin9x.cpp index 8a6e0927d..460753309 100644 --- a/radio/src/targets/gruvin9x/board_gruvin9x.cpp +++ b/radio/src/targets/gruvin9x/board_gruvin9x.cpp @@ -222,20 +222,6 @@ bool switchState(EnumKeys enuk) result = !(PINB & (1< 0); - break; -#endif - case SW_GEA: result = PING & (1< 0); - break; -#endif */ - case SW_GEA: result = !(PING & (1< 0); - break; -#endif - case SW_GEA: xxx = c & 0x00010000; // SW_GEAR PC16 break; diff --git a/radio/src/targets/stock/board_stock.cpp b/radio/src/targets/stock/board_stock.cpp index 6ff848a10..5483b4014 100644 --- a/radio/src/targets/stock/board_stock.cpp +++ b/radio/src/targets/stock/board_stock.cpp @@ -208,20 +208,6 @@ bool switchState(EnumKeys enuk) result = !(PINE & (1< 0); - break; -#endif - case SW_GEA: result = PINE & (1<