Description
I am running simple code Using LVGL which is a counter. My screen freezes and doesnt change the numbers so i tried removing the lv_timer_handler() from the loop function. now the screen autoscrolls but the counter is seen to be updating as the screen scroll.
What MCU/Processor/Board and compiler are you using?
I am using Waveshare 4.3 esp32s3 with ST7262 graphics driver with touch driver GT911
What do you want to achieve?
I want the screen to update normally and work so that i can display changing variables on it
Code to reproduce
#include <Arduino.h>
#include <ESP_Panel_Library.h>
#include <lvgl.h>
#include "lvgl_port_v8.h"
#define LVGL_PORT_DISP_BUFFER_NUM 2
#define LVGL_PORT_RGB_BOUNCE_BUFFER_SIZE (800 * 10) // Buffer size for 10 rows
lv_obj_t *label;
int counter = 1; // Start from 1
// Function to update the counter
void update_counter(lv_timer_t * timer)
{
// Update the counter and label text
char buf[8];
snprintf(buf, sizeof(buf), "%d", counter);
lv_label_set_text(label, buf);
// Increment the counter and reset if needed
counter++;
if (counter > 100) {
counter = 1; // Reset counter to 1
}
}
void setup()
{
Serial.begin(115200);
Serial.println("Starting setup...");
ESP_Panel *panel = new ESP_Panel();
Serial.println("Initializing panel...");
panel->init();
#if LVGL_PORT_AVOID_TEAR
// Ensure RGB bus configurations are correctly set
ESP_PanelBus_RGB *rgb_bus = static_cast<ESP_PanelBus_RGB *>(panel->getLcd()->getBus());
if (rgb_bus) {
rgb_bus->configRgbFrameBufferNumber(LVGL_PORT_DISP_BUFFER_NUM);
rgb_bus->configRgbBounceBufferSize(LVGL_PORT_RGB_BOUNCE_BUFFER_SIZE);
Serial.println("Configured RGB bus.");
} else {
Serial.println("Failed to get RGB bus.");
}
#endif
panel->begin();
Serial.println("Initializing LVGL port...");
lvgl_port_init(panel->getLcd(), NULL); // No touch
lvgl_port_lock(-1);
// Create a label to display the counter
label = lv_label_create(lv_scr_act());
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(label, "1"); // Set initial text
// Create a timer to update the counter every 100ms
lv_timer_create(update_counter, 100, NULL);
lvgl_port_unlock();
Serial.println("Setup complete.");
}
void loop()
{
lv_timer_handler(); // Let the GUI do its work
delay(5);
}
I can also share my set-up files if necessary.