More decent shutdown animation

This commit is contained in:
Raphael Coeffic
2021-06-11 13:34:51 +02:00
parent ff4776b40d
commit 66eda14cc4
2 changed files with 19 additions and 15 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 14 KiB

+19 -15
View File
@@ -74,25 +74,27 @@ void drawValueOrGVar(BitmapBuffer * dc, coord_t x, coord_t y, gvar_t value, gvar
} }
} }
constexpr LcdFlags splash_background_color =
COLOR2FLAGS(((0xC >> 3) << 11) | ((0x3F >> 2) << 5) | (0x66 >> 3));
void drawSleepBitmap() void drawSleepBitmap()
{ {
lcd->reset(); lcd->reset();
lcd->clear(); lcd->clear();
const BitmapBuffer * bitmap = BitmapBuffer::loadBitmap(OpenTxTheme::instance()->getFilePath("sleep.bmp")); const BitmapBuffer* bitmap = OpenTxTheme::instance()->shutdown;
if (bitmap) { if (bitmap) {
lcd->drawBitmap((LCD_W-bitmap->width())/2, (LCD_H-bitmap->height())/2, bitmap); lcd->drawMask((LCD_W-bitmap->width())/2, (LCD_H-bitmap->height())/2,
delete bitmap; bitmap, splash_background_color);
} }
lcdRefresh(); lcdRefresh();
} }
//
// TODO: move shutdown animation to Theme
//
#define SHUTDOWN_CIRCLE_DIAMETER 150 #define SHUTDOWN_CIRCLE_DIAMETER 150
void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message)
void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration,
const char* message)
{ {
if (totalDuration == 0) if (totalDuration == 0)
return; return;
@@ -100,38 +102,40 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char
static const BitmapBuffer * shutdown = OpenTxTheme::instance()->shutdown; static const BitmapBuffer * shutdown = OpenTxTheme::instance()->shutdown;
lcd->reset(); lcd->reset();
lcd->clear(splash_background_color);
if (shutdown) { if (shutdown) {
OpenTxTheme::instance()->drawBackground(lcd);
lcd->drawMask((LCD_W - shutdown->width()) / 2, lcd->drawMask((LCD_W - shutdown->width()) / 2,
(LCD_H - shutdown->height()) / 2, shutdown, DEFAULT_COLOR); (LCD_H - shutdown->height()) / 2, shutdown,
COLOR2FLAGS(WHITE));
int quarter = duration / (totalDuration / 5); int quarter = duration / (totalDuration / 5);
if (quarter >= 1) if (quarter >= 1)
lcd->drawBitmapPattern(LCD_W / 2, (LCD_H - SHUTDOWN_CIRCLE_DIAMETER) / 2, lcd->drawBitmapPattern(LCD_W / 2, (LCD_H - SHUTDOWN_CIRCLE_DIAMETER) / 2,
LBM_SHUTDOWN_CIRCLE, DEFAULT_COLOR, 0, LBM_SHUTDOWN_CIRCLE, COLOR2FLAGS(WHITE), 0,
SHUTDOWN_CIRCLE_DIAMETER / 2); SHUTDOWN_CIRCLE_DIAMETER / 2);
if (quarter >= 2) if (quarter >= 2)
lcd->drawBitmapPattern(LCD_W / 2, LCD_H / 2, LBM_SHUTDOWN_CIRCLE, lcd->drawBitmapPattern(LCD_W / 2, LCD_H / 2, LBM_SHUTDOWN_CIRCLE,
DEFAULT_COLOR, SHUTDOWN_CIRCLE_DIAMETER / 2, COLOR2FLAGS(WHITE), SHUTDOWN_CIRCLE_DIAMETER / 2,
SHUTDOWN_CIRCLE_DIAMETER / 2); SHUTDOWN_CIRCLE_DIAMETER / 2);
if (quarter >= 3) if (quarter >= 3)
lcd->drawBitmapPattern((LCD_W - SHUTDOWN_CIRCLE_DIAMETER) / 2, LCD_H / 2, lcd->drawBitmapPattern((LCD_W - SHUTDOWN_CIRCLE_DIAMETER) / 2, LCD_H / 2,
LBM_SHUTDOWN_CIRCLE, DEFAULT_COLOR, LBM_SHUTDOWN_CIRCLE, COLOR2FLAGS(WHITE),
SHUTDOWN_CIRCLE_DIAMETER, SHUTDOWN_CIRCLE_DIAMETER,
SHUTDOWN_CIRCLE_DIAMETER / 2); SHUTDOWN_CIRCLE_DIAMETER / 2);
if (quarter >= 4) if (quarter >= 4)
lcd->drawBitmapPattern((LCD_W - SHUTDOWN_CIRCLE_DIAMETER) / 2, lcd->drawBitmapPattern((LCD_W - SHUTDOWN_CIRCLE_DIAMETER) / 2,
(LCD_H - SHUTDOWN_CIRCLE_DIAMETER) / 2, (LCD_H - SHUTDOWN_CIRCLE_DIAMETER) / 2,
LBM_SHUTDOWN_CIRCLE, DEFAULT_COLOR, LBM_SHUTDOWN_CIRCLE, COLOR2FLAGS(WHITE),
SHUTDOWN_CIRCLE_DIAMETER * 3 / 2, SHUTDOWN_CIRCLE_DIAMETER * 3 / 2,
SHUTDOWN_CIRCLE_DIAMETER / 2); SHUTDOWN_CIRCLE_DIAMETER / 2);
} else { } else {
lcd->clear(); //lcd->clear();
int quarter = duration / (totalDuration / 5); int quarter = duration / (totalDuration / 5);
for (int i = 1; i <= 4; i++) { for (int i = 1; i <= 4; i++) {
if (quarter >= i) { if (quarter >= i) {
lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20, lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20,
20, DEFAULT_BGCOLOR); 20, COLOR2FLAGS(WHITE));
} }
} }
} }