LVGL GUI works but becomes unresponsive after 15-20 seconds

What MCU/Processor/Board and compiler are you using?

Arduino Giga R1 with Giga Display shield. Using arduino IDE to compile and Squareline Studio for the GUI design.

What LVGL version are you using?

8.3.11

What do you want to achieve?

3 Digital inputs from the arduino Giga R1 board drive the LVGL interface buttons. It works as intended as per the code below. Only issue is that the LVGL GUI becomes unresponsive after 15-20 seconds or so.

What have you tried so far?

This is probably related to the delay in the code which might cause an event flooding. Tried playing with the delay() values to no avail. wondering if I am on the right track or if it’s something more complicated.

youtube video : https://www.youtube.com/watch?v=dMOOboHALwA

Code to reproduce

/*You code here*/

#include "Arduino_H7_Video.h"
#include "Arduino_GigaDisplayTouch.h"
#include "lvgl.h"
#include <ui.h>

// Constants
const int LOGIC_SHUT = 2; // input for LOGIC_SHUT
const int LOGIC_MID = 4;  // input for LOGIC_MID
const int LOGIC_OPEN = 6; // input for LOGIC_OPEN

// Variables
int Logic_SHUTState = 0;  // Variable to store shut state
int Logic_MIDState = 0;   // Variable to store mid state
int Logic_OPENState = 0;  // Variable to store open state

Arduino_H7_Video Display(800, 480, GigaDisplayShield);
Arduino_GigaDisplayTouch TouchDetector;

void setup() {
    
    pinMode(LOGIC_SHUT, INPUT);  // Set the logic pins as inputs
    pinMode(LOGIC_MID, INPUT);
    pinMode(LOGIC_OPEN, INPUT);
    
    Display.begin();
    TouchDetector.begin();
    ui_init(); // Initialize the UI

    // Register event handlers for buttons
    lv_obj_add_event_cb(ui_SHUT_BUTTON, ui_event_SHUT_BUTTON, LV_EVENT_CLICKED, NULL);
    lv_obj_add_event_cb(ui_MID_BUTTON, ui_event_MID_BUTTON, LV_EVENT_CLICKED, NULL);
    lv_obj_add_event_cb(ui_OPEN_BUTTON, ui_event_OPEN_BUTTON, LV_EVENT_CLICKED, NULL);
}

void loop() {
    lv_timer_handler(); // Handle LVGL tasks
    delay(5); // Short delay to avoid blocking

    Logic_SHUTState = digitalRead(LOGIC_SHUT);                  
    if (Logic_SHUTState == HIGH) {                             
        lv_event_send(ui_SHUT_BUTTON, LV_EVENT_CLICKED, NULL);
    }
    delay(200); // 

    Logic_MIDState = digitalRead(LOGIC_MID);                  
    if (Logic_MIDState == HIGH) {                             
        lv_event_send(ui_MID_BUTTON, LV_EVENT_CLICKED, NULL);
    }
    delay(200); // 

    Logic_OPENState = digitalRead(LOGIC_OPEN);     
    if (Logic_OPENState == HIGH) {   
        lv_event_send(ui_OPEN_BUTTON, LV_EVENT_CLICKED, NULL);
    }
    delay(200); 
}

Event flooding was probably the culprit considering that any Event was always being triggered (clicked) by the constant Digital Input @ HIGH.

Reworked the code and it seems to be working as intended using the RISING Edge as the trigger. The GUI no longer hangs or becomes unresponsive.

Thanks.