@@ -1817,8 +1817,7 @@ void opentxInit()
|
||||
#endif
|
||||
|
||||
#if defined(EEPROM)
|
||||
storageClearRadioSetting();
|
||||
storageReadRadioSettings(false);
|
||||
bool radioSettingsValid = storageReadRadioSettings(false);
|
||||
#endif
|
||||
|
||||
BACKLIGHT_ENABLE(); // we start the backlight during the startup animation
|
||||
@@ -1877,7 +1876,8 @@ void opentxInit()
|
||||
#endif
|
||||
|
||||
#if defined(EEPROM)
|
||||
storageReadRadioSettings(true);
|
||||
if (!radioSettingsValid)
|
||||
storageReadRadioSettings();
|
||||
storageReadCurrentModel();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -86,17 +86,18 @@ void eeLoadModelHeaders()
|
||||
}
|
||||
}
|
||||
|
||||
void storageClearRadioSetting()
|
||||
void storageClearRadioSettings()
|
||||
{
|
||||
memclear(&g_eeGeneral, sizeof(RadioData));
|
||||
}
|
||||
|
||||
void storageReadRadioSettings(bool allowConversion)
|
||||
bool storageReadRadioSettings(bool allowFixes)
|
||||
{
|
||||
if (g_eeGeneral.version != 0)
|
||||
return;
|
||||
|
||||
if (!eepromOpen() || !eeLoadGeneral(allowConversion)) {
|
||||
if (!eepromOpen() || !eeLoadGeneral(allowFixes)) {
|
||||
if (!allowFixes) {
|
||||
storageClearRadioSettings();
|
||||
return false;
|
||||
}
|
||||
storageEraseAll(true);
|
||||
}
|
||||
else {
|
||||
@@ -109,6 +110,8 @@ void storageReadRadioSettings(bool allowConversion)
|
||||
currentLanguagePack = languagePacks[i];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void storageReadCurrentModel()
|
||||
@@ -118,7 +121,7 @@ void storageReadCurrentModel()
|
||||
|
||||
void storageReadAll()
|
||||
{
|
||||
storageReadRadioSettings(true);
|
||||
storageReadRadioSettings();
|
||||
storageReadCurrentModel();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ void eeLoadModel(uint8_t id);
|
||||
uint8_t eeFindEmptyModel(uint8_t id, bool down);
|
||||
void selectModel(uint8_t sub);
|
||||
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
void eeLoadModelHeader(uint8_t id, ModelHeader *header);
|
||||
void eeLoadModelHeaders();
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
void eeLoadModelHeader(uint8_t id, ModelHeader *header);
|
||||
void eeLoadModelHeaders();
|
||||
|
||||
void storageClearRadioSetting();
|
||||
void storageReadRadioSettings(bool allowConversion);
|
||||
void storageClearRadioSettings();
|
||||
bool storageReadRadioSettings(bool allowFixes = true);
|
||||
void storageReadCurrentModel();
|
||||
|
||||
|
||||
@@ -256,21 +256,17 @@ void writeModel(int index)
|
||||
writeFile(index+1, (uint8_t *)&g_model, sizeof(g_model));
|
||||
}
|
||||
|
||||
bool eeLoadGeneral(bool allowConversion)
|
||||
bool eeLoadGeneral(bool allowFixes)
|
||||
{
|
||||
eeLoadGeneralSettingsData();
|
||||
|
||||
if (g_eeGeneral.version != EEPROM_VER) {
|
||||
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
|
||||
#if defined(PCBSKY9X)
|
||||
if (!allowConversion) {
|
||||
storageClearRadioSetting();
|
||||
return true; // prevent eeprom from being wiped
|
||||
}
|
||||
|
||||
if (!eeConvert()) {
|
||||
if (!allowFixes)
|
||||
return false; // prevent eeprom from being wiped
|
||||
if (!eeConvert())
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool eeLoadGeneral(bool allowConversion);
|
||||
bool eeLoadGeneral(bool allowFixes);
|
||||
void eeDeleteModel( uint8_t id );
|
||||
bool eeCopyModel(uint8_t dst, uint8_t src);
|
||||
void eeSwapModels(uint8_t id1, uint8_t id2);
|
||||
|
||||
@@ -757,7 +757,7 @@ uint16_t eeLoadModelData(uint8_t index)
|
||||
return theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
|
||||
}
|
||||
|
||||
bool eeLoadGeneral(bool allowConversion)
|
||||
bool eeLoadGeneral(bool allowFixes)
|
||||
{
|
||||
theFile.openRlc(FILE_GENERAL);
|
||||
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 3) == 3 && g_eeGeneral.version == EEPROM_VER) {
|
||||
@@ -794,16 +794,14 @@ bool eeLoadGeneral(bool allowConversion)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(EEPROM_CONVERSIONS)
|
||||
if (g_eeGeneral.version != EEPROM_VER) {
|
||||
if (!allowConversion) {
|
||||
storageClearRadioSetting();
|
||||
return true; // prevent eeprom from being wiped
|
||||
}
|
||||
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
|
||||
if (!eeConvert()) {
|
||||
if (!allowFixes)
|
||||
return false; // prevent eeprom from being wiped
|
||||
if (!eeConvert())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
|
||||
@@ -180,7 +180,7 @@ void loadModel(int index, bool alarms=true);
|
||||
|
||||
bool eepromOpen();
|
||||
void eeLoadModelName(uint8_t id, char * name);
|
||||
bool eeLoadGeneral(bool allowConversion);
|
||||
bool eeLoadGeneral(bool allowFixes);
|
||||
|
||||
// For EEPROM backup/restore
|
||||
inline bool isEepromStart(const void * buffer)
|
||||
|
||||
Reference in New Issue
Block a user