diff --git a/radio/src/storage/conversions/datastructs_218.h b/radio/src/storage/conversions/datastructs_218.h index 566fc666b..fe43dffbe 100644 --- a/radio/src/storage/conversions/datastructs_218.h +++ b/radio/src/storage/conversions/datastructs_218.h @@ -31,6 +31,18 @@ #define BUZZER_FIELD_218 int8_t spareRadio:2; #endif +#if defined(PCBHORUS) + #define NUM_SWITCHES_218 8 +#elif defined(PCBXLITE) + #define NUM_SWITCHES_218 4 +#elif defined(PCBX7) + #define NUM_SWITCHES_218 6 +#elif defined(PCBX9E) + #define NUM_SWITCHES_218 18 // yes, it's a lot! +#else + #define NUM_SWITCHES_218 8 +#endif + #if defined(PCBHORUS) #define LEN_SWITCH_NAME_218 3 #define LEN_ANA_NAME_218 3 @@ -122,6 +134,61 @@ #define MAX_TELEMETRY_SENSORS_218 32 #endif +PACK(typedef struct { + uint8_t type:4; + int8_t rfProtocol:4; + uint8_t channelsStart; + int8_t channelsCount; // 0=8 channels + uint8_t failsafeMode:4; // only 3 bits used + uint8_t subType:3; + uint8_t invertedSerial:1; // telemetry serial inverted from standard + int16_t failsafeChannels[MAX_OUTPUT_CHANNELS_218]; + union { + struct { + int8_t delay:6; + uint8_t pulsePol:1; + uint8_t outputType:1; // false = open drain, true = push pull + int8_t frameLength; + } ppm; + struct { + uint8_t rfProtocolExtra:2; + uint8_t spare1:3; + uint8_t customProto:1; + uint8_t autoBindMode:1; + uint8_t lowPowerMode:1; + int8_t optionValue; + } multi; + struct { + uint8_t power:2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W + uint8_t spare1:2; + uint8_t receiver_telem_off:1; // false = receiver telem enabled + uint8_t receiver_channel_9_16:1; // false = pwm out 1-8, true 9-16 + uint8_t external_antenna:1; // false = internal antenna, true = external antenna + uint8_t fast:1; // TODO: to be used later by external module (fast means serial @ high speed) + uint8_t spare2; + } pxx; + struct { + uint8_t spare1:6; + uint8_t noninverted:1; + uint8_t spare2:1; + int8_t refreshRate; // definition as framelength for ppm (* 5 + 225 = time in 1/10 ms) + } sbus; + }; + + // Helper functions to set both of the rfProto protocol at the same time + inline uint8_t getMultiProtocol(bool returnCustom) { + if (returnCustom && multi.customProto) + return MM_RF_CUSTOM_SELECTED; + return ((uint8_t) (rfProtocol & 0x0f)) + (multi.rfProtocolExtra << 4); + } + + inline void setMultiProtocol(uint8_t proto) + { + rfProtocol = (uint8_t) (proto & 0x0f); + multi.rfProtocolExtra = (proto & 0x30) >> 4; + } +}) ModuleData_v218; + PACK(typedef struct { int32_t mode:9; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw uint32_t start:23; @@ -237,11 +304,11 @@ PACK(typedef struct { }) GVarData_v218; #if defined(PCBX12S) -#define MODELDATA_EXTRA_218 uint8_t spare:3;uint8_t trainerMode:3;uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1];ScriptData scriptsData[MAX_SCRIPTS_218];char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218];;uint8_t potsWarnEnabled;;int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS];; +#define MODELDATA_EXTRA_218 uint8_t spare:3;uint8_t trainerMode:3;uint8_t potsWarnMode:2; ModuleData_v218 moduleData[NUM_MODULES+1];ScriptData scriptsData[MAX_SCRIPTS_218];char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218];;uint8_t potsWarnEnabled;;int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS];; #elif defined(PCBX10) -#define MODELDATA_EXTRA_218 uint8_t spare:3;;uint8_t trainerMode:3;;uint8_t potsWarnMode:2;; ModuleData moduleData[NUM_MODULES+1];ScriptData scriptsData[MAX_SCRIPTS_218];;char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218];;uint8_t potsWarnEnabled;;int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS];;uint8_t potsWarnSpares[NUM_DUMMY_ANAS];; +#define MODELDATA_EXTRA_218 uint8_t spare:3;;uint8_t trainerMode:3;;uint8_t potsWarnMode:2;; ModuleData_v218 moduleData[NUM_MODULES+1];ScriptData scriptsData[MAX_SCRIPTS_218];;char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218];;uint8_t potsWarnEnabled;;int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS];;uint8_t potsWarnSpares[NUM_DUMMY_ANAS];; #elif defined(PCBTARANIS) -#define MODELDATA_EXTRA_218 uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1]; ScriptData scriptsData[MAX_SCRIPTS_218]; char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; +#define MODELDATA_EXTRA_218 uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData_v218 moduleData[NUM_MODULES+1]; ScriptData scriptsData[MAX_SCRIPTS_218]; char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; #elif defined(PCBSKY9X) #define MODELDATA_EXTRA_218 uint8_t spare:6; uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1]; char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; uint8_t rxBattAlarms[2]; #else @@ -320,7 +387,7 @@ PACK(typedef struct { uint8_t slidersConfig:4; \ uint32_t switchConfig; \ uint8_t potsConfig; /* two bits per pot */ \ - char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME_218]; \ + char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \ char anaNames[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_DUMMY_ANAS][LEN_ANA_NAME_218]; \ char currModelFilename[LEN_MODEL_FILENAME_218+1]; \ uint8_t spare:1; \ @@ -342,7 +409,7 @@ PACK(typedef struct { uint8_t backlightColor; \ swarnstate_t switchUnlockStates; \ swconfig_t switchConfig; \ - char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME_218]; \ + char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \ char anaNames[NUM_STICKS+NUM_POTS+NUM_SLIDERS][LEN_ANA_NAME_218]; \ BLUETOOTH_FIELDS #elif defined(PCBSKY9X) @@ -356,7 +423,7 @@ PACK(typedef struct { uint8_t optrexDisplay; \ uint8_t sticksGain; \ uint8_t rotarySteps; \ - char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME_218]; \ + char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \ char anaNames[NUM_STICKS+NUM_POTS+NUM_SLIDERS][LEN_ANA_NAME_218]; #elif defined(CPUARM) #define EXTRA_GENERAL_FIELDS_218 EXTRA_GENERAL_FIELDS_GENERAL_218