Startup / shutdown refactoring

This commit is contained in:
Bertrand Songis
2019-08-16 16:12:34 +02:00
parent f7a6d44d1e
commit a611d9e10f
26 changed files with 382 additions and 268 deletions
+1 -6
View File
@@ -142,12 +142,8 @@ void lcdDrawHexNumber(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0);
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL);
#if !defined(BOOT)
#define putstime_t int32_t
void drawRtcTime(coord_t x, coord_t y, LcdFlags att=0);
void drawTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att=0);
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags=0);
void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags att=0);
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
@@ -159,7 +155,6 @@ void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
#endif // !BOOT
#define SOLID 0xff
+6 -6
View File
@@ -391,20 +391,20 @@ void drawSleepBitmap()
}
#define SHUTDOWN_CIRCLE_DIAMETER 150
void drawShutdownAnimation(uint32_t index, const char * message)
void drawShutdownAnimation(uint32_t duration, const char * message)
{
static uint32_t last_index = 0xffffffff;
static uint32_t lastDuration = 0xffffffff;
static const BitmapBuffer * shutdown = BitmapBuffer::load(getThemePath("shutdown.bmp"));
if (shutdown) {
if (index < last_index) {
if (duration < lastDuration) {
theme->drawBackground();
lcd->drawBitmap((LCD_W-shutdown->getWidth())/2, (LCD_H-shutdown->getHeight())/2, shutdown);
lcdStoreBackupBuffer();
}
else {
lcdRestoreBackupBuffer();
int quarter = index / (PWR_PRESS_SHUTDOWN_DELAY / 5);
int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5);
if (quarter >= 1) lcdDrawBitmapPattern(LCD_W/2, (LCD_H-SHUTDOWN_CIRCLE_DIAMETER)/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, 0, SHUTDOWN_CIRCLE_DIAMETER/2);
if (quarter >= 2) lcdDrawBitmapPattern(LCD_W/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER/2, SHUTDOWN_CIRCLE_DIAMETER/2);
if (quarter >= 3) lcdDrawBitmapPattern((LCD_W-SHUTDOWN_CIRCLE_DIAMETER)/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER, SHUTDOWN_CIRCLE_DIAMETER/2);
@@ -413,7 +413,7 @@ void drawShutdownAnimation(uint32_t index, const char * message)
}
else {
lcd->clear();
int quarter = index / (PWR_PRESS_SHUTDOWN_DELAY / 5);
int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5);
for (int i=1; i<=4; i++) {
if (quarter >= i) {
lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20, 20, TEXT_BGCOLOR);
@@ -422,5 +422,5 @@ void drawShutdownAnimation(uint32_t index, const char * message)
}
lcdRefresh();
last_index = index;
lastDuration = duration;
}
+2 -4
View File
@@ -28,8 +28,6 @@
#define OPTION_MENU_TITLE_BAR 0x02
#define OPTION_MENU_NO_SCROLLBAR 0x04
#define OPTION_SLIDER_INVERS INVERS
#define OPTION_SLIDER_BLINK BLINK
#define OPTION_SLIDER_VERTICAL 0x04
#define OPTION_SLIDER_EMPTY_BAR 0x08
#define OPTION_SLIDER_DBL_COLOR 0x10
@@ -68,10 +66,10 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
#endif
// Screen templates
void drawMenuTemplate(const char * title, uint8_t icon, const uint8_t * icons=NULL, uint32_t options=0);
void drawMenuTemplate(const char * title, uint8_t icon, const uint8_t * icons=nullptr, uint32_t options=0);
void drawSplash();
void drawSleepBitmap();
void drawShutdownAnimation(uint32_t index, const char * message);
void drawShutdownAnimation(uint32_t duration, const char * message);
// Main view standard widgets
void drawTopBar();