Tweak memory buffers

This commit is contained in:
fvanroie 2021-02-08 01:05:35 +01:00
parent 25ff9858ac
commit 97ed56456c

View File

@ -240,8 +240,6 @@ void guiCalibrate()
void guiSetup() void guiSetup()
{ {
lv_init();
/* Initialize the Virtual Device Buffers */ /* Initialize the Virtual Device Buffers */
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
/* allocate on iram (or psram ?) */ /* allocate on iram (or psram ?) */
@ -250,47 +248,47 @@ void guiSetup()
static lv_disp_buf_t disp_buf; static lv_disp_buf_t disp_buf;
static lv_color_t *guiVdbBuffer1, *guiVdbBuffer2 = NULL; static lv_color_t *guiVdbBuffer1, *guiVdbBuffer2 = NULL;
// DMA: len must be less than 32767 // DMA: len must be less than 32767
size_t guiVDBsize = 15 * 1024u; // 15 KBytes * 2 size_t guiVDBsize = 15 * 1024u; // 30 KBytes
guiVdbBuffer1 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA); guiVdbBuffer1 = (lv_color_t *)heap_caps_calloc(guiVDBsize, sizeof(lv_color_t), MALLOC_CAP_DMA);
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
// guiVdbBuffer2 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA); // guiVdbBuffer2 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA);
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize); // lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
#else #else
static lv_disp_buf_t disp_buf;
static lv_color_t * guiVdbBuffer1; static lv_color_t * guiVdbBuffer1;
size_t guiVDBsize = 16 * 1024u; // 32 KBytes * 2 size_t guiVDBsize = 16 * 1024u; // 32 KBytes
guiVdbBuffer1 =
(lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, /*MALLOC_CAP_SPIRAM |*/ MALLOC_CAP_8BIT); if(0 && psramFound()) {
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize); guiVdbBuffer1 = (lv_color_t *)ps_calloc(guiVDBsize, sizeof(lv_color_t)); // too slow for VDB
} else {
guiVdbBuffer1 = (lv_color_t *)calloc(guiVDBsize, sizeof(lv_color_t));
}
#endif #endif
// static lv_color_t * guiVdbBuffer2 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize); // static lv_color_t * guiVdbBuffer2 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize);
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize); // lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
#elif defined(ARDUINO_ARCH_ESP8266) #elif defined(ARDUINO_ARCH_ESP8266)
/* allocate on heap */ /* allocate on heap */
// static lv_disp_buf_t disp_buf;
// static lv_color_t guiVdbBuffer1[2 * 512u]; // 4 KBytes // static lv_color_t guiVdbBuffer1[2 * 512u]; // 4 KBytes
// size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]); // size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize); // lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
static lv_disp_buf_t disp_buf;
static lv_color_t * guiVdbBuffer1; static lv_color_t * guiVdbBuffer1;
size_t guiVDBsize = 2 * 512u; // 4 KBytes * 2 size_t guiVDBsize = 2 * 512u; // 4 KBytes * 2
guiVdbBuffer1 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize); guiVdbBuffer1 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize);
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
#else #else
static lv_disp_buf_t disp_buf;
static lv_color_t guiVdbBuffer1[16 * 512u]; // 16 KBytes static lv_color_t guiVdbBuffer1[16 * 512u]; // 16 KBytes
// static lv_color_t guiVdbBuffer2[16 * 512u]; // 16 KBytes // static lv_color_t guiVdbBuffer2[16 * 512u]; // 16 KBytes
size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]); size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize); // lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
#endif #endif
/* Initialize PNG decoder */ if(!guiVdbBuffer1) {
#if HASP_USE_PNGDECODE > 0 Log.error(TAG_GUI, F("Gram out of memory"));
png_decoder_init(); }
#endif
static lv_disp_buf_t disp_buf;
lv_init();
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
/* Initialize Filesystems */ /* Initialize Filesystems */
#if LV_USE_FS_IF != 0 #if LV_USE_FS_IF != 0
@ -298,6 +296,11 @@ void guiSetup()
lv_fs_if_init(); // auxilary file system drivers lv_fs_if_init(); // auxilary file system drivers
#endif #endif
/* Initialize PNG decoder */
#if HASP_USE_PNGDECODE > 0
png_decoder_init();
#endif
#ifdef USE_DMA_TO_TFT #ifdef USE_DMA_TO_TFT
Log.verbose(TAG_GUI, F("DMA : ENABLED")); Log.verbose(TAG_GUI, F("DMA : ENABLED"));
#else #else
@ -327,7 +330,7 @@ void guiSetup()
#if LV_USE_LOG != 0 #if LV_USE_LOG != 0
Log.notice(TAG_LVGL, F("Registering lvgl logging handler")); Log.notice(TAG_LVGL, F("Registering lvgl logging handler"));
lv_log_register_print_cb(debugLvglLogEvent); /* register print function for debugging */ lv_log_register_print_cb(debugLvglLogEvent);
#endif #endif
/* Initialize the display driver */ /* Initialize the display driver */
@ -400,13 +403,14 @@ void guiSetup()
// guiStart(); // Ticker // guiStart(); // Ticker
} }
void IRAM_ATTR guiLoop(void) void guiLoop(void)
{ {
lv_task_handler(); // process animations
#if defined(STM32F4xx) #if defined(STM32F4xx)
// tick.update(); // tick.update();
#endif #endif
lv_task_handler(); // process animations
drv_touch_loop(); // update touch
} }
void guiEverySecond(void) void guiEverySecond(void)