Description
my code is getting stuck on lv_timer_handler(); and my flush callback is never getting called. There is nothing rendering on my display. I was able to get everything successfully running yesterday, but after a small change to my code everything broke, even after undoing the change ;-;
What MCU/Processor/Board and compiler are you using?
Esp32 Feather V2
Waveshape 7.5in B/W display
Arduino Ide
Currently tested with LVGL 9.2.2, 9.2.1
What do you want to achieve?
I want my code to call my_disp_flush() so that my UI will be rendered
What have you tried so far?
I don’t understand why this issue is happening, I’ve added a bunch of error checking so I have narrowed down where my issue is occuring:
Code to reproduce
Add the relevant code snippets here.
The code block(s) should be between ```c
and ```
tags:
/* Display Flush */
void my_disp_flush(lv_display_t* disp, const lv_area_t* area, uint8_t* color_p) {
Serial.println("Flush Called"); // Debugging Purposes
// Define dimensions of area being updated
uint32_t width = lv_area_get_width(area);
uint32_t height = lv_area_get_height(area);
uint16_t* color_buf16 = (uint16_t*)color_p;
// Define area being update
display.setPartialWindow(area->x1, area->y1, width, height);
// For epaper "pages" are horizontal strips that are updated sequentially to save memory/space
display.firstPage();
do {
for (uint32_t y = 0; y < height; y++) {
for (uint32_t x = 0; x < width; x++) {
uint16_t color = color_buf16[y * width + x];
uint8_t gray = ((color & 0xF800) >> 8) | // Red contribution
((color & 0x07E0) >> 3) | // Green contribution
((color & 0x001F) << 3); // Blue contribution
display.drawPixel(
area->x1 + x,
area->y1 + y,
gray < 128 ? GxEPD_BLACK : GxEPD_WHITE);
}
}
} while (display.nextPage()); // Loops until all pages are displayed
// Small delay to ensure e-paper has time to update
delay(10);
lv_disp_flush_ready(disp); // Inform lvgl that update is complete
}
/* LVGL setup */
// Initialize LVGL
lv_init();
Serial.print("Lvgl Init");
// Tick callback
lv_tick_get_cb_t tick_cb = my_tick_get_cb;
lv_tick_set_cb(tick_cb);
// Initialize Display
display.init(115200);
display.setRotation(0); // Landcape Mode
display.setPartialWindow(0, 0, screenWidth, screenHeight);
// Clear display with proper full refresh
display.setFullWindow();
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
} while (display.nextPage());
// Create LVGL display
lv_display_t* disp = lv_display_create(screenWidth, screenHeight);
if (!disp) {
Serial.println("LVGL display creation failed!");
while (1)
;
}
Serial.println("LVGL display created");
// Allocate display buffer
const int bufferHeight = screenHeight; // Reduce buffer size b/c dram is overflowing -> mem allocated reduced testing without reducing buffersize, was originally screenHeight
static lv_color_t* disp_buf = (lv_color_t*)malloc(screenWidth * bufferHeight * sizeof(lv_color_t));
if (!disp_buf) {
Serial.println("Display buffer allocation failed!");
while (1);
}
Serial.println("Buffer allocated");
// Configure display
lv_display_set_buffers(disp, disp_buf, NULL,
screenWidth * bufferHeight * sizeof(lv_color_t),
LV_DISPLAY_RENDER_MODE_PARTIAL);
Serial.println("Display Buffers set");
lv_display_set_flush_cb(disp, my_disp_flush);
Serial.println("Flush callback set");
lv_display_set_render_mode(disp, LV_DISPLAY_RENDER_MODE_PARTIAL);
Serial.println("Initing UI");
// Initialize UI
ui_init();
lv_scr_load(ui_Screen1);
delay(100); // brief pause for everything to catch up
// Initialize lastMillis
lastMillis = millis();
// Update display with an initial forecast and stuff
updateDisplay();
updateTime();
Serial.println("Setup Done");
}
void loop() {
if (loopCount < 5) {
Serial.println("Looping");
loopCount++;
}
// lv_display_t* disp = lv_display_get_default();
// if (disp && !lv_display_is_rendering(disp)) {
// Serial.println("Triggering refresh");
// lv_refr_now(disp);
// }
Serial.println("Before timer handler");
lv_timer_handler();
Serial.println("After timer handler"); // CODE NEVER REACHES THIS LINE
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.