Lv_msgbox_create isnt creating a msgbox

Description

I am using lvgl with the giga display shield. lv_msgbox_create is creating a msgbox the first time it is called but any other calls dont work

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

The Arduino GIGA R1 Wifi (STM32H7) with The GIGA Display Shield

What LVGL version are you using?

8.3.11

What do you want to achieve?

I want to show a a message box that says Please Wait Scanning for Wifi Networks… when the user clicks the reload button

The code block(s) should be formatted like:

#include "Arduino_H7_Video.h"
#include "lvgl.h"
#include "Arduino_GigaDisplayTouch.h"
#include <WiFi.h>
#include "RPC.h"


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

bool ssid_selected = false;
bool keyboard_should_hide = true;
lv_obj_t* wifiList;
lv_obj_t* currentButton;
lv_obj_t* ssidLabel;
int status = WL_IDLE_STATUS;
lv_obj_t* ta_pass;
lv_obj_t* wifiGrid;
lv_obj_t* screen;
lv_obj_t* ssid_btn;


void ta_event_cb(lv_event_t* e) {
  lv_event_code_t code = lv_event_get_code(e);
  lv_obj_t* ta = lv_event_get_target(e);
  lv_obj_t* kb = (lv_obj_t*)lv_event_get_user_data(e);
  if (code == LV_EVENT_FOCUSED) {
    lv_keyboard_set_textarea(kb, ta);
    if (keyboard_should_hide) {
      lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
    }
  }

  if (code == LV_EVENT_DEFOCUSED) {
    lv_keyboard_set_textarea(kb, NULL);
    if (keyboard_should_hide) {
      lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
    }
  }
}

void wifiListEventHandler(lv_event_t* e) {
  lv_event_code_t code = lv_event_get_code(e);
  lv_obj_t* obj = lv_event_get_target(e);
  if (code == LV_EVENT_CLICKED) {

    if (currentButton == obj) {
      currentButton = NULL;
    } else {
      currentButton = obj;
    }
    lv_obj_t* parent = lv_obj_get_parent(obj);
    uint32_t i;
    for (i = 0; i < lv_obj_get_child_cnt(parent); i++) {
      lv_obj_t* child = lv_obj_get_child(parent, i);
      if (child == currentButton) {
        lv_obj_add_state(child, LV_STATE_CHECKED);
        lv_label_set_text(ssidLabel, lv_list_get_btn_text(wifiList, obj));
        lv_obj_clear_flag(ssid_btn, LV_OBJ_FLAG_HIDDEN);
        ssid_selected = true;
      } else {
        lv_obj_clear_state(child, LV_STATE_CHECKED);
      }
    }
  }
}


void next_btn_event(lv_event_t* e) {
  if (ssid_selected) {
    Serial.println(lv_label_get_text(ssidLabel));
    if (WiFi.status() == WL_NO_MODULE) {
      Serial.println("Communication with WiFi module failed!");
    }


    // attempt to connect to WiFi network:

    while (status != WL_CONNECTED || status != 4) {
      // Connect to WPA/WPA2 network:
      status = WiFi.begin(lv_label_get_text(ssidLabel), lv_textarea_get_text(ta_pass));
      Serial.println(status);
      // wait 10 seconds for connection:
      int start = millis();
      while ((millis() - start) < 10000) {
        lv_task_handler();
        lv_timer_handler();
      }
    }

    if (status == WL_CONNECTED) {
      Serial.println("You're connected to the network");
    } else {
      Serial.println("Wrong Password");
    }
  }
}


void wifiScanNonBtn() {
  lv_obj_t* btn;
  lv_obj_t* wait_msgbox;
  lv_obj_clean(wifiList);
  lv_obj_add_flag(ssid_btn, LV_OBJ_FLAG_HIDDEN);
  lv_label_set_text(ssidLabel, "No Wifi Network Selected");
  ssid_selected = false;
  Serial.println("Making msgbox");
  lv_task_handler();
  wait_msgbox = lv_msgbox_create(NULL, "Please Wait", "Scanning for Wifi Networks...", {}, false);
  lv_obj_center(wait_msgbox);
  lv_task_handler();
  /*int numSsid = WiFi.scanNetworks();
  if (numSsid != -1) {
    for (int thisNet = 0; thisNet < numSsid; thisNet++) {
      String ssid = WiFi.SSID(thisNet);
      if (!ssid.equals("")) {
        btn = lv_list_add_btn(wifiList, LV_SYMBOL_WIFI, ssid.c_str());
        lv_obj_add_event_cb(btn, wifiListEventHandler, LV_EVENT_CLICKED, NULL);
      }
    }
  }*/
  delay(3000);
  lv_msgbox_close(wait_msgbox);
  lv_task_handler();
}

