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:
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.6 KiB |
Executable
BIN
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 |
@@ -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);
|
||||
|
||||
@@ -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++) {
|
||||
uint8_t *p = &displayBuf[(row + (y/2)) * LCD_W + x];
|
||||
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);
|
||||
if (overlay) {
|
||||
for (coord_t i=0; i<width; i++) {
|
||||
if (p >= DISPLAY_END) return;
|
||||
uint8_t b = pic.getNext();
|
||||
if (y & 1) {
|
||||
if (b & 0x0f)
|
||||
*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 {
|
||||
*p = b;
|
||||
} else {
|
||||
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.skip(offset);
|
||||
|
||||
@@ -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 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)
|
||||
|
||||
|
||||
|
||||
@@ -22,8 +22,14 @@
|
||||
#include "opentx.h"
|
||||
|
||||
|
||||
#define ANIMATIONS_BITMAP_WIDTH 60
|
||||
#define ANIMATIONS_BITMAP_HEIGHT 60
|
||||
#define ANIMATIONS_BITMAP_WIDTH 30
|
||||
#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[] = {
|
||||
@@ -33,11 +39,28 @@ const unsigned char bmp_lock[] = {
|
||||
const unsigned char bmp_shutdown[] = {
|
||||
#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[] = {
|
||||
#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)
|
||||
{
|
||||
if (totalDuration == 0)
|
||||
@@ -49,9 +72,9 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration)
|
||||
lcdClear();
|
||||
|
||||
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
|
||||
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();
|
||||
}
|
||||
@@ -66,7 +89,8 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char
|
||||
lcdRefreshWait();
|
||||
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) {
|
||||
lcdDrawText((LCD_W - getTextWidth(message)) / 2, LCD_H - 2*FH, message);
|
||||
}
|
||||
@@ -78,7 +102,7 @@ void drawSleepBitmap()
|
||||
{
|
||||
lcdRefreshWait();
|
||||
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();
|
||||
lcdRefreshWait();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user