I want to erase the buttons on the previous screen when switching next screens

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Read the

Delete this section if you read and applied the mentioned points.

Description

When the power is turned on, the clock screen is displayed.

Added a button to move to the settings screen.

When I press this button, I want to move to the numeric keypad panel screen, but the numeric keypad panel is now displayed, but the previous clock display screen remains as is.

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

ESP32 + ili9488

What do you want to achieve?

Please tell me how to delete the object on the previous screen.

What have you tried so far?

Code to reproduce

Add the relevant code snippets here.

The code block(s) should be between ```c and ``` tags:



static void btn_event_setting_cb(lv_event_t *event) {
    
    Serial.println("設定ボタン_イベントハンドラ呼び出し");
    lv_event_code_t code = lv_event_get_code(event);
    if (code == LV_EVENT_CLICKED) {
        Serial.println("設定ボタンがクリックされました");

        //lv_obj_set_visible(time_label,false); // ボタンオブジェクトを削除
        //lv_obj_set_visible(wifiStatus_label,false); // ボタンオブジェクトを削除
        //lv_obj_set_visible(settings_btn,false); // ボタンオブジェクトを削除
        tenkey_setup();
    }
}



LV_FONT_DECLARE(jpFont04);



void clock_setup() {
    Serial.begin(115200); // シリアル通信の初期化
    Serial.println("clock_setup Start");

    // TFTの初期化
    tft.begin();
    tft.setRotation(1);

    uint16_t calData[5] = { 231, 3567, 344, 3355, 7 };
    tft.setTouch(calData);

    // LVGLの初期化
    lv_init();

    // バッファのサイズを設定
    lv_disp_draw_buf_init(&draw_buf, buf, NULL, 320 * 10); // 解像度に基づいてバッファサイズを設定  
    // LVGLのディスプレイドライバー設定 

    lv_disp_drv_init(&disp_drv);
    disp_drv.hor_res = 480; // ディスプレイの解像度を設定
    disp_drv.ver_res = 320;
    disp_drv.flush_cb = my_disp_flush;
    disp_drv.draw_buf = &draw_buf;
    lv_disp_drv_register(&disp_drv);


    #if 1
    // タッチパッド入力デバイスを初期化して登録
    static lv_indev_drv_t indev_drv;
    lv_indev_drv_init(&indev_drv);
    indev_drv.type = LV_INDEV_TYPE_POINTER;
    indev_drv.read_cb = my_touchpad_read;
    lv_indev_drv_register(&indev_drv);
    #endif


    static lv_style_t style1;
    lv_style_init(&style1);
    lv_style_set_text_font(&style1, &jpFont04);
  
    static lv_style_t style2;
    lv_style_init(&style2);
    lv_style_set_text_font(&style2, &lv_font_montserrat_48);


    // 時刻表示用ラベルの作成
    time_label = lv_label_create(lv_scr_act());
    lv_obj_add_style(time_label, &style2, 0); // スタイルを適用
    lv_label_set_text(time_label, "00:00");
    lv_obj_align(time_label, LV_ALIGN_CENTER, 0, 0);  
   
    // wifi状態表示用ラベルの作成
    wifiStatus_label = lv_label_create(lv_scr_act());
    lv_obj_add_style(wifiStatus_label, &style1, 0); // スタイルを適用
    lv_label_set_text(wifiStatus_label, "WiFi接続中...");
    lv_obj_align(wifiStatus_label, LV_ALIGN_CENTER, 0, 0);

    // ボタンの作成
    settings_btn = lv_btn_create(lv_scr_act());
    lv_obj_add_style(settings_btn, &style1, 0); // スタイルを適用
    lv_obj_set_size(settings_btn, 100, 50); // ボタンのサイズ設定
    lv_obj_align(settings_btn, LV_ALIGN_BOTTOM_RIGHT, -10, -10); // 画面の右下隅に配置
    lv_obj_add_event_cb(settings_btn, btn_event_setting_cb, LV_EVENT_CLICKED , NULL); // ボタンアクションの新しい設定方法

    // ボタンにラベルを追加
    lv_obj_t *settings_label = lv_label_create(settings_btn);
    lv_label_set_text(settings_label, "設定");

    // ... その他の初期化コード ...
    Serial.println("clock_setup end");
}



// NTP更新用のタスク
void ntpUpdateTask(void *pvParameters) {
  Serial.println("タスク_ntpUpdateTask_start");

  for (;;) {
    Serial.println("test_ntpUpdateTask");
    vTaskDelay(1000); 
    #if 1
    if (WiFi.status() == WL_CONNECTED) {
      timeClient.update();
      String currentTime = timeClient.getFormattedTime();
      if (time_label != NULL) {
        lv_label_set_text(time_label, currentTime.c_str());
      }
      if (wifiStatus_label != NULL)
      {
        lv_label_set_text(wifiStatus_label, " ");
      }
      
    } else {
      Serial.println("WiFiが接続されていません");
      // WiFiに接続できていない場合は警告メッセージを表示
      // 使用前にNULLでないことをチェック
      if (time_label != NULL) {
        lv_label_set_text(wifiStatus_label, "NTP接続不可 確認してください!");
      }
    }
    //vTaskDelay(3600000 / portTICK_PERIOD_MS); // 1時間ごと
    #endif
  }
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.