Bsongis/x9d+ 2019 (#6588)

X9D+ 2019 added
This commit is contained in:
Bertrand Songis
2019-07-26 19:18:29 +02:00
committed by GitHub
parent 37e1e0ef33
commit 151827ada5
44 changed files with 704 additions and 321 deletions
@@ -35,12 +35,18 @@ typedef ModelData ModelData_v219;
int convertSource_218_to_219(int source)
{
// on X7: 2 additional switches
// on X9D / X9D+: 1 additional switch
#if defined(PCBX7)
if (source >= MIXSRC_SI)
source += 2;
#endif
#if defined(PCBX9D) || defined(PCBX9DP)
if (source >= MIXSRC_SI)
source += 1;
#endif
#if defined(PCBHORUS)
if (source >= MIXSRC_GMBL)
source += 2;
@@ -52,8 +58,9 @@ int convertSource_218_to_219(int source)
int convertSwitch_218_to_219(int swtch)
{
// on X7: 2 additional switches
// on X9D / X9D+: 1 additional switch
#if defined(PCBX7) || defined(PCBHORUS)
#if defined(PCBX7) || defined(PCBHORUS) || defined(PCBX9D) || defined(PCBX9DP)
if (swtch < 0)
return -convertSwitch_218_to_219(-swtch);
#endif
@@ -63,6 +70,11 @@ int convertSwitch_218_to_219(int swtch)
swtch += 2 * 3;
#endif
#if defined(PCBX9D) || defined(PCBX9DP)
if (swtch >= SWSRC_SI0)
swtch += 3;
#endif
#if defined(PCBHORUS)
if (swtch >= SWSRC_GMBL0)
swtch += 2 * 3;
@@ -184,6 +196,15 @@ void convertModelData_218_to_219(ModelData &model)
newModel.moduleData[i].type += 1;
if (newModel.moduleData[i].type >= MODULE_TYPE_R9M_PXX2)
newModel.moduleData[i].type += 4;
if (newModel.moduleData[i].type == MODULE_TYPE_XJT_PXX1) {
newModel.moduleData[i].subType = newModel.moduleData[i].rfProtocol;
#if defined(PCBX9DP) && PCBREV >= 2019
if (i == INTERNAL_MODULE) {
newModel.moduleData[i].type = MODULE_TYPE_ISRM_PXX2;
newModel.moduleData[i].subType = MODULE_SUBTYPE_ISRM_PXX2_ACCST_D16;
}
#endif
}
}
#if defined(RADIO_T12)
@@ -250,21 +271,18 @@ void convertModelData_218_to_219(ModelData &model)
#else
newModel.screensType = oldModel.frsky.screensType;
memmove(&newModel.screens, &oldModel.frsky.screens, sizeof(newModel.screens));
#endif
#if defined(PCBX7)
for (int i=0; i<MAX_TELEMETRY_SCREENS; i++) {
uint8_t screenType = (newModel.screensType >> (2*i)) & 0x03;
if (screenType == TELEMETRY_SCREEN_TYPE_VALUES) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < NUM_LINE_ITEMS; k++) {
newModel.screens[i].lines[j].sources[k] = convertSource_218_to_219(newModel.screens[i].lines[j].sources[k]);
newModel.screens[i].lines[j].sources[k] = convertSource_218_to_219(oldModel.frsky.screens[i].lines[j].sources[k]);
}
}
}
else if (screenType == TELEMETRY_SCREEN_TYPE_GAUGES) {
for (int j = 0; j < 4; j++) {
newModel.screens[i].bars[j].source = convertSource_218_to_219(newModel.screens[i].bars[j].source);
newModel.screens[i].bars[j].source = convertSource_218_to_219(oldModel.frsky.screens[i].bars[j].source);
}
}
}
@@ -280,30 +298,67 @@ void convertRadioData_218_to_219(RadioData & settings)
settings.version = 219;
settings.variant = EEPROM_VARIANT;
#if defined(PCBHORUS)
RadioData_v218 settings_v218 = (RadioData_v218 &)settings;
#if defined(STM32)
RadioData_v218 * oldSettingsAllocated = (RadioData_v218 *)malloc(sizeof(RadioData_v218));
RadioData_v218 & oldSettings = *oldSettingsAllocated;
memcpy(&oldSettings, &settings, sizeof(RadioData_v218));
#endif
memcpy(&settings.chkSum, &settings_v218.chkSum, offsetof(RadioData, auxSerialMode) - offsetof(RadioData, chkSum));
memcpy(&settings.calib[NUM_STICKS + 5], &settings_v218.calib[NUM_STICKS + 3], sizeof(CalibData) * (STORAGE_NUM_SLIDERS + STORAGE_NUM_MOUSE_ANALOGS));
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX7)
for (uint8_t i=0; i<MAX_SPECIAL_FUNCTIONS_218; i++) {
CustomFunctionData & cf = settings.customFn[i];
cf.swtch = convertSwitch_218_to_219(cf.swtch);
}
#endif
#if defined(PCBX9D) || defined(PCBX9DP)
// no bluetooth before PCBREV 2019
settings.auxSerialMode = oldSettings.auxSerialMode;
settings.slidersConfig = oldSettings.slidersConfig;
settings.potsConfig = oldSettings.potsConfig;
settings.backlightColor = oldSettings.backlightColor;
settings.switchUnlockStates = oldSettings.switchUnlockStates;
settings.switchConfig = oldSettings.switchConfig;
#if defined(PCBX9DP) && PCBREV >= 2019
settings.switchConfig |= SWITCH_TOGGLE << 16;
#endif
memcpy(&settings.switchNames[0], &oldSettings.switchNames[0], 8 * LEN_SWITCH_NAME);
memclear(&settings.switchNames[8], LEN_SWITCH_NAME);
memcpy(&settings.anaNames[0], &oldSettings.anaNames[0], (NUM_STICKS+NUM_POTS+NUM_SLIDERS) * LEN_ANA_NAME);
#endif
#if defined(PCBHORUS)
memcpy(&settings.chkSum, &oldSettings.chkSum, offsetof(RadioData, auxSerialMode) - offsetof(RadioData, chkSum));
memcpy(&settings.calib[NUM_STICKS + 5], &oldSettings.calib[NUM_STICKS + 3], sizeof(CalibData) * (STORAGE_NUM_SLIDERS + STORAGE_NUM_MOUSE_ANALOGS));
memclear(&settings.calib[NUM_STICKS + 3], sizeof(CalibData) * 2);
settings.auxSerialMode = settings_v218.auxSerialMode;
settings.switchConfig = settings_v218.switchConfig;
settings.potsConfig = settings_v218.potsConfig;
settings.slidersConfig = settings_v218.slidersConfig;
settings.auxSerialMode = oldSettings.auxSerialMode;
settings.switchConfig = oldSettings.switchConfig;
settings.potsConfig = oldSettings.potsConfig;
settings.slidersConfig = oldSettings.slidersConfig;
memcpy(&settings.switchNames[0], &settings_v218.switchNames[0], 8 * LEN_SWITCH_NAME);
memcpy(&settings.switchNames[0], &oldSettings.switchNames[0], 8 * LEN_SWITCH_NAME);
memclear(&settings.switchNames[8], 2 * LEN_SWITCH_NAME);
memcpy(&settings.anaNames[0], &settings_v218.anaNames[0], (NUM_STICKS + 3) * LEN_ANA_NAME);
memcpy(&settings.anaNames[0], &oldSettings.anaNames[0], (NUM_STICKS + 3) * LEN_ANA_NAME);
memclear(&settings.anaNames[NUM_STICKS + 3], 2 * LEN_SWITCH_NAME);
memcpy(&settings.anaNames[NUM_STICKS + 5], &settings_v218.anaNames[NUM_STICKS + 3], STORAGE_NUM_SLIDERS * LEN_ANA_NAME);
memcpy(&settings.anaNames[NUM_STICKS + 5], &oldSettings.anaNames[NUM_STICKS + 3], STORAGE_NUM_SLIDERS * LEN_ANA_NAME);
memcpy(&settings.currModelFilename[0], &settings_v218.currModelFilename[0], sizeof(RadioData_v218) - offsetof(RadioData_v218, currModelFilename[0]));
memcpy(&settings.currModelFilename[0], &oldSettings.currModelFilename[0], sizeof(RadioData_v218) - offsetof(RadioData_v218, currModelFilename[0]));
#endif
#if defined(RADIO_T12)
g_eeGeneral.switchConfig = bfSet<uint32_t>(g_eeGeneral.switchConfig, SWITCH_2POS, 10, 2); // T12 comes with wrongly defined pot2
g_eeGeneral.potsConfig = bfSet<uint32_t>(g_eeGeneral.potsConfig, POT_WITHOUT_DETENT, 2, 2); // T12 comes with wrongly defined pot2
#endif
#if defined(PCBX9DP) && PCBREV >= 2019
// force re-calibration
settings.chkSum = 0xFFFF;
setDefaultOwnerId();
#endif
#if defined(STM32)
free(oldSettingsAllocated);
#endif
}
+74 -72
View File
@@ -24,12 +24,6 @@
#define MAX_TIMERS_218 3
#define MAX_GVARS_218 9
#if defined(BUZZER)
#define BUZZER_FIELD_218 int8_t buzzerMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all (only used on AVR radios without audio hardware)
#else
#define BUZZER_FIELD_218 int8_t spareRadio:2;
#endif
#if defined(PCBHORUS)
#define NUM_SWITCHES_218 8
#elif defined(PCBXLITE)
@@ -130,6 +124,21 @@
#define MAX_TELEMETRY_SENSORS_218 32
#endif
#if defined(COLORLCD)
typedef uint32_t swarnstate218_t;
#elif defined(PCBX9E)
typedef uint64_t swconfig218_t;
typedef uint64_t swarnstate218_t;
typedef uint32_t swarnenable218_t;
#elif defined(PCBTARANIS)
typedef uint16_t swconfig218_t;
typedef uint16_t swarnstate218_t;
typedef uint8_t swarnenable218_t;
#else
typedef uint8_t swarnstate218_t;
typedef uint8_t swarnenable218_t;
#endif
PACK(typedef struct {
uint8_t type:4;
int8_t rfProtocol:4;
@@ -416,7 +425,7 @@ PACK(struct ModelHeader_v218 {
#if defined(COLORLCD)
#define SWITCH_WARNING_DATA_218
#else
#define SWITCH_WARNING_DATA_218 swarnenable_t switchWarningEnable;
#define SWITCH_WARNING_DATA_218 swarnenable218_t switchWarningEnable;
#endif
PACK(struct ModelData_v218 {
@@ -448,7 +457,7 @@ PACK(struct ModelData_v218 {
uint8_t thrTraceSrc;
swarnstate_t switchWarningState;
swarnstate218_t switchWarningState;
SWITCH_WARNING_DATA_218
@@ -467,45 +476,8 @@ PACK(struct ModelData_v218 {
VIEW_DATA
});
#include "chksize.h"
#define CHKSIZE(x, y) check_size<struct x, y>()
static inline void check_struct_218()
{
#if defined(PCBHORUS)
CHKSIZE(ModelData_v218, 9380);
#elif defined(PCBX9E)
CHKSIZE(ModelData_v218, 6520);
#endif
}
#undef CHKSIZE
#define EXTRA_GENERAL_FIELDS_GENERAL_218 \
uint8_t backlightBright; \
uint32_t globalTimer; \
uint8_t bluetoothBaudrate:4; \
uint8_t bluetoothMode:4; \
uint8_t countryCode; \
uint8_t imperial:1; \
uint8_t jitterFilter:1; /* 0 - active */\
uint8_t disableRssiPoweroffAlarm:1; \
uint8_t USBMode:2; \
uint8_t spareExtraArm:3; \
char ttsLanguage[2]; \
int8_t beepVolume:4; \
int8_t wavVolume:4; \
int8_t varioVolume:4; \
int8_t backgroundVolume:4; \
int8_t varioPitch; \
int8_t varioRange; \
int8_t varioRepeat; \
CustomFunctionData_v218 customFn[MAX_SPECIAL_FUNCTIONS_218];
#if defined(PCBHORUS)
#define EXTRA_GENERAL_FIELDS_218 \
EXTRA_GENERAL_FIELDS_GENERAL_218 \
uint8_t auxSerialMode:4; \
uint8_t slidersConfig:4; \
uint32_t switchConfig; \
@@ -517,27 +489,25 @@ static inline void check_struct_218()
uint8_t blOffBright:7; \
char bluetoothName[LEN_BLUETOOTH_NAME_218];
#elif defined(PCBTARANIS)
#if defined(BLUETOOTH)
#define BLUETOOTH_FIELDS_218 \
#if defined(STORAGE_BLUETOOTH) && !defined(PCBX9D) && !defined(PCBX9DP)
#define BLUETOOTH_FIELDS_218 \
uint8_t spare; \
char bluetoothName[LEN_BLUETOOTH_NAME_218];
#else
#define BLUETOOTH_FIELDS
#endif
#define EXTRA_GENERAL_FIELDS_218 \
EXTRA_GENERAL_FIELDS_GENERAL_218 \
#else
#define BLUETOOTH_FIELDS_218
#endif
#define EXTRA_GENERAL_FIELDS_218 \
uint8_t auxSerialMode:4; \
uint8_t slidersConfig:4; \
uint8_t potsConfig; /* two bits per pot */\
uint8_t backlightColor; \
swarnstate_t switchUnlockStates; \
swconfig_t switchConfig; \
swarnstate218_t switchUnlockStates; \
swconfig218_t switchConfig; \
char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \
char anaNames[NUM_STICKS+NUM_POTS+NUM_SLIDERS][LEN_ANA_NAME_218]; \
BLUETOOTH_FIELDS
BLUETOOTH_FIELDS_218
#elif defined(PCBSKY9X)
#define EXTRA_GENERAL_FIELDS_218 \
EXTRA_GENERAL_FIELDS_GENERAL_218 \
#define EXTRA_GENERAL_FIELDS_218 \
int8_t txCurrentCalibration; \
int8_t temperatureWarn; \
uint8_t mAhWarn; \
@@ -548,16 +518,8 @@ static inline void check_struct_218()
uint8_t rotarySteps; \
char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \
char anaNames[NUM_STICKS+NUM_POTS+NUM_SLIDERS][LEN_ANA_NAME_218];
#else
#define EXTRA_GENERAL_FIELDS_218 EXTRA_GENERAL_FIELDS_GENERAL_218
#endif
#if defined(PCBHORUS)
#define SPLASH_MODE_218 uint8_t splashSpares:3
#elif defined(FSPLASH)
#define SPLASH_MODE_218 uint8_t splashMode:3
#else
#define SPLASH_MODE_218 int8_t splashMode:3
#else
#define EXTRA_GENERAL_FIELDS_218 EXTRA_GENERAL_FIELDS_GENERAL_218
#endif
#if defined(COLORLCD)
@@ -570,7 +532,7 @@ static inline void check_struct_218()
#define THEME_DATA
#endif
PACK(typedef struct {
PACK(struct RadioData_v218 {
uint8_t version;
uint16_t variant;
CalibData calib[NUM_STICKS+STORAGE_NUM_POTS+STORAGE_NUM_SLIDERS+STORAGE_NUM_MOUSE_ANALOGS];
@@ -582,7 +544,7 @@ PACK(typedef struct {
int8_t backlightMode;
TrainerData_v218 trainer;
uint8_t view; // index of view in main screen
BUZZER_FIELD_218
int8_t buzzerMode:2;
uint8_t fai:1;
int8_t beepMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all
uint8_t alarmsFlash:1;
@@ -592,8 +554,10 @@ PACK(typedef struct {
int8_t timezone:5;
uint8_t adjustRTC:1;
uint8_t inactivityTimer;
SPLASH_MODE_218; /* 3bits */
int8_t hapticMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all
int8_t splashMode:3;
int8_t hapticMode:2;
int8_t spare2:3;
int8_t switchesDelay;
uint8_t lightAutoOff;
uint8_t templateSetup; // RETA order for receiver channels
int8_t PPM_Multiplier;
@@ -609,9 +573,47 @@ PACK(typedef struct {
int8_t vBatMin;
int8_t vBatMax;
uint8_t backlightBright;
uint32_t globalTimer;
uint8_t bluetoothBaudrate:4;
uint8_t bluetoothMode:4;
uint8_t countryCode;
uint8_t imperial:1;
uint8_t jitterFilter:1; /* 0 - active */
uint8_t disableRssiPoweroffAlarm:1;
uint8_t USBMode:2;
uint8_t spareExtraArm:3;
char ttsLanguage[2];
int8_t beepVolume:4;
int8_t wavVolume:4;
int8_t varioVolume:4;
int8_t backgroundVolume:4;
int8_t varioPitch;
int8_t varioRange;
int8_t varioRepeat;
CustomFunctionData_v218 customFn[MAX_SPECIAL_FUNCTIONS_218];
EXTRA_GENERAL_FIELDS_218
THEME_DATA
}) RadioData_v218;
});
#include "chksize.h"
#define CHKSIZE(x, y) check_size<struct x, y>()
static inline void check_struct_218()
{
#if defined(PCBHORUS)
CHKSIZE(ModelData_v218, 9380);
#elif defined(PCBX9E)
CHKSIZE(ModelData_v218, 6520);
#elif defined(PCBX9D)
CHKSIZE(RadioData_v218, 872);
#endif
}
#undef CHKSIZE
#endif //OPENTX_DATASTRUCTS_218_H