1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-22 15:55:26 +03:00

[ARM boards] Model persistent timers / telemetry / pots positions were not always correctly saved

This commit is contained in:
Bertrand Songis 2016-09-13 18:35:03 +02:00
parent 4a88d3477d
commit 2b32abe467
8 changed files with 40 additions and 45 deletions

View file

@ -425,13 +425,16 @@ inline void drawProgressBar(const char * label)
{ {
// TODO // TODO
} }
inline void updateProgressBar(int num, int den) inline void updateProgressBar(int num, int den)
{ {
// TODO // TODO
} }
inline void drawSleepBitmap() inline void drawSleepBitmap()
{ {
// TODO lcdClear();
showMessageBox(STR_SHUTDOWN);
} }
#if !defined(CPUM64) #if !defined(CPUM64)

View file

@ -45,9 +45,9 @@ void drawMessageBox()
// could be a place for a warningInfoText // could be a place for a warningInfoText
} }
void showMessageBox(const pm_char * pstr) void showMessageBox(const pm_char * str)
{ {
warningText = pstr; warningText = str;
drawMessageBox(); drawMessageBox();
warningText = NULL; warningText = NULL;
lcdRefresh(); lcdRefresh();

View file

@ -1882,15 +1882,12 @@ void opentxClose(uint8_t shutdown)
logsClose(); logsClose();
#endif #endif
saveTimers(); storageFlushCurrentModel();
#if defined(CPUARM) #if defined(CPUARM) && !defined(REVA)
for (int i=0; i<MAX_TELEMETRY_SENSORS; i++) { if (sessionTimer > 0) {
TelemetrySensor & sensor = g_model.telemetrySensors[i]; g_eeGeneral.globalTimer += sessionTimer;
if (sensor.type == TELEM_TYPE_CALCULATED && sensor.persistent && sensor.persistentValue != telemetryItems[i].value) { sessionTimer = 0;
sensor.persistentValue = telemetryItems[i].value;
storageDirty(EE_MODEL);
}
} }
#endif #endif
@ -1901,25 +1898,7 @@ void opentxClose(uint8_t shutdown)
} }
#endif #endif
#if defined(PCBTARANIS)
if (g_model.potsWarnMode == POTS_WARN_AUTO) {
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
if (!(g_model.potsWarnEnabled & (1 << i))) {
SAVE_POT_POSITION(i);
}
}
storageDirty(EE_MODEL);
}
#endif
#if !defined(PCBTARANIS) && !defined(COLORLCD)
if (storageDirtyMsk & EE_MODEL) {
showMessageBox(STR_SAVEMODEL);
}
#endif
g_eeGeneral.unexpectedShutdown = 0; g_eeGeneral.unexpectedShutdown = 0;
storageDirty(EE_GENERAL); storageDirty(EE_GENERAL);
storageCheck(true); storageCheck(true);

View file

@ -71,7 +71,7 @@ void selectModel(uint8_t sub)
#if !defined(COLORLCD) #if !defined(COLORLCD)
showMessageBox(STR_LOADINGMODEL); showMessageBox(STR_LOADINGMODEL);
#endif #endif
saveTimers(); storageFlushCurrentModel();
storageCheck(true); // force writing of current model data before this is changed storageCheck(true); // force writing of current model data before this is changed
g_eeGeneral.currModel = sub; g_eeGeneral.currModel = sub;
storageDirty(EE_GENERAL); storageDirty(EE_GENERAL);

View file

@ -50,6 +50,7 @@ void storageFormat();
void storageReadAll(); void storageReadAll();
void storageDirty(uint8_t msk); void storageDirty(uint8_t msk);
void storageCheck(bool immediately); void storageCheck(bool immediately);
void storageFlushCurrentModel();
void preModelLoad(); void preModelLoad();
void postModelLoad(bool alarms); void postModelLoad(bool alarms);

View file

@ -106,3 +106,29 @@ void postModelLoad(bool alarms)
SEND_FAILSAFE_1S(); SEND_FAILSAFE_1S();
PLAY_MODEL_NAME(); PLAY_MODEL_NAME();
} }
void storageFlushCurrentModel()
{
saveTimers();
#if defined(CPUARM)
for (int i=0; i<MAX_TELEMETRY_SENSORS; i++) {
TelemetrySensor & sensor = g_model.telemetrySensors[i];
if (sensor.type == TELEM_TYPE_CALCULATED && sensor.persistent && sensor.persistentValue != telemetryItems[i].value) {
sensor.persistentValue = telemetryItems[i].value;
storageDirty(EE_MODEL);
}
}
#endif
#if defined(CPUARM)
if (g_model.potsWarnMode == POTS_WARN_AUTO) {
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
if (!(g_model.potsWarnEnabled & (1 << i))) {
SAVE_POT_POSITION(i);
}
}
storageDirty(EE_MODEL);
}
#endif
}

View file

@ -243,13 +243,7 @@ void menusTask(void * pdata)
ledOff(); ledOff();
#endif #endif
#if defined(COLORLCD) || defined(PCBTARANIS)
drawSleepBitmap(); drawSleepBitmap();
#else
lcdClear();
showMessageBox(STR_SHUTDOWN);
#endif
opentxClose(); opentxClose();
boardOff(); // Only turn power off if necessary boardOff(); // Only turn power off if necessary
} }

View file

@ -66,16 +66,8 @@ void saveTimers()
} }
} }
} }
#if defined(CPUARM) && !defined(REVA)
if (sessionTimer > 0) {
g_eeGeneral.globalTimer += sessionTimer;
storageDirty(EE_GENERAL);
sessionTimer = 0;
}
#endif
} }
#endif // #if defined(CPUARM) || defined(CPUM2560) #endif // #if defined(CPUARM) || defined(CPUM2560)
#if defined(ACCURAT_THROTTLE_TIMER) #if defined(ACCURAT_THROTTLE_TIMER)
#define THR_TRG_TRESHOLD 13 // approximately 10% full throttle #define THR_TRG_TRESHOLD 13 // approximately 10% full throttle