diff --git a/src/Makefile b/src/Makefile index 61257a8d8..8ac737d1f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -298,7 +298,8 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128)) MCU = atmega128 OPT = 2 SDCARD = NO - CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM128 -DEEPROM_VARIANT=0x8000 + EEPROM_VARIANT += ${M128_VARIANT} + CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM128 -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) EXTRAINCDIRS = stock BOARDSRC = stock/board_stock.cpp EXTRABOARDSRC = stock/lcd_driver.cpp @@ -592,9 +593,10 @@ CPPDEFS += -DTRANSLATIONS_$(TRANSLATIONS) # TTS language CPPDEFS += -DTTS_$(TTS) -GVARS_VARIANT = +1 -FRSKY_VARIANT = +2 -3POS_VARIANT = +4 +GVARS_VARIANT = +0x0001 +FRSKY_VARIANT = +0x0002 +3POS_VARIANT = +0x0004 +M128_VARIANT = +0x8000 EEPROM_VARIANT = 0 ifeq ($(UNITS), IMPERIAL) diff --git a/src/eeprom_rlc.cpp b/src/eeprom_rlc.cpp index 3f3163deb..4091b1959 100644 --- a/src/eeprom_rlc.cpp +++ b/src/eeprom_rlc.cpp @@ -813,7 +813,7 @@ bool eeLoadGeneral() if (theFile.readRlc((uint8_t*)&g_eeGeneral, 1) == 1 && g_eeGeneral.version == EEPROM_VER) { theFile.openRlc(FILE_GENERAL); if (theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral)) <= sizeof(EEGeneral)) { -#if defined(CPUM64) +#if defined(PCBSTD) if (g_eeGeneral.variant == EEPROM_VARIANT && g_eeGeneral.chkSum == evalChkSum()) { return true; } diff --git a/src/lcd.cpp b/src/lcd.cpp index 980042094..5b7862b2e 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -813,7 +813,7 @@ void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att) putsStrIdx(x, y, STR_PPM, idx-MIXSRC_PPM1+1, att); else if (idx <= MIXSRC_LAST_CH) putsStrIdx(x, y, STR_CH, idx-MIXSRC_CH1+1, att); -#if defined(GVARS) || !defined(CPUM64) +#if defined(GVARS) || !defined(PCBSTD) else if (idx <= MIXSRC_LAST_GVAR) putsStrIdx(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att); #endif @@ -860,7 +860,7 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) } #endif -#if !defined(CPUM64) +#if !defined(PCBSTD) else if (idx >= SWSRC_TRAINER_SHORT) { idx -= SWSRC_TRAINER_SHORT; lcd_putcAtt(x+3*FW, y, (idx & 1) ? CHR_LONG : CHR_SHORT, att); diff --git a/src/menu_model.cpp b/src/menu_model.cpp index 798696594..5e63c477a 100644 --- a/src/menu_model.cpp +++ b/src/menu_model.cpp @@ -1447,7 +1447,7 @@ enum menuModelPhaseItems { IF_ROTARY_ENCODERS(ITEM_MODEL_PHASE_ROTARY_ENCODERS) ITEM_MODEL_PHASE_FADE_IN, ITEM_MODEL_PHASE_FADE_OUT, -#if defined(GVARS) && !defined(CPUM64) +#if defined(GVARS) && !defined(PCBSTD) ITEM_MODEL_PHASE_GVARS_LABEL, ITEM_MODEL_PHASE_GV1, ITEM_MODEL_PHASE_GV2, @@ -1463,7 +1463,7 @@ void menuModelPhaseOne(uint8_t event) PhaseData *phase = phaseaddress(s_currIdx); putsFlightPhase(13*FW, 0, s_currIdx+1, (getFlightPhase()==s_currIdx ? BOLD : 0)); -#if defined(GVARS) && !defined(CPUM64) +#if defined(GVARS) && !defined(PCBSTD) static const pm_uint8_t mstate_tab_phase1[] PROGMEM = {0, 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; static const pm_uint8_t mstate_tab_others[] PROGMEM = {0, 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; @@ -1480,7 +1480,7 @@ void menuModelPhaseOne(uint8_t event) int8_t sub = m_posVert; int8_t editMode = s_editMode; -#if defined(GVARS) && !defined(CPUM64) +#if defined(GVARS) && !defined(PCBSTD) if (s_currIdx == 0 && sub>=ITEM_MODEL_PHASE_SWITCH) sub += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH; for (uint8_t k=0; kfadeOut = EDIT_DELAY(0, y, event, attr, STR_FADEOUT, phase->fadeOut); break; -#if defined(GVARS) && !defined(CPUM64) +#if defined(GVARS) && !defined(PCBSTD) case ITEM_MODEL_PHASE_GVARS_LABEL: lcd_putsLeft(y, STR_GLOBAL_VARS); break; @@ -3050,7 +3050,7 @@ void menuModelLimits(uint8_t event) void menuModelCurvesAll(uint8_t event) { -#if defined(GVARS) && defined(CPUM64) +#if defined(GVARS) && defined(PCBSTD) SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES+MAX_GVARS); #else SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES); @@ -3077,7 +3077,7 @@ void menuModelCurvesAll(uint8_t event) uint8_t y = 1 + FH + i*FH; uint8_t k = i + s_pgOfs; uint8_t attr = (sub == k ? INVERS : 0); -#if defined(GVARS) && defined(CPUM64) +#if defined(GVARS) && defined(PCBSTD) if (k < MAX_CURVES) { putsStrIdx(0, y, STR_CV, k+1, attr); } diff --git a/src/myeeprom.h b/src/myeeprom.h index 67861d92c..e8645f5e1 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -52,35 +52,36 @@ #define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 ) #if defined(PCBTARANIS) -#define EEPROM_VER 214 + #define EEPROM_VER 214 #elif defined(PCBSKY9X) -#define EEPROM_VER 214 -#elif defined(PCBGRUVIN9X) || defined(CPUM128) -#define EEPROM_VER 214 + #define EEPROM_VER 214 +#elif defined(PCBGRUVIN9X) + #define EEPROM_VER 214 +#elif defined(CPUM128) + #define EEPROM_VER 215 #else -#define EEPROM_VER 213 + #define EEPROM_VER 213 #endif #ifndef PACK #define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) #endif - typedef int16_t gvar_t; -#if !defined(CPUM64) +#if !defined(PCBSTD) typedef char gvar_name_t[6]; #define GVAR_MAX 1024 #endif #define RESERVE_RANGE_FOR_GVARS 10 // even we do not spend space in EEPROM for 10 GVARS, we reserve the space inside the range of values, like offset, weight, etc. -#if defined(CPUM64) && defined(GVARS) +#if defined(PCBSTD) && defined(GVARS) #define MAX_GVARS 5 #define MODEL_GVARS_DATA gvar_t gvars[MAX_GVARS]; #define PHASE_GVARS_DATA #define GVAR_VALUE(x, p) g_model.gvars[x] -#elif defined(CPUM64) +#elif defined(PCBSTD) #define MAX_GVARS 0 #define MODEL_GVARS_DATA #define PHASE_GVARS_DATA @@ -252,7 +253,7 @@ PACK(typedef struct t_ExpoData { char name[LEN_EXPOMIX_NAME]; int8_t curveParam; }) ExpoData; -#elif defined(CPUM64) +#elif defined(PCBSTD) PACK(typedef struct t_ExpoData { uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both int8_t swtch:6; @@ -354,7 +355,7 @@ PACK( union u_int8int16_t { #define DELAY_MAX 15 /* 7.5 seconds */ #define SLOW_MAX 15 /* 7.5 seconds */ -#if defined(CPUM64) +#if defined(PCBSTD) PACK(typedef struct t_MixData { uint8_t destCh:4; // 0, 1..NUM_CHNOUT uint8_t curveMode:1; // O=curve, 1=differential @@ -823,7 +824,7 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data #define ROTARY_ENCODER_ARRAY_EXTRA #endif -#if defined(CPUM64) +#if defined(PCBSTD) #define TRIM_ARRAY int8_t trim[4]; int8_t trim_ext:8 #else #define TRIM_ARRAY int16_t trim[4] @@ -859,7 +860,7 @@ PACK(typedef struct t_PhaseData { #define MAX_EXPOS 32 #define NUM_CSW 32 // number of custom switches #define NUM_CFN 32 // number of functions assigned to switches -#elif defined(PCBGRUVIN9X) || defined(CPUM128) +#elif defined(PCBGRUVIN9X) #define MAX_MODELS 30 #define NUM_CHNOUT 16 // number of real output channels CH1-CH16 #define MAX_PHASES 6 @@ -867,6 +868,14 @@ PACK(typedef struct t_PhaseData { #define MAX_EXPOS 16 #define NUM_CSW 15 // number of custom switches #define NUM_CFN 24 // number of functions assigned to switches +#elif defined(CPUM128) + #define MAX_MODELS 30 + #define NUM_CHNOUT 16 // number of real output channels CH1-CH16 + #define MAX_PHASES 5 + #define MAX_MIXERS 32 + #define MAX_EXPOS 14 + #define NUM_CSW 12 // number of custom switches + #define NUM_CFN 16 // number of functions assigned to switches #else #define MAX_MODELS 16 #define NUM_CHNOUT 16 // number of real output channels CH1-CH16 @@ -952,7 +961,7 @@ enum SwitchSources { SWSRC_FIRST_MOMENT_SWITCH, SWSRC_LAST_MOMENT_SWITCH = SWSRC_FIRST_MOMENT_SWITCH+SWSRC_ON-1, -#if !defined(CPUM64) +#if !defined(PCBSTD) SWSRC_TRAINER_SHORT, SWSRC_TRAINER_LONG, #endif @@ -1142,7 +1151,7 @@ enum FailsafeModes { #if defined(MAVLINK) #define TELEMETRY_DATA MavlinkData mavlink; -#elif defined(FRSKY) || !defined(CPUM64) +#elif defined(FRSKY) #define TELEMETRY_DATA FrSkyData frsky; #else #define TELEMETRY_DATA @@ -1168,7 +1177,7 @@ PACK(typedef struct t_ModelData { uint8_t extendedTrims:1; uint8_t spare1:1; int8_t ppmDelay; - BeepANACenter beepANACenter; // 1<<0->A1.. 1<<6->A7 + BeepANACenter beepANACenter; // 1<<0->A1.. 1<<6->A7 MixData mixData[MAX_MIXERS]; LimitData limitData[NUM_CHNOUT]; ExpoData expoData[MAX_EXPOS]; @@ -1177,7 +1186,7 @@ PACK(typedef struct t_ModelData { int8_t points[NUM_POINTS]; CustomSwData customSw[NUM_CSW]; - CustomFnData funcSw[NUM_CFN]; + CustomFnData funcSw[NUM_CFN]; SwashRingData swashR; PhaseData phaseData[MAX_PHASES]; diff --git a/src/opentx.cpp b/src/opentx.cpp index 91d63fa82..80f19d8d7 100644 --- a/src/opentx.cpp +++ b/src/opentx.cpp @@ -670,14 +670,13 @@ void applyExpos(int16_t *anas) else v = expo(v, GET_GVAR(curveParam, -100, 100, s_perout_flight_phase)); } - int16_t weight=GET_GVAR(ed.weight, 0, 100, s_perout_flight_phase); - weight=calc100to256(weight); + int16_t weight = GET_GVAR(ed.weight, 0, 100, s_perout_flight_phase); + weight = calc100to256(weight); v = ((int32_t)v * weight) >> 8; - // v = ((int32_t)v * GET_GVAR(ed.weight, 0, 100, s_perout_flight_phase)) / 100; anas[cur_chn] = v; - } //endif - } //endif getSwitch - } //endfor + } + } + } } #if !defined(CPUARM) @@ -1228,7 +1227,7 @@ uint8_t getFlightPhase() int16_t getRawTrimValue(uint8_t phase, uint8_t idx) { PhaseData *p = phaseaddress(phase); -#if defined(CPUM64) +#if defined(PCBSTD) return (((int16_t)p->trim[idx]) << 2) + ((p->trim_ext >> (2*idx)) & 0x03); #else return p->trim[idx]; @@ -1243,7 +1242,7 @@ int16_t getTrimValue(uint8_t phase, uint8_t idx) void setTrimValue(uint8_t phase, uint8_t idx, int16_t trim) { PhaseData *p = phaseaddress(phase); -#if defined(CPUM64) +#if defined(PCBSTD) p->trim[idx] = (int8_t)(trim >> 2); p->trim_ext = (p->trim_ext & ~(0x03 << (2*idx))) + (((trim & 0x03) << (2*idx))); #else @@ -1318,7 +1317,7 @@ void incRotaryEncoder(uint8_t idx, int8_t inc) uint8_t s_gvar_timer = 0; uint8_t s_gvar_last = 0; -#if defined(CPUM64) +#if defined(PCBSTD) int16_t getGVarValue(int16_t x, int16_t min, int16_t max) { if (GV_IS_GV_VALUE(x,min,max)) { @@ -1736,7 +1735,7 @@ uint8_t checkTrim(uint8_t event) #if defined(GVARS) #define TRIM_REUSED() trimGvar[idx] >= 0 if (TRIM_REUSED()) { -#if defined(CPUM64) +#if defined(PCBSTD) phase = 0; #else phase = getGVarFlightPhase(s_perout_flight_phase, trimGvar[idx]); @@ -2321,7 +2320,7 @@ PLAY_FUNCTION(playValue, uint8_t idx) } #endif -#if !defined(CPUM64) +#if !defined(PCBSTD) uint8_t mSwitchDuration[1+NUM_ROTARY_ENCODERS] = { 0 }; #define CFN_PRESSLONG_DURATION 100 #endif @@ -2367,7 +2366,7 @@ void evalFunctions() MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i); uint8_t momentary = 0; -#if !defined(CPUM64) +#if !defined(PCBSTD) #define MOMENTARY_START_TEST() ( (momentary && !(activeSwitches & switch_mask) && active) || \ (short_long==1 && !active && mSwitchDuration[mswitch]>0 && mSwitchDuration[mswitch]1 ? 3*FW : 0), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i, 0) ? INVERS : 0); -#elif !defined(CPUM64) +#elif !defined(PCBSTD) for (uint8_t i=0; i