fix fatal error screens with LVGL
This commit is contained in:
committed by
Raphael Coeffic
parent
40641e5787
commit
809480bc6a
@@ -22,6 +22,7 @@
|
|||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "theme_manager.h"
|
#include "theme_manager.h"
|
||||||
|
#include "libopenui.h"
|
||||||
|
|
||||||
coord_t drawStringWithIndex(BitmapBuffer * dc, coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix)
|
coord_t drawStringWithIndex(BitmapBuffer * dc, coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix)
|
||||||
{
|
{
|
||||||
@@ -124,6 +125,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration,
|
|||||||
static const BitmapBuffer* shutdown = OpenTxTheme::instance()->shutdown;
|
static const BitmapBuffer* shutdown = OpenTxTheme::instance()->shutdown;
|
||||||
|
|
||||||
lcd->reset();
|
lcd->reset();
|
||||||
|
lcdInitDirectDrawing();
|
||||||
lcd->clear(bgColor);
|
lcd->clear(bgColor);
|
||||||
|
|
||||||
if (shutdown) {
|
if (shutdown) {
|
||||||
@@ -163,21 +165,71 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration,
|
|||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class FatalErrorScreen: public FormGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FatalErrorScreen(const std::string& message):
|
||||||
|
FormGroup(MainWindow::instance(), {0, 0, LCD_W, LCD_H}, OPAQUE | FORM_NO_BORDER),
|
||||||
|
message(std::move(message))
|
||||||
|
{
|
||||||
|
Layer::push(this);
|
||||||
|
bringToTop();
|
||||||
|
setFocus(SET_FOCUS_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DEBUG_WINDOWS)
|
||||||
|
std::string getName() const override
|
||||||
|
{
|
||||||
|
return "FatalErrorScreen";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
void paint(BitmapBuffer * dc) override
|
||||||
|
{
|
||||||
|
dc->clear(COLOR2FLAGS(BLACK));
|
||||||
|
dc->drawText(LCD_W/2, LCD_H/2-20, message.c_str(), FONT(XL)|CENTERED|COLOR2FLAGS(WHITE));
|
||||||
|
}
|
||||||
|
void deleteLater(bool detach = true, bool trash = true) override
|
||||||
|
{
|
||||||
|
Layer::pop(this);
|
||||||
|
Window::deleteLater(detach, trash);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string message;
|
||||||
|
bool running = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
static FatalErrorScreen *errorScreen = nullptr;
|
||||||
|
|
||||||
void drawFatalErrorScreen(const char * message)
|
void drawFatalErrorScreen(const char * message)
|
||||||
{
|
{
|
||||||
lcd->reset();
|
if(!errorScreen)
|
||||||
lcd->clear(COLOR2FLAGS(BLACK));
|
{
|
||||||
lcd->drawText(LCD_W/2, LCD_H/2-20, message, FONT(XL)|CENTERED|COLOR2FLAGS(WHITE));
|
errorScreen = new FatalErrorScreen(message);
|
||||||
|
}
|
||||||
WDG_RESET();
|
RTOS_WAIT_MS(1);
|
||||||
lcdRefresh();
|
MainWindow::instance()->run(false);
|
||||||
|
LvglWrapper::instance()->run();
|
||||||
|
}
|
||||||
|
void clearFatalErrorScreen()
|
||||||
|
{
|
||||||
|
errorScreen->deleteLater();
|
||||||
|
errorScreen = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void runFatalErrorScreen(const char * message)
|
void runFatalErrorScreen(const char * message)
|
||||||
{
|
{
|
||||||
|
lcdInitDisplayDriver();
|
||||||
while (true) {
|
while (true) {
|
||||||
backlightEnable(100);
|
backlightEnable(100);
|
||||||
drawFatalErrorScreen(message);
|
lcd->reset();
|
||||||
|
lcdInitDirectDrawing();
|
||||||
|
lcd->clear(COLOR2FLAGS(BLACK));
|
||||||
|
lcd->drawText(LCD_W/2, LCD_H/2-20, message, FONT(XL)|CENTERED|COLOR2FLAGS(WHITE));
|
||||||
|
|
||||||
|
WDG_RESET();
|
||||||
|
lcdRefresh();
|
||||||
|
|
||||||
uint8_t refresh = false;
|
uint8_t refresh = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
coord_t drawStringWithIndex(BitmapBuffer * dc, coord_t x, coord_t y, const char * str, int idx, LcdFlags flags = 0, const char * prefix = nullptr, const char * suffix = nullptr);
|
coord_t drawStringWithIndex(BitmapBuffer * dc, coord_t x, coord_t y, const char * str, int idx, LcdFlags flags = 0, const char * prefix = nullptr, const char * suffix = nullptr);
|
||||||
void drawFatalErrorScreen(const char * message);
|
void drawFatalErrorScreen(const char * message);
|
||||||
|
void clearFatalErrorScreen();
|
||||||
void runFatalErrorScreen(const char * message);
|
void runFatalErrorScreen(const char * message);
|
||||||
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att);
|
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att);
|
||||||
void drawSource(BitmapBuffer * dc, coord_t x, coord_t y, mixsrc_t idx, LcdFlags flags=0);
|
void drawSource(BitmapBuffer * dc, coord_t x, coord_t y, mixsrc_t idx, LcdFlags flags=0);
|
||||||
|
|||||||
+12
-1
@@ -488,7 +488,7 @@ void guiMain(event_t evt)
|
|||||||
void perMain()
|
void perMain()
|
||||||
{
|
{
|
||||||
DEBUG_TIMER_START(debugTimerPerMain1);
|
DEBUG_TIMER_START(debugTimerPerMain1);
|
||||||
|
static bool fatalError = false;
|
||||||
|
|
||||||
checkSpeakerVolume();
|
checkSpeakerVolume();
|
||||||
|
|
||||||
@@ -521,6 +521,7 @@ void perMain()
|
|||||||
|
|
||||||
#if defined(RTC_BACKUP_RAM)
|
#if defined(RTC_BACKUP_RAM)
|
||||||
if (globalData.unexpectedShutdown) {
|
if (globalData.unexpectedShutdown) {
|
||||||
|
fatalError = true;
|
||||||
drawFatalErrorScreen(STR_EMERGENCY_MODE);
|
drawFatalErrorScreen(STR_EMERGENCY_MODE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -538,12 +539,22 @@ void perMain()
|
|||||||
|
|
||||||
// TODO: implement for b/w
|
// TODO: implement for b/w
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
|
fatalError = true;
|
||||||
drawFatalErrorScreen(STR_NO_SDCARD);
|
drawFatalErrorScreen(STR_NO_SDCARD);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(LIBOPENUI)
|
||||||
|
if(fatalError)
|
||||||
|
{
|
||||||
|
clearFatalErrorScreen();
|
||||||
|
fatalError = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (usbPlugged() && getSelectedUsbMode() == USB_MASS_STORAGE_MODE) {
|
if (usbPlugged() && getSelectedUsbMode() == USB_MASS_STORAGE_MODE) {
|
||||||
#if defined(LIBOPENUI)
|
#if defined(LIBOPENUI)
|
||||||
// draw some image showing USB
|
// draw some image showing USB
|
||||||
|
|||||||
Reference in New Issue
Block a user