From 74779cc525e81a647de6b97452fdaa34f5e6f67c Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sat, 14 Mar 2015 10:26:05 +0100 Subject: [PATCH] Cosmetics --- radio/src/curves.cpp | 13 ++---- radio/src/myeeprom.h | 108 +++++++++++++++++++++++-------------------- 2 files changed, 62 insertions(+), 59 deletions(-) diff --git a/radio/src/curves.cpp b/radio/src/curves.cpp index fa7a66b39..9cd969e33 100644 --- a/radio/src/curves.cpp +++ b/radio/src/curves.cpp @@ -36,7 +36,7 @@ #include "opentx.h" -#if defined(PCBTARANIS) +#if defined(XCURVES) int8_t *curveEnd[MAX_CURVES]; void loadCurves() { @@ -86,7 +86,7 @@ CurveInfo curveInfo(uint8_t idx) } #endif -#if defined(PCBTARANIS) +#if defined(XCURVES) #define CUSTOM_POINT_X(points, count, idx) ((idx)==0 ? -100 : (((idx)==(count)-1) ? 100 : points[(count)+(idx)-1])) s32 compute_tangent(CurveInfo *crv, int8_t *points, int i) { @@ -205,7 +205,7 @@ int16_t hermite_spline(int16_t x, uint8_t idx) int intpol(int x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100 { -#if defined(PCBTARANIS) +#if defined(XCURVES) CurveInfo &crv = g_model.curves[idx]; int8_t *points = curveAddress(idx); uint8_t count = crv.points+5; @@ -248,8 +248,7 @@ int intpol(int x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100 return erg / 25; // 100*D5/RESX; } -#if defined(CURVES) -#if defined(PCBTARANIS) +#if defined(CURVES) && defined(XCURVES) int applyCurve(int x, CurveRef & curve) { switch (curve.type) { @@ -313,8 +312,7 @@ int applyCustomCurve(int x, uint8_t idx) else return intpol(x, idx); } - -#else +#elif defined(CURVES) int applyCurve(int x, int8_t idx) { /* already tried to have only one return at the end */ @@ -343,7 +341,6 @@ int applyCurve(int x, int8_t idx) return applyCustomCurve(x, idx - CURVE_BASE); } #endif -#endif // #define EXTENDED_EXPO // increases range of expo curve but costs about 82 bytes flash diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 2f1c48542..46f5eeaa9 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -185,6 +185,28 @@ #define NUM_CYC 3 #define NUM_CAL_PPM 4 +enum CurveType { + CURVE_TYPE_STANDARD, + CURVE_TYPE_CUSTOM, + CURVE_TYPE_LAST = CURVE_TYPE_CUSTOM +}; + +#if defined(XCURVES) +PACK(typedef struct { + uint8_t type:3; + uint8_t smooth:1; + uint8_t spare:4; + int8_t points; +}) CurveInfo; +#else +struct CurveInfo { + int8_t *crv; + uint8_t points; + bool custom; +}; +extern CurveInfo curveInfo(uint8_t idx); +#endif + #if defined(PCBTARANIS) #define LEN_MODEL_NAME 12 #define LEN_TIMER_NAME 8 @@ -193,17 +215,6 @@ #define LEN_EXPOMIX_NAME 8 #define LEN_CHANNEL_NAME 6 #define LEN_INPUT_NAME 4 - enum CurveType { - CURVE_TYPE_STANDARD, - CURVE_TYPE_CUSTOM, - CURVE_TYPE_LAST = CURVE_TYPE_CUSTOM - }; -PACK(typedef struct { - uint8_t type:3; - uint8_t smooth:1; - uint8_t spare:4; - int8_t points; -}) CurveInfo; #define MAX_CURVES 32 #define NUM_POINTS 512 #define CURVDATA CurveInfo @@ -337,28 +348,38 @@ enum BeeperMode { #endif #if defined(PCBTARANIS) -enum uartModes { - UART_MODE_NONE, - UART_MODE_TELEMETRY_MIRROR, - UART_MODE_TELEMETRY, - UART_MODE_SBUS_TRAINER, - // UART_MODE_CPPM_TRAINER, -#if defined(DEBUG) - UART_MODE_DEBUG, -#endif - UART_MODE_COUNT, - UART_MODE_MAX = UART_MODE_COUNT-1 -}; + enum UartModes { + UART_MODE_NONE, + UART_MODE_TELEMETRY_MIRROR, + UART_MODE_TELEMETRY, + UART_MODE_SBUS_TRAINER, + // UART_MODE_CPPM_TRAINER, + #if defined(DEBUG) + UART_MODE_DEBUG, + #endif + UART_MODE_COUNT, + UART_MODE_MAX = UART_MODE_COUNT-1 + }; -#define HAS_WIRELESS_TRAINER_HARDWARE() (g_eeGeneral.uart3Mode==UART_MODE_SBUS_TRAINER/* || g_eeGeneral.uart3Mode==UART_MODE_CPPM_TRAINER*/) -#define EXTRA_GENERAL_FIELDS \ - EXTRA_GENERAL_FIELDS_ARM \ - uint8_t uart3Mode:6; \ - uint8_t slidersConfig:2; \ - uint8_t potsConfig; /*two bits for every pot*/\ - uint8_t backlightColor; + #define LEN_SWITCH_NAME 3 + #define LEN_ANA_NAME 3 + + #define HAS_WIRELESS_TRAINER_HARDWARE() (g_eeGeneral.uart3Mode==UART_MODE_SBUS_TRAINER/* || g_eeGeneral.uart3Mode==UART_MODE_CPPM_TRAINER*/) + #define EXTRA_GENERAL_FIELDS \ + EXTRA_GENERAL_FIELDS_ARM \ + uint8_t uart3Mode:6; \ + uint8_t slidersConfig:2; \ + uint8_t potsConfig; /*two bits for every pot*/\ + uint8_t backlightColor; + swarnstate_t switchUnlockStates; \ + CustomFunctionData customFn[NUM_CFN]; \ + swconfig_t switchConfig; \ + char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]; \ + char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]; #elif defined(CPUARM) - #define EXTRA_GENERAL_FIELDS EXTRA_GENERAL_FIELDS_ARM + #define EXTRA_GENERAL_FIELDS \ + EXTRA_GENERAL_FIELDS_ARM \ + CustomFunctionData customFn[NUM_CFN] #elif defined(PXX) #define EXTRA_GENERAL_FIELDS uint8_t countryCode; #else @@ -691,19 +712,13 @@ PACK(typedef struct { SLIDER_NONE, SLIDER_WITH_DETENT, }; - #define GENERAL_FIELD_SWITCH_CONFIG swconfig_t switchConfig; #define SWITCH_CONFIG(x) ((g_eeGeneral.switchConfig >> (2*(x))) & 0x03) #define SWITCH_EXISTS(x) (SWITCH_CONFIG(x) != SWITCH_NONE) #define IS_3POS(x) (SWITCH_CONFIG(x) == SWITCH_3POS) #define IS_TOGGLE(x) (SWITCH_CONFIG(x) == SWITCH_TOGGLE) #define SWITCH_WARNING_ALLOWED(x) (SWITCH_EXISTS(x) && !IS_TOGGLE(x)) -#else - #define GENERAL_FIELD_SWITCH_CONFIG #endif -#define LEN_SWITCH_NAME 3 -#define LEN_ANA_NAME 3 - #define ALTERNATE_VIEW 0x10 PACK(typedef struct { uint8_t version; @@ -750,34 +765,25 @@ PACK(typedef struct { EXTRA_GENERAL_FIELDS - TARANIS_FIELD(swarnstate_t switchUnlockStates) - - ARM_FIELD(CustomFunctionData customFn[NUM_CFN]) - - GENERAL_FIELD_SWITCH_CONFIG - - TARANIS_FIELD(char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]) - - TARANIS_FIELD(char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]) - }) EEGeneral; #define SWITCHES_DELAY() uint8_t(15+g_eeGeneral.switchesDelay) #define SWITCHES_DELAY_NONE (-15) #define HAPTIC_STRENGTH() (3+g_eeGeneral.hapticStrength) -#if defined(PCBTARANIS) enum CurveRefType { CURVE_REF_DIFF, CURVE_REF_EXPO, CURVE_REF_FUNC, CURVE_REF_CUSTOM }; + PACK(typedef struct { uint8_t type; int8_t value; }) CurveRef; -#else + +#if !defined(XCURVES) #define MODE_DIFFERENTIAL 0 #define MODE_EXPO 0 #define MODE_CURVE 1 @@ -1451,7 +1457,7 @@ enum TelemetryScreenType { TELEMETRY_SCREEN_TYPE_NONE, TELEMETRY_SCREEN_TYPE_VALUES, TELEMETRY_SCREEN_TYPE_GAUGES, -#if defined(PCBTARANIS) && defined(LUA) +#if defined(LUA) TELEMETRY_SCREEN_TYPE_SCRIPT, TELEMETRY_SCREEN_TYPE_MAX = TELEMETRY_SCREEN_TYPE_SCRIPT #else @@ -1751,7 +1757,7 @@ enum SwitchSources { enum MixSources { MIXSRC_NONE, -#if defined(PCBTARANIS) +#if defined(VIRTUALINPUTS) MIXSRC_FIRST_INPUT, LUA_EXPORT_MULTIPLE("input", "Input [I%d]", MAX_INPUTS) MIXSRC_LAST_INPUT = MIXSRC_FIRST_INPUT+MAX_INPUTS-1,