Remove scratch buffer

This commit is contained in:
Raphael Coeffic
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent b40441f0c0
commit 86152da85d
11 changed files with 97 additions and 53 deletions
+5 -4
View File
@@ -203,7 +203,7 @@ extern BitmapBuffer * lcd;
static lv_disp_drv_t disp_drv;
static lv_disp_drv_t* init_disp_drv()
void init_disp_drv()
{
lv_disp_draw_buf_init(&disp_buf, lcdFront->getData(), lcd->getData(), LCD_W*LCD_H);
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
@@ -219,7 +219,8 @@ static lv_disp_drv_t* init_disp_drv()
// disp_drv.rotated = LV_DISP_ROT_90;
disp_drv.sw_rotate = 1;
return &disp_drv;
// Register the driver and save the created display objects
disp = lv_disp_drv_register(&disp_drv);
}
static void init_lvgl_drivers()
@@ -229,7 +230,7 @@ static void init_lvgl_drivers()
lv_group_set_default(inputGroup);
// Register the driver and save the created display objects
disp = lv_disp_drv_register(init_disp_drv());
init_disp_drv();
// Register the driver in LVGL and save the created input device object
lv_indev_drv_init(&touchDriver); /*Basic initialization*/
@@ -346,7 +347,7 @@ LvglWrapper::LvglWrapper()
// Create main window and load that screen
auto window = MainWindow::instance();
lv_scr_load(window->getLvObj());
window->setActiveScreen();
}
void LvglWrapper::run()
+49 -22
View File
@@ -31,13 +31,38 @@ const uint8_t __bmp_splash_chr[] {
#include "splash_chr.lbm"
};
void draw_splash_cb(lv_event_t * e)
{
auto draw_ctx = lv_event_get_draw_ctx(e);
auto splashImg = (BitmapBuffer*)lv_event_get_user_data(e);
// lcd->clear(splash_background_color);
if (splashImg) {
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);
// TODO: center image
lv_area_t coords;
coords.x1 = 0;
coords.y1 = 0;
coords.x2 = splashImg->width()-1;
coords.y2 = splashImg->height()-1;
lv_draw_img_decoded(draw_ctx, &img_dsc, &coords,
(const uint8_t *)splashImg->getData(),
LV_IMG_CF_TRUE_COLOR);
}
}
void drawSplash()
{
constexpr LcdFlags splash_background_color =
COLOR2FLAGS(((0xC >> 3) << 11) | ((0x3F >> 2) << 5) | (0x66 >> 3));
static bool loadSplashImg = true;
static BitmapBuffer * splashImg = nullptr;
static BitmapBuffer* splashImg = nullptr;
static lv_obj_t* splashScreen = nullptr;
// try splash from SD card first
if (loadSplashImg && splashImg == nullptr) {
@@ -47,30 +72,32 @@ void drawSplash()
// otherwise load from FLASH
struct gtm t;
gettime(&t);
// Please do not spoil the suprise by discussing following lines in public
// mon == 11 == December, starts from 0!
if (t.tm_mon == 11 && t.tm_mday >= 24 && t.tm_mday <= 26)
{
if (splashImg == nullptr) {
splashImg = BitmapBuffer::loadRamBitmap(__bmp_splash_chr, sizeof(__bmp_splash_chr));
}
} else
{
if (splashImg == nullptr) {
splashImg = BitmapBuffer::loadRamBitmap(__bmp_splash, sizeof(__bmp_splash));
}
}
gettime(&t);
// Please do not spoil the suprise by discussing following lines in public
// mon == 11 == December, starts from 0!
if (t.tm_mon == 11 && t.tm_mday >= 24 && t.tm_mday <= 26) {
if (splashImg == nullptr) {
splashImg = BitmapBuffer::loadRamBitmap(__bmp_splash_chr,
sizeof(__bmp_splash_chr));
}
} else {
if (splashImg == nullptr) {
splashImg =
BitmapBuffer::loadRamBitmap(__bmp_splash, sizeof(__bmp_splash));
}
}
splashScreen = lv_obj_create(nullptr);
if (splashScreen) {
lv_obj_add_event_cb(splashScreen, draw_splash_cb, LV_EVENT_DRAW_MAIN, splashImg);
}
}
lcd->clear(splash_background_color);
if (splashImg) {
lcd->drawBitmap((LCD_W - splashImg->width())/2,
(LCD_H - splashImg->height())/2,
splashImg);
if (splashScreen) {
lv_scr_load(splashScreen);
lv_refr_now(nullptr);
}
lcdRefresh();
MainWindow::instance()->setActiveScreen();
}
#endif