1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 00:05:17 +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
}
inline void updateProgressBar(int num, int den)
{
// TODO
}
inline void drawSleepBitmap()
{
// TODO
lcdClear();
showMessageBox(STR_SHUTDOWN);
}
#if !defined(CPUM64)

View file

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

View file

@ -1882,15 +1882,12 @@ void opentxClose(uint8_t shutdown)
logsClose();
#endif
saveTimers();
storageFlushCurrentModel();
#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);
}
#if defined(CPUARM) && !defined(REVA)
if (sessionTimer > 0) {
g_eeGeneral.globalTimer += sessionTimer;
sessionTimer = 0;
}
#endif
@ -1901,25 +1898,7 @@ void opentxClose(uint8_t shutdown)
}
#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;
storageDirty(EE_GENERAL);
storageCheck(true);

View file

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

View file

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

View file

@ -106,3 +106,29 @@ void postModelLoad(bool alarms)
SEND_FAILSAFE_1S();
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();
#endif
#if defined(COLORLCD) || defined(PCBTARANIS)
drawSleepBitmap();
#else
lcdClear();
showMessageBox(STR_SHUTDOWN);
#endif
opentxClose();
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)
#define THR_TRG_TRESHOLD 13 // approximately 10% full throttle