Hello everyone,
I would like to import a png image from the sd card into the button “ui_ImgButton1” so that it changes the original image when the button is pressed.
This is my code:
void ui_Screen1_screen_init(void){
ui_Screen1 = lv_obj_create(NULL);
lv_obj_clear_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE);
ui_ImgButton1 = lv_imgbtn_create(ui_Screen1);
lv_imgbtn_set_src(ui_ImgButton1, LV_IMGBTN_STATE_RELEASED, NULL, &ui_img_bt_red_png, NULL);
lv_imgbtn_set_src(ui_ImgButton1, LV_IMGBTN_STATE_PRESSED, NULL, "S:/bt_yw.png", NULL);
lv_obj_set_height(ui_ImgButton1, 50);
lv_obj_set_width(ui_ImgButton1, LV_SIZE_CONTENT);
lv_obj_set_x(ui_ImgButton1, 4);
lv_obj_set_y(ui_ImgButton1, -4);
lv_obj_set_align(ui_ImgButton1, LV_ALIGN_CENTER);
}
Where am I wrong?
Can anyone advise me how to do it?
Thanks.
- SquareLine Studio version: 1.2.1
- **Operating system: win 10 - Arduino
- **Target hardware: ESP32s3