From 81bd236577cd960544d7b7ede5d1ad1273b420a0 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 11 Feb 2024 08:51:24 +0000 Subject: [PATCH] Revert "Delay save settings to prevent ESC lockup on emergency rearm" --- src/main/cms/cms.c | 2 +- src/main/fc/config.c | 29 +++++++---------------------- src/main/fc/config.h | 2 +- src/main/fc/fc_core.c | 11 ++++------- src/main/fc/fc_core.h | 1 - src/main/io/osd.c | 39 +++++++++------------------------------ src/main/io/osd.h | 3 --- 7 files changed, 22 insertions(+), 65 deletions(-) diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index f2f66476e4d..a32ab0af886 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -902,7 +902,7 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr) setServoOutputEnabled(true); if ((exitType == CMS_EXIT_SAVEREBOOT) || (exitType == CMS_POPUP_SAVEREBOOT)) { - processDelayedSave(true); + processDelayedSave(); displayClearScreen(pDisplay); displayWrite(pDisplay, 5, 3, "REBOOTING..."); diff --git a/src/main/fc/config.c b/src/main/fc/config.c index ea8e0d509d4..52cb06f81a6 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -68,7 +68,6 @@ #include "fc/config.h" #include "fc/controlrate_profile.h" -#include "fc/fc_core.h" #include "fc/rc_adjustments.h" #include "fc/rc_controls.h" #include "fc/rc_curves.h" @@ -397,30 +396,16 @@ void saveConfig(void) } } -void processDelayedSave(bool readyToSave) +void processDelayedSave(void) { if (saveState == SAVESTATE_SAVEANDNOTIFY) { - if (emergInflightRearmEnabled() || !readyToSave) { - // Do not process save if we are potentially still flying. Once armed, this function will not be called until the next disarm. -#ifdef USE_OSD - osdSaveWaitingProcess(); -#endif - } else { -#ifdef USE_OSD - osdStartedSaveProcess(); -#endif - if (readyToSave) { - processSaveConfigAndNotify(); - saveState = SAVESTATE_NONE; - } - } + processSaveConfigAndNotify(); + saveState = SAVESTATE_NONE; } else if (saveState == SAVESTATE_SAVEONLY) { - if (readyToSave) { - suspendRxSignal(); - writeEEPROM(); - resumeRxSignal(); - saveState = SAVESTATE_NONE; - } + suspendRxSignal(); + writeEEPROM(); + resumeRxSignal(); + saveState = SAVESTATE_NONE; } } diff --git a/src/main/fc/config.h b/src/main/fc/config.h index 00ffe36e044..bafa5c0cbe0 100644 --- a/src/main/fc/config.h +++ b/src/main/fc/config.h @@ -124,7 +124,7 @@ void resetEEPROM(void); void readEEPROM(void); void writeEEPROM(void); void ensureEEPROMContainsValidData(void); -void processDelayedSave(bool readyToSave); +void processDelayedSave(void); void saveConfig(void); void saveConfigAndNotify(void); diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index 470d9c11aae..a61204dee90 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -65,7 +65,6 @@ #include "io/beeper.h" #include "io/dashboard.h" #include "io/gps.h" -#include "io/osd.h" #include "io/serial.h" #include "io/statusindicator.h" #include "io/asyncfatfs/asyncfatfs.h" @@ -895,15 +894,13 @@ void taskMainPidLoop(timeUs_t currentTimeUs) if (!ARMING_FLAG(ARMED)) { armTime = 0; - // Delay saving for 0.5s to allow other functions to finish processing data to be stored on disarm - processDelayedSave((currentTimeUs - lastDisarmTimeUs > USECS_PER_SEC / 2)); + // Delay saving for 0.5s to allow other functions to process save actions on disarm + if (currentTimeUs - lastDisarmTimeUs > USECS_PER_SEC / 2) { + processDelayedSave(); + } } if (armTime > 1 * USECS_PER_SEC) { // reset in flight emerg rearm flag 1 sec after arming once it's served its purpose -#ifdef USE_OSD - if (STATE(IN_FLIGHT_EMERG_REARM)) - osdSaveProcessAborted(); -#endif DISABLE_STATE(IN_FLIGHT_EMERG_REARM); } diff --git a/src/main/fc/fc_core.h b/src/main/fc/fc_core.h index 573ae31bc4d..c66a0050ba2 100644 --- a/src/main/fc/fc_core.h +++ b/src/main/fc/fc_core.h @@ -43,7 +43,6 @@ void tryArm(void); disarmReason_t getDisarmReason(void); bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm); -bool emergInflightRearmEnabled(void); bool areSensorsCalibrating(void); float getFlightTime(void); diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 70e8f524456..02d0e02a803 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -155,16 +155,8 @@ #define OSD_MIN_FONT_VERSION 3 static timeMs_t linearDescentMessageMs = 0; - -typedef enum { - OSD_SAVE_MESSAGE_NONE, - OSD_SAVE_MESSAGE_WAITING, - OSD_SAVE_MESSAGE_SAVING, - OSD_SAVE_MESSAGE_SAVED -} osd_saveMessage_e; - static timeMs_t notify_settings_saved = 0; -static uint8_t savingSettings = OSD_SAVE_MESSAGE_NONE; +static bool savingSettings = false; static unsigned currentLayout = 0; static int layoutOverride = -1; @@ -220,24 +212,17 @@ static bool osdDisplayHasCanvas; PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 9); PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 1); -void osdSaveProcessAborted(void) { - notify_settings_saved = 0; - savingSettings = OSD_SAVE_MESSAGE_NONE; -} - -void osdSaveWaitingProcess(void) { - savingSettings = OSD_SAVE_MESSAGE_WAITING; -} - void osdStartedSaveProcess(void) { - savingSettings = OSD_SAVE_MESSAGE_SAVING; + savingSettings = true; } void osdShowEEPROMSavedNotification(void) { - savingSettings = OSD_SAVE_MESSAGE_SAVED; + savingSettings = false; notify_settings_saved = millis() + 5000; } + + bool osdDisplayIsPAL(void) { return displayScreenSize(osdDisplayPort) == VIDEO_BUFFER_CHARS_PAL; @@ -4549,15 +4534,12 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); } - if (savingSettings == OSD_SAVE_MESSAGE_SAVING) { + if (savingSettings == true) { displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); - } else if (savingSettings == OSD_SAVE_MESSAGE_WAITING) { - displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_WAITING_TO_SAVE)); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; - savingSettings = OSD_SAVE_MESSAGE_NONE; - } else if (savingSettings == OSD_SAVE_MESSAGE_SAVED) { + } else { displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SETTINGS_SAVED)); } } @@ -5283,15 +5265,12 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter /* Messages that are shown regardless of Arming state */ - if (savingSettings == OSD_SAVE_MESSAGE_SAVING) { + if (savingSettings == true) { messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS); - } else if (savingSettings == OSD_SAVE_MESSAGE_WAITING) { - messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_WAITING_TO_SAVE); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; - savingSettings = OSD_SAVE_MESSAGE_NONE; - } else if (savingSettings == OSD_SAVE_MESSAGE_SAVED) { + } else { messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_SETTINGS_SAVED); } } diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 5f444ad4543..5bcf6d34740 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -119,7 +119,6 @@ #define OSD_MSG_UNABLE_ARM "UNABLE TO ARM" #define OSD_MSG_SAVING_SETTNGS "** SAVING SETTINGS **" #define OSD_MSG_SETTINGS_SAVED "** SETTINGS SAVED **" -#define OSD_MSG_WAITING_TO_SAVE "** WAITING TO SAVE **" #define OSD_MSG_ANGLEHOLD_ROLL "(ANGLEHOLD ROLL)" #define OSD_MSG_ANGLEHOLD_PITCH "(ANGLEHOLD PITCH)" #define OSD_MSG_ANGLEHOLD_LEVEL "(ANGLEHOLD LEVEL)" @@ -487,8 +486,6 @@ int32_t osdGetAltitude(void); bool osdUsingScaledThrottle(void); -void osdSaveProcessAborted(void); -void osdSaveWaitingProcess(void); void osdStartedSaveProcess(void); void osdShowEEPROMSavedNotification(void);