WiP: conversions and storage format v220

This commit is contained in:
Raphael Coeffic
2021-06-05 20:29:09 +02:00
committed by Raphael Coeffic
parent ecb1146b13
commit 599bbdf314
6 changed files with 263 additions and 285 deletions
+12 -64
View File
@@ -25,24 +25,9 @@ void convertRadioData(int version)
{
TRACE("convertRadioData(%d)", version);
#if STORAGE_CONVERSIONS < 217
if (version == 216) {
version = 217;
convertRadioData_216_to_217(g_eeGeneral);
}
#endif
#if STORAGE_CONVERSIONS < 218
if (version == 217) {
version = 218;
convertRadioData_217_to_218(g_eeGeneral);
}
#endif
#if STORAGE_CONVERSIONS < 219
if (version == 218) {
version = 219;
convertRadioData_218_to_219(g_eeGeneral);
#if STORAGE_CONVERSIONS < 220
if (version == 219) {
convertRadioData_219_to_220(g_eeGeneral);
}
#endif
}
@@ -51,24 +36,10 @@ void convertModelData(int version)
{
TRACE("convertModelData(%d)", version);
#if STORAGE_CONVERSIONS < 217
if (version == 216) {
version = 217;
convertModelData_216_to_217(g_model);
}
#endif
#if STORAGE_CONVERSIONS < 218
if (version == 217) {
version = 218;
convertModelData_217_to_218(g_model);
}
#endif
#if STORAGE_CONVERSIONS < 219
if (version == 218) {
#if STORAGE_CONVERSIONS < 220
if (version == 219) {
version = 219;
convertModelData_218_to_219(g_model);
convertModelData_219_to_220(g_model);
}
#endif
}
@@ -90,14 +61,8 @@ bool eeConvert()
const char *msg = NULL;
switch (g_eeGeneral.version) {
case 216:
msg = "EEprom Data v216";
break;
case 217:
msg = "EEprom Data v217";
break;
case 218:
msg = "EEprom Data v218";
case 219:
msg = "EEprom Data v219";
break;
default:
return false;
@@ -106,9 +71,6 @@ bool eeConvert()
int conversionVersionStart = g_eeGeneral.version;
// Information to the user and wait for key press
#if defined(PCBSKY9X)
g_eeGeneral.optrexDisplay = 0;
#endif
g_eeGeneral.backlightMode = e_backlight_mode_on;
g_eeGeneral.backlightBright = 0;
g_eeGeneral.contrast = 25;
@@ -121,24 +83,10 @@ bool eeConvert()
eeLoadGeneralSettingsData();
int version = conversionVersionStart;
#if STORAGE_CONVERSIONS < 217
if (version == 216) {
version = 217;
convertRadioData_216_to_217(g_eeGeneral);
}
#endif
#if STORAGE_CONVERSIONS < 218
if (version == 217) {
version = 218;
convertRadioData_217_to_218(g_eeGeneral);
}
#endif
#if STORAGE_CONVERSIONS < 219
if (version == 218) {
version = 219;
convertRadioData_218_to_219(g_eeGeneral);
#if STORAGE_CONVERSIONS < 220
if (version == 219) {
version = 220;
convertRadioData_219_to_220(g_eeGeneral);
}
#endif
+14 -9
View File
@@ -24,14 +24,19 @@ void convertModelData(int version);
bool eeConvert();
void eeConvertModel(int id, int version);
// Conversions 216 to 217
void convertModelData_216_to_217(ModelData &model);
void convertRadioData_216_to_217(RadioData &settings);
// // Conversions 216 to 217
// void convertModelData_216_to_217(ModelData &model);
// void convertRadioData_216_to_217(RadioData &settings);
// Conversions 217 to 218
void convertModelData_217_to_218(ModelData &model);
void convertRadioData_217_to_218(RadioData &settings);
// // Conversions 217 to 218
// void convertModelData_217_to_218(ModelData &model);
// void convertRadioData_217_to_218(RadioData &settings);
// Conversions 218 to 219
void convertModelData_218_to_219(ModelData &model);
void convertRadioData_218_to_219(RadioData &settings);
// // Conversions 218 to 219
// void convertModelData_218_to_219(ModelData &model);
// void convertRadioData_218_to_219(RadioData &settings);
// Conversions 219 to 220
void convertModelData_219_to_220(ModelData &model);
void convertRadioData_219_to_220(RadioData &settings);
@@ -68,6 +68,18 @@
typedef TimerData TimerData_v220;
static void convertToStr(char* str, size_t len)
{
for (int c = 0; c < len; c++) {
str[c] = zchar2char(str[c]);
}
// Trim string
while(len > 0 && str[len-1]) {
if (str[len - 1] != ' ' && str[len - 1] != '\0') break;
str[--len] = '\0';
}
}
void convertModelData_219_to_220(ModelData &model)
{
ModelData* oldModelAllocated = (ModelData*)malloc(sizeof(ModelData));
@@ -76,11 +88,77 @@ void convertModelData_219_to_220(ModelData &model)
memcpy(&oldModel, &model, sizeof(ModelData));
ModelData& newModel = (ModelData&)model;
convertToStr(model.header.name, LEN_MODEL_NAME_219);
for (uint8_t i=0; i<MAX_TIMERS_219; i++) {
//TODO: convert to new timers v220
//TimerData & timer = newModel.timers[i];
TimerData& timer = newModel.timers[i];
convertToStr(timer.name, LEN_TIMER_NAME_219);
}
// MixData::name
for (uint8_t i=0; i<MAX_MIXERS_219; ++i) {
convertToStr(model.mixData[i].name, LEN_EXPOMIX_NAME_219);
}
// LimitData::name
for (uint8_t i=0; i<MAX_OUTPUT_CHANNELS_219; ++i) {
convertToStr(model.limitData[i].name, LEN_CHANNEL_NAME_219);
}
// ExpoData::name
for (uint8_t i=0; i<MAX_EXPOS_219; ++i) {
convertToStr(model.expoData[i].name, LEN_EXPOMIX_NAME_219);
}
// CurveHeader.name
for (uint8_t i=0; i<MAX_CURVES_219; ++i) {
convertToStr(model.expoData[i].name, LEN_CURVE_NAME_219);
}
// CustomFunctionData::play.name
for (uint8_t i = 0; i < MAX_SPECIAL_FUNCTIONS_219; ++i) {
CustomFunctionData* cfn = &(model.customFn[i]);
if (cfn->func == FUNC_PLAY_TRACK || cfn->func == FUNC_BACKGND_MUSIC) {
convertToStr(cfn->play.name, LEN_FUNCTION_NAME_219);
}
}
// GVarData::name ?
for (uint8_t i=0; i<MAX_GVARS_219; ++i) {
convertToStr(model.gvars[i].name, LEN_GVAR_NAME_219);
}
// ScriptData::name ?
// ScriptData::file ?
for (uint8_t i=0; i<MAX_SCRIPTS_219; ++i) {
convertToStr(model.scriptsData[i].file, LEN_SCRIPT_FILENAME);
convertToStr(model.scriptsData[i].name, LEN_SCRIPT_NAME);
}
// Input names
for (uint8_t i=0; i<MAX_INPUTS_219; ++i) {
convertToStr(model.inputNames[i], LEN_INPUT_NAME_219);
}
// Telemetry names
for (uint8_t i=0; i<MAX_TELEMETRY_SENSORS_219; ++i) {
convertToStr(model.telemetrySensors[i].label, TELEM_LABEL_LEN_219);
}
// FlightModeData name
for (uint8_t i=0; i<MAX_FLIGHT_MODES_219; ++i) {
convertToStr(model.flightModeData[i].name, LEN_FLIGHT_MODE_NAME_219);
}
//
// TODO: convert all names from zchar to "normal" chars
//
// g_model.header.bitmap ???? really ????
// TelemetryScriptData::file ?
// ModuleData::pxx2.receiverName
#if defined(PCBHORUS)
// Clear CustomScreenData + TopBarPersistentData
// as they cannot be converted (missing option types)
@@ -89,9 +167,6 @@ void convertModelData_219_to_220(ModelData &model)
sizeof(newModel.topbarData));
//TODO: set defaults as with new model
#endif
//TODO: convert all names from zchar to "normal" chars
free(oldModelAllocated);
}
@@ -117,20 +192,19 @@ void convertRadioData_219_to_220(RadioData & settings)
defaultTheme->init();
#endif
//
// TODO: convert all names from zchar to "normal" chars
//
// g_model.telemetrySensors[i].label
// g_model.header.name
// g_model.header.bitmap // ???? really ????
// timer.name
// fm->name
// expo->name
// g_model.inputNames[chn]
// mix->name
// CurveHeader.name
// cfn->play.name
// limit->name
for (int i = 0; i < NUM_SWITCHES_219; ++i) {
char* sw_name = &(settings.switchNames[i][0]);
convertToStr(sw_name, LEN_SWITCH_NAME_219);
}
for (int i = 0; i < NUM_STICKS_219 + NUM_POTS_219 + NUM_SLIDERS_219; ++i) {
char* sw_name = &(settings.anaNames[i][0]);
convertToStr(sw_name, LEN_ANA_NAME_219);
}
#if defined(PCBHORUS) || defined(PCBNV14)
convertToStr(settings.bluetoothName, LEN_BLUETOOTH_NAME_219);
#endif
free(oldSettingsAllocated);
}
@@ -43,6 +43,25 @@
#error "Unsupported Conversion for Radio"
#endif
#if defined(PCBHORUS)
#define NUM_POTS_219 5
#define NUM_SLIDERS_219 4
#elif defined(PCBX9LITE)
#define NUM_POTS_219 1
#define NUM_SLIDERS_219 0
#elif defined(RADIO_T8) || defined(RADIO_TLITE) || defined(PCBXLITE) || defined(PCBX7)
#define NUM_POTS_219 2
#define NUM_SLIDERS_219 0
#elif defined(PCBX9E)
#define NUM_POTS_219 4
#define NUM_SLIDERS_219 4
#else
#define NUM_POTS_219 3
#define NUM_SLIDERS_219 2
#endif
#define NUM_STICKS_219 4
#if defined(PCBHORUS)
#define LEN_SWITCH_NAME_219 3
#define LEN_ANA_NAME_219 3
@@ -55,6 +74,7 @@
#endif
#define LEN_GVAR_NAME_219 3
#define TELEM_LABEL_LEN_219 4
#if defined(PCBHORUS)
#define LEN_MODEL_NAME_219 15