fix: Prevent functional degradation if SD has less than 50MB free space (#3802)
* fix: Prevent functional degradation if SD has less than 50MB free space (#3730) * justification: https://github.com/EdgeTX/edgetx/discussions/3666 - checks SD card free space at startup, start of logging and writing screenshots - issues warning to user if SD card has less than 50MB free space - will not write logs or screenshots if free space is less than 50MB at activation timerReset - fixes crash of warning popup in logs.cpp (#3728) * update: warning message if SD card fills up to threshold while logging * empty commit * call popup in non-blocking mode * make b&w compatible to non-blocking popup calls * 2nd attempt * Popup: - turns on backlight if dimmed due to inactivity setting - if backlight is dimmed due to inactivity setting backlight can turnd on again by any controls * #3599 * fixed b&w UI * updated languages CN, CZ, DA, DE, FR, HE, IT, PL, PT, SE, TW * chore: Update translations * chore: Remove magic number * chore: JP language update for SD card full (#3809) * fix: Don't spam simulator log with file close msgs --------- Co-authored-by: Michael <mha1@users.noreply.github.com>
This commit is contained in:
+24
-13
@@ -123,9 +123,6 @@ const char * logsOpen()
|
||||
if (!sdMounted())
|
||||
return STR_NO_SDCARD;
|
||||
|
||||
if (sdGetFreeSectors() == 0)
|
||||
return STR_SDCARD_FULL;
|
||||
|
||||
// check and create folder here
|
||||
strcpy(filename, STR_LOGS_PATH);
|
||||
const char * error = sdCheckAndCreateDirectory(filename);
|
||||
@@ -184,16 +181,14 @@ const char * logsOpen()
|
||||
|
||||
void logsClose()
|
||||
{
|
||||
if (sdMounted()) {
|
||||
if (g_oLogFile.obj.fs && sdMounted()) {
|
||||
if (f_close(&g_oLogFile) != FR_OK) {
|
||||
// close failed, forget file
|
||||
g_oLogFile.obj.fs = 0;
|
||||
}
|
||||
lastLogTime = 0;
|
||||
}
|
||||
#if !defined(SIMU)
|
||||
loggingTimerStop();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void writeHeader()
|
||||
@@ -285,17 +280,31 @@ void logsWrite()
|
||||
{
|
||||
#endif
|
||||
|
||||
bool sdCardFull = IS_SDCARD_FULL();
|
||||
|
||||
// check if file needs to be opened
|
||||
if (!g_oLogFile.obj.fs) {
|
||||
const char * result = logsOpen();
|
||||
const char *result = sdCardFull ? STR_SDCARD_FULL_EXT : logsOpen();
|
||||
|
||||
// SD card is full or file open failed
|
||||
if (result) {
|
||||
if (result != error_displayed) {
|
||||
error_displayed = result;
|
||||
POPUP_WARNING(result);
|
||||
POPUP_WARNING_ON_UI_TASK(result, nullptr, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check at every write cycle
|
||||
if (sdCardFull) {
|
||||
logsClose(); // timer is still running and code above will try to
|
||||
// open the file again but will fail with error
|
||||
// which will trigger the warning popup
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#if defined(RTCLOCK)
|
||||
{
|
||||
static struct gtm utm;
|
||||
@@ -383,15 +392,17 @@ void logsWrite()
|
||||
|
||||
if (result<0 && !error_displayed) {
|
||||
error_displayed = STR_SDCARD_ERROR;
|
||||
POPUP_WARNING(STR_SDCARD_ERROR);
|
||||
POPUP_WARNING_ON_UI_TASK(STR_SDCARD_ERROR, nullptr, false);
|
||||
logsClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error_displayed = nullptr;
|
||||
if (g_oLogFile.obj.fs) {
|
||||
logsClose();
|
||||
}
|
||||
logsClose();
|
||||
|
||||
#if !defined(SIMU)
|
||||
loggingTimerStop();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user