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
+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;
}