1
0
Fork 0
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:
bsongis 2014-04-07 11:54:31 +02:00
parent 451463505d
commit d1d499a299
6 changed files with 48 additions and 19 deletions

View file

@ -18,3 +18,4 @@
/allsrc.cpp
/BMP
/traces
/MODELS

View file

@ -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];

View file

@ -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;
}

View file

@ -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

View file

@ -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
@ -760,7 +769,7 @@ void RlcFile::nextRlcWriteStep()
return;
}
}
else{
else {
m_rlc_buf+=cnt0;
m_rlc_len-=cnt0+cnt;
m_cur_rlc_len=cnt;

View file

@ -52,15 +52,18 @@
#define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 )
#if defined(PCBTARANIS)
#define EEPROM_VER 216
#define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER 215
#elif defined(PCBSKY9X)
#define EEPROM_VER 216
#define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER 215
#elif defined(CPUM2560) || defined(CPUM2561)
#define EEPROM_VER 216
#define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER EEPROM_VER
#elif defined(CPUM128)
#define EEPROM_VER 216
#define EEPROM_VER 216
#else
#define EEPROM_VER 216
#define EEPROM_VER 216
#endif
#ifndef PACK