Add hasp_use_psram and LV_VDB_SIZE

This commit is contained in:
fvanroie 2021-11-21 08:24:35 +01:00
parent 182a98644b
commit 511540efd9

View File

@ -101,51 +101,57 @@ static inline void gui_init_lvgl()
lv_log_register_print_cb(debugLvglLogEvent); lv_log_register_print_cb(debugLvglLogEvent);
#endif #endif
static lv_color_t *guiVdbBuffer1, *guiVdbBuffer2 = NULL;
/* Create the Virtual Device Buffers */ /* Create the Virtual Device Buffers */
#if defined(ARDUINO_ARCH_ESP32) // #if defined(ARDUINO_ARCH_ESP32)
//
// #ifdef USE_DMA_TO_TFT
// // DMA: len must be less than 32767
// const size_t guiVDBsize = 15 * 1024u; // 30 KBytes
// guiVdbBuffer1 = (lv_color_t*)heap_caps_calloc(guiVDBsize, sizeof(lv_color_t), 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);
// #else
// const size_t guiVDBsize = 8 * 1024u; // 32 KBytes
#ifdef USE_DMA_TO_TFT // if(0 && psramFound()) {
// DMA: len must be less than 32767 // guiVdbBuffer1 = (lv_color_t*)ps_calloc(guiVDBsize, sizeof(lv_color_t)); // too slow for VDB
const size_t guiVDBsize = 15 * 1024u; // 30 KBytes // } else {
guiVdbBuffer1 = (lv_color_t*)heap_caps_calloc(guiVDBsize, sizeof(lv_color_t), MALLOC_CAP_DMA); // guiVdbBuffer1 = (lv_color_t*)calloc(guiVDBsize, sizeof(lv_color_t));
// guiVdbBuffer2 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA); // }
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
#else
const size_t guiVDBsize = 16 * 1024u; // 32 KBytes
if(0 && psramFound()) { // #endif
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 // // static lv_color_t * guiVdbBuffer2 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize);
// // lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
// static lv_color_t * guiVdbBuffer2 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize); // #elif defined(ARDUINO_ARCH_ESP8266)
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize); // /* allocate on heap */
// // static lv_color_t guiVdbBuffer1[2 * 512u]; // 4 KBytes
// // size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
// // lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
#elif defined(ARDUINO_ARCH_ESP8266) // const size_t guiVDBsize = 2 * 512u; // 4 KBytes * 2
/* allocate on heap */ // guiVdbBuffer1 = (lv_color_t*)malloc(sizeof(lv_color_t) * guiVDBsize);
// static lv_color_t guiVdbBuffer1[2 * 512u]; // 4 KBytes
// size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
const size_t guiVDBsize = 2 * 512u; // 4 KBytes * 2 // #elif defined(WINDOWS) || defined(POSIX)
guiVdbBuffer1 = (lv_color_t*)malloc(sizeof(lv_color_t) * guiVDBsize); // const size_t guiVDBsize = LV_HOR_RES_MAX * 10;
// // static lv_color_t guiVdbBuffer1[guiVDBsize]; /*Declare a buffer for 10 lines*/
// guiVdbBuffer1 = (lv_color_t*)calloc(guiVDBsize, sizeof(lv_color_t));
#elif defined(WINDOWS) || defined(POSIX) // #else
const size_t guiVDBsize = LV_HOR_RES_MAX * 10; // static lv_color_t guiVdbBuffer1[16 * 512u]; // 16 KBytes
// static lv_color_t guiVdbBuffer1[guiVDBsize]; /*Declare a buffer for 10 lines*/ // // static lv_color_t guiVdbBuffer2[16 * 512u]; // 16 KBytes
guiVdbBuffer1 = (lv_color_t*)calloc(guiVDBsize, sizeof(lv_color_t)); // size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
// // lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
// #endif
#else /* Dynamic VDB allocation */
static lv_color_t guiVdbBuffer1[16 * 512u]; // 16 KBytes const size_t guiVDBsize = LV_VDB_SIZE / 2;
// static lv_color_t guiVdbBuffer2[16 * 512u]; // 16 KBytes static lv_color_t* guiVdbBuffer1 = (lv_color_t*)malloc(sizeof(lv_color_t) * guiVDBsize);
size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize); /* Static VDB allocation */
#endif // static lv_color_t guiVdbBuffer1[LV_VDB_SIZE * 512u];
// const size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(lv_color_t);
/* Initialize VDB */ /* Initialize VDB */
if(guiVdbBuffer1 && guiVDBsize > 0) { if(guiVdbBuffer1 && guiVDBsize > 0) {
@ -238,7 +244,7 @@ static inline void gui_init_images()
#endif #endif
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
if(psramFound()) lv_img_cache_set_size(LV_IMG_CACHE_DEF_SIZE_PSRAM); if(hasp_use_psram()) lv_img_cache_set_size(LV_IMG_CACHE_DEF_SIZE_PSRAM);
#endif #endif
} }
@ -248,7 +254,7 @@ static inline void gui_init_freetype()
// #ifdef 1 || USE_LVGL_FREETYPE // #ifdef 1 || USE_LVGL_FREETYPE
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
if(lv_freetype_init(USE_LVGL_FREETYPE_MAX_FACES, USE_LVGL_FREETYPE_MAX_SIZES, if(lv_freetype_init(USE_LVGL_FREETYPE_MAX_FACES, USE_LVGL_FREETYPE_MAX_SIZES,
psramFound() ? USE_LVGL_FREETYPE_MAX_BYTES_PSRAM : USE_LVGL_FREETYPE_MAX_BYTES)) { hasp_use_psram() ? USE_LVGL_FREETYPE_MAX_BYTES_PSRAM : USE_LVGL_FREETYPE_MAX_BYTES)) {
LOG_VERBOSE(TAG_FONT, F("FreeType v%d.%d.%d " D_SERVICE_STARTED), FREETYPE_MAJOR, FREETYPE_MINOR, LOG_VERBOSE(TAG_FONT, F("FreeType v%d.%d.%d " D_SERVICE_STARTED), FREETYPE_MAJOR, FREETYPE_MINOR,
FREETYPE_PATCH); FREETYPE_PATCH);
} else { } else {