Conversions now run when restoring old Model backups

This commit is contained in:
bsongis
2014-04-07 12:00:02 +02:00
parent 451463505d
commit d1d499a299
6 changed files with 48 additions and 19 deletions
+1
View File
@@ -18,3 +18,4 @@
/allsrc.cpp /allsrc.cpp
/BMP /BMP
/traces /traces
/MODELS
+1
View File
@@ -56,6 +56,7 @@ bool eeModelExists(uint8_t id);
void eeLoadModelName(uint8_t id, char *name); void eeLoadModelName(uint8_t id, char *name);
void eeLoadModel(uint8_t id); void eeLoadModel(uint8_t id);
bool eeConvert(); bool eeConvert();
void ConvertModel(int id, int version);
#if defined(CPUARM) #if defined(CPUARM)
extern ModelHeader modelHeaders[MAX_MODELS]; extern ModelHeader modelHeaders[MAX_MODELS];
+17 -11
View File
@@ -860,6 +860,22 @@ void ConvertModel_215_to_216(ModelData &model)
memcpy(g_model.moduleData, oldModel.moduleData, sizeof(g_model.moduleData)); 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() bool eeConvert()
{ {
const char *msg = NULL; const char *msg = NULL;
@@ -900,7 +916,6 @@ bool eeConvert()
#endif #endif
// Models conversion // Models conversion
uint8_t currModel = g_eeGeneral.currModel;
for (uint8_t id=0; id<MAX_MODELS; id++) { for (uint8_t id=0; id<MAX_MODELS; id++) {
#if LCD_W >= 212 #if LCD_W >= 212
lcd_hline(61, 6*FH+5, 10+id*2, FORCE); lcd_hline(61, 6*FH+5, 10+id*2, FORCE);
@@ -909,19 +924,10 @@ bool eeConvert()
#endif #endif
lcdRefresh(); lcdRefresh();
if (eeModelExists(id)) { if (eeModelExists(id)) {
loadModel(id); ConvertModel(id, conversionVersionStart);
int version = conversionVersionStart;
if (version == 215) {
version = 216;
ConvertModel_215_to_216(g_model);
}
g_eeGeneral.currModel = id;
s_eeDirtyMsk = EE_MODEL;
eeCheck(true);
} }
} }
g_eeGeneral.currModel = currModel;
return true; return true;
} }
+10 -1
View File
@@ -753,7 +753,8 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
return SDCARD_ERROR(result); 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); f_close(&restoreFile);
return STR_INCOMPATIBLE; return STR_INCOMPATIBLE;
} }
@@ -784,6 +785,14 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
Eeprom32_process_state = E32_BLANKCHECK; Eeprom32_process_state = E32_BLANKCHECK;
eeWaitFinished(); eeWaitFinished();
#if defined(CPUARM)
if (version < EEPROM_VER) {
eeCheck(true);
ConvertModel(i_fileDst, version);
loadModel(g_eeGeneral.currModel);
}
#endif
return NULL; return NULL;
} }
#endif #endif
+11 -2
View File
@@ -663,7 +663,8 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
return SDCARD_ERROR(result); 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); f_close(&g_oLogFile);
return STR_INCOMPATIBLE; return STR_INCOMPATIBLE;
} }
@@ -702,6 +703,14 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
f_close(&g_oLogFile); 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) #if defined(CPUARM)
eeLoadModelHeader(i_fileDst, &modelHeaders[i_fileDst]); eeLoadModelHeader(i_fileDst, &modelHeaders[i_fileDst]);
#endif #endif
@@ -760,7 +769,7 @@ void RlcFile::nextRlcWriteStep()
return; return;
} }
} }
else{ else {
m_rlc_buf+=cnt0; m_rlc_buf+=cnt0;
m_rlc_len-=cnt0+cnt; m_rlc_len-=cnt0+cnt;
m_cur_rlc_len=cnt; m_cur_rlc_len=cnt;
+8 -5
View File
@@ -52,15 +52,18 @@
#define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 ) #define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 )
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define EEPROM_VER 216 #define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER 215
#elif defined(PCBSKY9X) #elif defined(PCBSKY9X)
#define EEPROM_VER 216 #define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER 215
#elif defined(CPUM2560) || defined(CPUM2561) #elif defined(CPUM2560) || defined(CPUM2561)
#define EEPROM_VER 216 #define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER EEPROM_VER
#elif defined(CPUM128) #elif defined(CPUM128)
#define EEPROM_VER 216 #define EEPROM_VER 216
#else #else
#define EEPROM_VER 216 #define EEPROM_VER 216
#endif #endif
#ifndef PACK #ifndef PACK