chore(bw): Reduce FLASH used by 212x64 startup/shutdown animations (#3989)

* Reduce FLASH storage of startup/shutdown animation for 212x64 LCD B&W radios.

* Simplify bitmaps.

* Support drawing animation bitmaps with transparency.
This commit is contained in:
philmoz
2023-09-04 14:10:50 +10:00
committed by GitHub
parent 8be8b51813
commit 9f4997caea
6 changed files with 63 additions and 18 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

+32 -11
View File
@@ -1008,7 +1008,7 @@ void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset, co
} }
} }
void lcdDrawRleBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset, coord_t width) void lcdDrawRleBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset, coord_t width, bool overlay)
{ {
RleBitmap pic(img, offset); RleBitmap pic(img, offset);
@@ -1024,19 +1024,40 @@ void lcdDrawRleBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset,
for (uint8_t row=0; row<rows; row++) { for (uint8_t row=0; row<rows; row++) {
uint8_t *p = &displayBuf[(row + (y/2)) * LCD_W + x]; uint8_t *p = &displayBuf[(row + (y/2)) * LCD_W + x];
for (coord_t i=0; i<width; i++) { if (overlay) {
if (p >= DISPLAY_END) return; for (coord_t i=0; i<width; i++) {
uint8_t b = pic.getNext(); if (p >= DISPLAY_END) return;
if (y & 1) { uint8_t b = pic.getNext();
*p = (*p & 0x0f) + ((b & 0x0f) << 4); if (y & 1) {
if ((p+LCD_W) < DISPLAY_END) { if (b & 0x0f)
*(p+LCD_W) = (*(p+LCD_W) & 0xf0) + ((b & 0xf0) >> 4); *p = (*p & 0x0f) + ((b & 0x0f) << 4);
if ((p+LCD_W) < DISPLAY_END && b & 0xf0) {
*(p+LCD_W) = (*(p+LCD_W) & 0xf0) + ((b & 0xf0) >> 4);
}
} }
else {
if (b & 0x0f)
*p = (*p & 0xf0) + (b & 0x0f);
if (b & 0xf0)
*p = (*p & 0x0f) + (b & 0xf0);
}
p++;
} }
else { } else {
*p = b; for (coord_t i=0; i<width; i++) {
if (p >= DISPLAY_END) return;
uint8_t b = pic.getNext();
if (y & 1) {
*p = (*p & 0x0f) + ((b & 0x0f) << 4);
if ((p+LCD_W) < DISPLAY_END) {
*(p+LCD_W) = (*(p+LCD_W) & 0xf0) + ((b & 0xf0) >> 4);
}
}
else {
*p = b;
}
p++;
} }
p++;
} }
pic.goToNextRow(); pic.goToNextRow();
pic.skip(offset); pic.skip(offset);
+1 -1
View File
@@ -164,7 +164,7 @@ void drawTelemetryTopBar();
void lcdDraw1bitBitmap(coord_t x, coord_t y, const unsigned char * img, uint8_t idx, LcdFlags att=0); void lcdDraw1bitBitmap(coord_t x, coord_t y, const unsigned char * img, uint8_t idx, LcdFlags att=0);
void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_t width=0); void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_t width=0);
void lcdDrawRleBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_t width=0); void lcdDrawRleBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_t width=0, bool overlay=false);
#define LCD_ICON(x, y, icon) lcdDrawRleBitmap(x, y, icons, icon) #define LCD_ICON(x, y, icon) lcdDrawRleBitmap(x, y, icons, icon)
+30 -6
View File
@@ -22,8 +22,14 @@
#include "opentx.h" #include "opentx.h"
#define ANIMATIONS_BITMAP_WIDTH 60 #define ANIMATIONS_BITMAP_WIDTH 30
#define ANIMATIONS_BITMAP_HEIGHT 60 #define ANIMATIONS_BITMAP_HEIGHT 30
#define POWER_BITMAP_WIDTH 40
#define POWER_BITMAP_HEIGHT 40
#define SLEEP_BITMAP_WIDTH 60
#define SLEEP_BITMAP_HEIGHT 60
const unsigned char bmp_lock[] = { const unsigned char bmp_lock[] = {
@@ -33,11 +39,28 @@ const unsigned char bmp_lock[] = {
const unsigned char bmp_shutdown[] = { const unsigned char bmp_shutdown[] = {
#include "shutdown.lbm" #include "shutdown.lbm"
}; };
const int8_t bmp_shutdown_xo[] = {
0, 0, -ANIMATIONS_BITMAP_WIDTH, -ANIMATIONS_BITMAP_WIDTH
};
const int8_t bmp_shutdown_yo[] = {
-ANIMATIONS_BITMAP_HEIGHT, 0, 0, -ANIMATIONS_BITMAP_HEIGHT
};
const unsigned char bmp_power[] = {
#include "power.lbm"
};
const unsigned char bmp_sleep[] = { const unsigned char bmp_sleep[] = {
#include "sleep.lbm" #include "sleep.lbm"
}; };
static void drawAnimation(uint8_t idx)
{
lcdDrawRleBitmap((LCD_W - POWER_BITMAP_WIDTH) / 2, (LCD_H - POWER_BITMAP_HEIGHT) / 2, bmp_power);
for (uint8_t i = 0; i <=idx; i += 1)
lcdDrawRleBitmap((LCD_W / 2) + bmp_shutdown_xo[i], (LCD_H / 2) + bmp_shutdown_yo[i], bmp_shutdown, i * ANIMATIONS_BITMAP_WIDTH, ANIMATIONS_BITMAP_WIDTH, true);
}
void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) void drawStartupAnimation(uint32_t duration, uint32_t totalDuration)
{ {
if (totalDuration == 0) if (totalDuration == 0)
@@ -49,9 +72,9 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration)
lcdClear(); lcdClear();
if (index == 0) if (index == 0)
lcdDrawRleBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_lock, 0, ANIMATIONS_BITMAP_WIDTH); lcdDrawRleBitmap((LCD_W - POWER_BITMAP_WIDTH) / 2, (LCD_H - POWER_BITMAP_HEIGHT) / 2, bmp_lock);
else else
lcdDrawRleBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_shutdown, (index - 1) * ANIMATIONS_BITMAP_WIDTH, ANIMATIONS_BITMAP_WIDTH); drawAnimation(index - 1);
lcdRefresh(); lcdRefresh();
} }
@@ -66,7 +89,8 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char
lcdRefreshWait(); lcdRefreshWait();
lcdClear(); lcdClear();
lcdDrawRleBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_shutdown, (3 - index) * ANIMATIONS_BITMAP_WIDTH, ANIMATIONS_BITMAP_WIDTH); drawAnimation(3 - index);
if (message) { if (message) {
lcdDrawText((LCD_W - getTextWidth(message)) / 2, LCD_H - 2*FH, message); lcdDrawText((LCD_W - getTextWidth(message)) / 2, LCD_H - 2*FH, message);
} }
@@ -78,7 +102,7 @@ void drawSleepBitmap()
{ {
lcdRefreshWait(); lcdRefreshWait();
lcdClear(); lcdClear();
lcdDrawRleBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_sleep, 0); lcdDrawRleBitmap((LCD_W - SLEEP_BITMAP_WIDTH) / 2, (LCD_H - SLEEP_BITMAP_HEIGHT) / 2, bmp_sleep);
lcdRefresh(); lcdRefresh();
lcdRefreshWait(); lcdRefreshWait();
} }