mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 17:55:19 +03:00
Conversions now run when restoring old Model backups
This commit is contained in:
parent
451463505d
commit
d1d499a299
6 changed files with 48 additions and 19 deletions
1
radio/src/.gitignore
vendored
1
radio/src/.gitignore
vendored
|
@ -18,3 +18,4 @@
|
|||
/allsrc.cpp
|
||||
/BMP
|
||||
/traces
|
||||
/MODELS
|
||||
|
|
|
@ -56,6 +56,7 @@ bool eeModelExists(uint8_t id);
|
|||
void eeLoadModelName(uint8_t id, char *name);
|
||||
void eeLoadModel(uint8_t id);
|
||||
bool eeConvert();
|
||||
void ConvertModel(int id, int version);
|
||||
|
||||
#if defined(CPUARM)
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
|
|
|
@ -860,6 +860,22 @@ void ConvertModel_215_to_216(ModelData &model)
|
|||
memcpy(g_model.moduleData, oldModel.moduleData, sizeof(g_model.moduleData));
|
||||
}
|
||||
|
||||
void ConvertModel(int id, int version)
|
||||
{
|
||||
loadModel(id);
|
||||
|
||||
if (version == 215) {
|
||||
version = 216;
|
||||
ConvertModel_215_to_216(g_model);
|
||||
}
|
||||
|
||||
uint8_t currModel = g_eeGeneral.currModel;
|
||||
g_eeGeneral.currModel = id;
|
||||
s_eeDirtyMsk = EE_MODEL;
|
||||
eeCheck(true);
|
||||
g_eeGeneral.currModel = currModel;
|
||||
}
|
||||
|
||||
bool eeConvert()
|
||||
{
|
||||
const char *msg = NULL;
|
||||
|
@ -900,7 +916,6 @@ bool eeConvert()
|
|||
#endif
|
||||
|
||||
// Models conversion
|
||||
uint8_t currModel = g_eeGeneral.currModel;
|
||||
for (uint8_t id=0; id<MAX_MODELS; id++) {
|
||||
#if LCD_W >= 212
|
||||
lcd_hline(61, 6*FH+5, 10+id*2, FORCE);
|
||||
|
@ -909,19 +924,10 @@ bool eeConvert()
|
|||
#endif
|
||||
lcdRefresh();
|
||||
if (eeModelExists(id)) {
|
||||
loadModel(id);
|
||||
int version = conversionVersionStart;
|
||||
if (version == 215) {
|
||||
version = 216;
|
||||
ConvertModel_215_to_216(g_model);
|
||||
}
|
||||
g_eeGeneral.currModel = id;
|
||||
s_eeDirtyMsk = EE_MODEL;
|
||||
eeCheck(true);
|
||||
ConvertModel(id, conversionVersionStart);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
g_eeGeneral.currModel = currModel;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -753,7 +753,8 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
|
|||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
if (*(uint32_t*)&buf[0] != O9X_FOURCC || (uint8_t)buf[4] != EEPROM_VER || buf[5] != 'M') {
|
||||
uint8_t version = (uint8_t)buf[4];
|
||||
if (*(uint32_t*)&buf[0] != O9X_FOURCC || version < FIRST_CONV_EEPROM_VER || version > EEPROM_VER || buf[5] != 'M') {
|
||||
f_close(&restoreFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
@ -784,6 +785,14 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
|
|||
Eeprom32_process_state = E32_BLANKCHECK;
|
||||
eeWaitFinished();
|
||||
|
||||
#if defined(CPUARM)
|
||||
if (version < EEPROM_VER) {
|
||||
eeCheck(true);
|
||||
ConvertModel(i_fileDst, version);
|
||||
loadModel(g_eeGeneral.currModel);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -663,7 +663,8 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
|
|||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
if (*(uint32_t*)&buf[0] != O9X_FOURCC || (uint8_t)buf[4] != EEPROM_VER || buf[5] != 'M') {
|
||||
uint8_t version = (uint8_t)buf[4];
|
||||
if (*(uint32_t*)&buf[0] != O9X_FOURCC || version < FIRST_CONV_EEPROM_VER || version > EEPROM_VER || buf[5] != 'M') {
|
||||
f_close(&g_oLogFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
@ -702,6 +703,14 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
|
|||
|
||||
f_close(&g_oLogFile);
|
||||
|
||||
#if defined(CPUARM)
|
||||
if (version < EEPROM_VER) {
|
||||
eeCheck(true);
|
||||
ConvertModel(i_fileDst, version);
|
||||
loadModel(g_eeGeneral.currModel);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
eeLoadModelHeader(i_fileDst, &modelHeaders[i_fileDst]);
|
||||
#endif
|
||||
|
|
|
@ -53,10 +53,13 @@
|
|||
|
||||
#if defined(PCBTARANIS)
|
||||
#define EEPROM_VER 216
|
||||
#define FIRST_CONV_EEPROM_VER 215
|
||||
#elif defined(PCBSKY9X)
|
||||
#define EEPROM_VER 216
|
||||
#define FIRST_CONV_EEPROM_VER 215
|
||||
#elif defined(CPUM2560) || defined(CPUM2561)
|
||||
#define EEPROM_VER 216
|
||||
#define FIRST_CONV_EEPROM_VER EEPROM_VER
|
||||
#elif defined(CPUM128)
|
||||
#define EEPROM_VER 216
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue