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:
Peter Feerick
2023-07-30 12:03:24 +10:00
committed by GitHub
co-authored by Michael
parent 9e7a331fa6
commit 2450db470d
27 changed files with 158 additions and 33 deletions
+16 -4
View File
@@ -19,6 +19,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "popups.h"
#include "libopenui.h"
#include "pwr.h"
@@ -30,10 +31,12 @@ static void _run_popup_dialog(const char* title, const char* msg,
{
bool running = true;
resetBacklightTimeout();
// reset input devices to avoid
// RELEASED/CLICKED to be called in a loop
lv_indev_reset(nullptr, nullptr);
auto md = new MessageDialog(MainWindow::instance(), title, msg);
md->setCloseHandler([&]() { running = false; });
if (info) {
@@ -53,6 +56,8 @@ static void _run_popup_dialog(const char* title, const char* msg,
RTOS_WAIT_MS(1);
continue;
}
checkBacklight();
WDG_RESET();
MainWindow::instance()->run();
LvglWrapper::runNested();
@@ -84,8 +89,12 @@ void show_ui_popup()
}
}
void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info)
void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info, bool waitForClose)
{
// if already in a popup, and we don't want to wait, ignore call
if (!waitForClose && ui_popup_active)
return;
// Wait in case already in popup.
while (ui_popup_active) {
RTOS_WAIT_MS(20);
@@ -94,8 +103,11 @@ void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info)
ui_popup_msg = message;
ui_popup_info = info;
ui_popup_active = true;
// Wait until closed
while (ui_popup_active) {
RTOS_WAIT_MS(20);
if (waitForClose) {
while (ui_popup_active) {
RTOS_WAIT_MS(20);
}
}
}
+1 -1
View File
@@ -27,6 +27,6 @@ typedef std::function<void(const char *, const char *, int, int)> ProgressHandle
void POPUP_INFORMATION(const char * message);
void POPUP_WARNING(const char * message, const char * info = nullptr);
void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info = nullptr);
void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info = nullptr, bool waitForClose = true);
void show_ui_popup();
+3 -3
View File
@@ -176,15 +176,15 @@ void runPopupWarning(event_t event)
return;
case WARNING_TYPE_INFO:
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH+2, STR_OK);
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+4*FH+2, STR_OK);
break;
case WARNING_TYPE_ASTERISK:
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH+2, BUTTON(TR_EXIT));
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+4*FH+2, BUTTON(TR_EXIT));
break;
default:
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH+2, STR_POPUPS_ENTER_EXIT);
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+4*FH+2, STR_POPUPS_ENTER_EXIT);
break;
}
+4 -2
View File
@@ -74,7 +74,7 @@ enum
#if !defined(GUI)
#define DISPLAY_WARNING(...)
inline void POPUP_WAIT(const char * s) { }
inline void POPUP_WARNING(const char *, const char * = nullptr) { }
inline void POPUP_WARNING(const char *, const char * = nullptr, bool waitForClose) { }
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler) { }
inline void POPUP_INPUT(const char * s, PopupFunc func) { }
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags) { }
@@ -105,8 +105,10 @@ enum
popupFunc = runPopupWarning;
}
inline void POPUP_WARNING(const char * message, const char * info = nullptr)
inline void POPUP_WARNING(const char * message, const char * info = nullptr, bool waitForClose = true)
{
(void)waitForClose;
warningText = message;
warningInfoText = info;
warningInfoLength = info ? strlen(info) : 0;
+5
View File
@@ -56,6 +56,11 @@ const char * writeScreenshot()
UINT written;
char filename[42]; // /SCREENSHOTS/screen-2013-01-01-123540.bmp
if (IS_SDCARD_FULL()) {
POPUP_WARNING(STR_SDCARD_FULL_EXT);
return STR_SDCARD_FULL_EXT;
}
// check and create folder here
strcpy(filename, SCREENSHOTS_PATH);
const char * error = sdCheckAndCreateDirectory(filename);