It wouldn’t bother if it didn’t run quickly and smoothly, as my application is very static anyway.
The text on the screenshots is partly in German. Here is the translation:
1.)
The sketch uses 12966 bytes (5%) of the program memory. The maximum is 253952 bytes.
Global variables use 233 bytes (2%) of dynamic memory, leaving 7959 bytes for local variables. The maximum is 8192 bytes.
2.)
The sketch uses 88122 bytes (34%) of the program memory. The maximum is 253952 bytes.
Global variables use 21851 bytes (266%) of dynamic memory, leaving -13659 bytes for local variables. The maximum is 8192 bytes.
The Code:
#include <lvgl.h>
#include <UTFT.h>
static lv_disp_buf_t disp_buf;
static lv_color_t buf[LV_HOR_RES_MAX * 10];
UTFT myGLCD(ITDB32S, 38, 39, 40, 41);
int x;
int y;
void timer_1(void)
{
if (millis() % 5 > 1) //Every 5 ms
{
lv_tick_inc(1);
}
}
void LCD_WritePixel(int x, int y, int color)
{
myGLCD.setColor(color);
myGLCD.drawPixel(x, y);
}
void setup()
{
Serial.begin(9600);
myGLCD.InitLCD();
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = 320;
disp_drv.ver_res = 240;
disp_drv.buffer = &disp_buf;
disp_drv.flush_cb = my_flush_cb;
lv_disp_t * disp;
lv_disp_drv_register(&disp_drv); /*Register the driver and save the created display objects*/
}
void my_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
int32_t x, y;
for (y = area->y1; y <= area->y2; y++) {
for (x = area->x1; x <= area->x2; x++) {
LCD_WritePixel(x, y, color_p->full);
color_p++;
}
}
/* IMPORTANT!!!
Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
void loop()
{
timer_1();
if (millis() % 5 > 1)
{
lv_task_handler();
}
}
Best regards
David