void wifiScan(lv_event_t* e) {
  wifiScanNonBtn();
}

void startScreen() {
  static lv_coord_t col_dsc[] = { 320, 420, LV_GRID_TEMPLATE_LAST };
  static lv_coord_t row_dsc[] = { 440, LV_GRID_TEMPLATE_LAST };

  lv_obj_set_grid_dsc_array(wifiGrid, col_dsc, row_dsc);
  lv_obj_set_size(wifiGrid, Display.width(), Display.height());
  lv_obj_set_style_bg_color(wifiGrid, lv_color_hex(0x03989e), LV_PART_MAIN);

  //top left
  lv_obj_t* obj;
  lv_obj_t* label;
  lv_obj_t* btn;


  //bottom left
  obj = lv_obj_create(wifiGrid);
  lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 1, 1,  //column
                       LV_GRID_ALIGN_STRETCH, 0, 1);      //row
  lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
  lv_obj_set_flex_align(obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
  lv_obj_set_scrollbar_mode(obj, LV_SCROLLBAR_MODE_OFF);
  lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);

  ssidLabel = lv_label_create(obj);
  lv_label_set_text(ssidLabel, "No Wifi Network Selected");
  lv_obj_align(ssidLabel, LV_ALIGN_CENTER, 0, 0);

  ta_pass = lv_textarea_create(obj);
  lv_obj_t* kb = lv_keyboard_create(obj);
  lv_obj_set_align(ta_pass, LV_ALIGN_CENTER);
  lv_textarea_set_password_mode(ta_pass, true);
  lv_obj_add_event_cb(ta_pass, ta_event_cb, LV_EVENT_ALL, kb);
  lv_textarea_set_placeholder_text(ta_pass, "Wifi Password");
  lv_obj_set_size(ta_pass, 380, 80);
  lv_textarea_set_one_line(ta_pass, true);
  keyboard_should_hide = false;

  lv_keyboard_set_textarea(kb, ta_pass);

  ssid_btn = lv_btn_create(obj);
  lv_obj_set_size(ssid_btn, 100, 40);
  lv_obj_add_event_cb(ssid_btn, next_btn_event, LV_EVENT_CLICKED, NULL);

  label = lv_label_create(ssid_btn);
  lv_label_set_text(label, "Connect");
  lv_obj_center(label);
  lv_obj_add_flag(ssid_btn, LV_OBJ_FLAG_HIDDEN);



  obj = lv_obj_create(wifiGrid);
  lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1,  //column
                       LV_GRID_ALIGN_STRETCH, 0, 1);      //row
  lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
  lv_obj_set_flex_align(obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);

  wifiList = lv_list_create(obj);
  lv_obj_set_style_pad_row(wifiList, 5, 0);
  lv_obj_set_flex_grow(wifiList, 4);

  btn = lv_btn_create(obj);
  lv_obj_set_size(btn, 100, 40);
  lv_obj_add_event_cb(btn, wifiScan, LV_EVENT_CLICKED, NULL);

  label = lv_label_create(btn);
  lv_label_set_text(label, "Reload");
  lv_obj_center(label);

  wifiScanNonBtn();
}

void setup() {
  Serial.begin(9600);
  Serial.println("Start of setup");
  Display.begin();
  TouchDetector.begin();
  screen = lv_obj_create(lv_scr_act());
  wifiGrid = lv_obj_create(lv_scr_act());
  lv_obj_set_size(screen, Display.width(), Display.height());
  startScreen();
  RPC.begin();
}

void loop() {
  lv_task_handler();
}