绑定按钮到界面中

This commit is contained in:
YuXifeng 2025-04-01 18:00:41 +08:00
parent 24f520a32d
commit 9e0646df34
12 changed files with 1853 additions and 50 deletions

View File

@ -24,4 +24,5 @@ idf_component_register(SRCS "main.c" "Receiver.c" "flasher_tool.c"
INCLUDE_DIRS "GUI/" INCLUDE_DIRS "GUI/"
INCLUDE_DIRS "file_system/" INCLUDE_DIRS "file_system/"
INCLUDE_DIRS "wifi/") INCLUDE_DIRS "wifi/")
#spiffs_create_partition_image(storage spiffs_image FLASH_IN_PROJECT) #spiffs_create_partition_image(storage spiffs_image FLASH_IN_PROJECT)

View File

@ -14,7 +14,44 @@
#if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER #if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
#include "freemaster_client.h" #include "freemaster_client.h"
#endif #endif
extern lv_group_t *Key_Matrix_Group;
static void screen_btn_1_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_group_remove_all_objs(Key_Matrix_Group);
ui_load_scr_animation(&guider_ui, &guider_ui.screen_imglist, guider_ui.screen_imglist_del, &guider_ui.screen_del, setup_scr_screen_imglist, LV_SCR_LOAD_ANIM_OVER_LEFT, 200, 200, false, false);
lv_group_add_obj(Key_Matrix_Group,guider_ui.screen_imglist_ddlist_1);
lv_group_add_obj(Key_Matrix_Group,guider_ui.screen_imglist_list_1);
break;
}
default:
break;
}
}
static void screen_btn_3_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
ui_load_scr_animation(&guider_ui, &guider_ui.sscreen_burn, guider_ui.sscreen_burn_del, &guider_ui.screen_del, setup_scr_sscreen_burn, LV_SCR_LOAD_ANIM_OVER_RIGHT, 200, 200, false, false);
break;
}
default:
break;
}
}
void events_init_screen (lv_ui *ui)
{
lv_obj_add_event_cb(ui->screen_btn_1, screen_btn_1_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->screen_btn_3, screen_btn_3_event_handler, LV_EVENT_ALL, ui);
}
void events_init(lv_ui *ui) void events_init(lv_ui *ui)

View File

@ -18,6 +18,7 @@ extern "C" {
void events_init(lv_ui *ui); void events_init(lv_ui *ui);
void events_init_screen(lv_ui *ui);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -74,6 +74,8 @@ void init_scr_del_flag(lv_ui *ui)
{ {
ui->screen_del = true; ui->screen_del = true;
ui->sscreen_burn_del = true;
ui->screen_imglist_del = true;
} }
void setup_ui(lv_ui *ui) void setup_ui(lv_ui *ui)

View File

@ -27,6 +27,17 @@ typedef struct
lv_obj_t *screen_btn_2_label; lv_obj_t *screen_btn_2_label;
lv_obj_t *screen_btn_3; lv_obj_t *screen_btn_3;
lv_obj_t *screen_btn_3_label; lv_obj_t *screen_btn_3_label;
lv_obj_t *sscreen_burn;
bool sscreen_burn_del;
lv_obj_t *sscreen_burn_cont_1;
lv_obj_t *sscreen_burn_bar_1;
lv_obj_t *screen_imglist;
bool screen_imglist_del;
lv_obj_t *screen_imglist_cont_1;
lv_obj_t *screen_imglist_label_1;
lv_obj_t *screen_imglist_list_1;
lv_obj_t *screen_imglist_list_1_item0;
lv_obj_t *screen_imglist_ddlist_1;
}lv_ui; }lv_ui;
typedef void (*ui_setup_scr_t)(lv_ui * ui); typedef void (*ui_setup_scr_t)(lv_ui * ui);
@ -50,10 +61,13 @@ extern lv_ui guider_ui;
void setup_scr_screen(lv_ui *ui); void setup_scr_screen(lv_ui *ui);
void setup_scr_sscreen_burn(lv_ui *ui);
void setup_scr_screen_imglist(lv_ui *ui);
LV_FONT_DECLARE(lv_font_GB2312_16) LV_FONT_DECLARE(lv_font_GB2312_16)
LV_FONT_DECLARE(lv_font_montserratMedium_16) LV_FONT_DECLARE(lv_font_montserratMedium_16)
LV_FONT_DECLARE(lv_font_montserratMedium_12) LV_FONT_DECLARE(lv_font_montserratMedium_12)
LV_FONT_DECLARE(lv_font_GB2312_12)
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1 +1 @@
GEN_CSRCS += lv_font_GB2312_16.c lv_font_montserratMedium_16.c lv_font_montserratMedium_12.c GEN_CSRCS += lv_font_GB2312_16.c lv_font_montserratMedium_16.c lv_font_montserratMedium_12.c lv_font_GB2312_12.c

File diff suppressed because it is too large Load Diff

View File

@ -122,4 +122,6 @@ void setup_scr_screen(lv_ui *ui)
//Update current screen layout. //Update current screen layout.
lv_obj_update_layout(ui->screen); lv_obj_update_layout(ui->screen);
//Init events for screen.
events_init_screen(ui);
} }

View File

@ -0,0 +1,221 @@
/*
* Copyright 2025 NXP
* NXP Proprietary. This software is owned or controlled by NXP and may only be used strictly in
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms. If you do not agree to be bound by the applicable license
* terms, then you may not retain, install, activate or otherwise use the software.
*/
#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"
#include "widgets_init.h"
#include "custom.h"
void setup_scr_screen_imglist(lv_ui *ui)
{
//Write codes screen_imglist
ui->screen_imglist = lv_obj_create(NULL);
lv_obj_set_size(ui->screen_imglist, 128, 160);
lv_obj_set_scrollbar_mode(ui->screen_imglist, LV_SCROLLBAR_MODE_OFF);
//Write style for screen_imglist, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->screen_imglist, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_imglist_cont_1
ui->screen_imglist_cont_1 = lv_obj_create(ui->screen_imglist);
lv_obj_set_pos(ui->screen_imglist_cont_1, 0, 0);
lv_obj_set_size(ui->screen_imglist_cont_1, 128, 160);
lv_obj_set_scrollbar_mode(ui->screen_imglist_cont_1, LV_SCROLLBAR_MODE_OFF);
//Write style for screen_imglist_cont_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->screen_imglist_cont_1, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui->screen_imglist_cont_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui->screen_imglist_cont_1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_side(ui->screen_imglist_cont_1, LV_BORDER_SIDE_FULL, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_imglist_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->screen_imglist_cont_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->screen_imglist_cont_1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->screen_imglist_cont_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->screen_imglist_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(ui->screen_imglist_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->screen_imglist_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->screen_imglist_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_imglist_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_imglist_label_1
ui->screen_imglist_label_1 = lv_label_create(ui->screen_imglist);
lv_label_set_text(ui->screen_imglist_label_1, "镜像");
lv_label_set_long_mode(ui->screen_imglist_label_1, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(ui->screen_imglist_label_1, 0, 0);
lv_obj_set_size(ui->screen_imglist_label_1, 128, 18);
//Write style for screen_imglist_label_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->screen_imglist_label_1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_imglist_label_1, &lv_font_GB2312_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->screen_imglist_label_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(ui->screen_imglist_label_1, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->screen_imglist_label_1, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->screen_imglist_label_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->screen_imglist_label_1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->screen_imglist_label_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_imglist_label_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_imglist_list_1
ui->screen_imglist_list_1 = lv_list_create(ui->screen_imglist);
// ui->screen_imglist_list_1_item0 =lv_list_add_text(ui->screen_imglist_list_1, "save_1");
lv_obj_t * btn;
btn = lv_list_add_btn(ui->screen_imglist_list_1,LV_SYMBOL_FILE,"OfflineBurn.bin");
btn = lv_list_add_btn(ui->screen_imglist_list_1,LV_SYMBOL_FILE,"target_esp32s3.bin");
lv_obj_set_pos(ui->screen_imglist_list_1, 2, 43);
lv_obj_set_size(ui->screen_imglist_list_1, 124, 110);
lv_obj_set_scrollbar_mode(ui->screen_imglist_list_1, LV_SCROLLBAR_MODE_OFF);
//Write style state: LV_STATE_DEFAULT for &style_screen_imglist_list_1_main_main_default
static lv_style_t style_screen_imglist_list_1_main_main_default;
ui_init_style(&style_screen_imglist_list_1_main_main_default);
lv_style_set_pad_top(&style_screen_imglist_list_1_main_main_default, 5);
lv_style_set_pad_left(&style_screen_imglist_list_1_main_main_default, 5);
lv_style_set_pad_right(&style_screen_imglist_list_1_main_main_default, 5);
lv_style_set_pad_bottom(&style_screen_imglist_list_1_main_main_default, 5);
lv_style_set_bg_opa(&style_screen_imglist_list_1_main_main_default, 255);
lv_style_set_bg_color(&style_screen_imglist_list_1_main_main_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_screen_imglist_list_1_main_main_default, LV_GRAD_DIR_NONE);
lv_style_set_border_width(&style_screen_imglist_list_1_main_main_default, 1);
lv_style_set_border_opa(&style_screen_imglist_list_1_main_main_default, 255);
lv_style_set_border_color(&style_screen_imglist_list_1_main_main_default, lv_color_hex(0xe1e6ee));
lv_style_set_border_side(&style_screen_imglist_list_1_main_main_default, LV_BORDER_SIDE_FULL);
lv_style_set_radius(&style_screen_imglist_list_1_main_main_default, 3);
lv_style_set_shadow_width(&style_screen_imglist_list_1_main_main_default, 0);
lv_obj_add_style(ui->screen_imglist_list_1, &style_screen_imglist_list_1_main_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write style state: LV_STATE_DEFAULT for &style_screen_imglist_list_1_main_scrollbar_default
static lv_style_t style_screen_imglist_list_1_main_scrollbar_default;
ui_init_style(&style_screen_imglist_list_1_main_scrollbar_default);
lv_style_set_radius(&style_screen_imglist_list_1_main_scrollbar_default, 3);
lv_style_set_bg_opa(&style_screen_imglist_list_1_main_scrollbar_default, 255);
lv_style_set_bg_color(&style_screen_imglist_list_1_main_scrollbar_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_screen_imglist_list_1_main_scrollbar_default, LV_GRAD_DIR_NONE);
lv_obj_add_style(ui->screen_imglist_list_1, &style_screen_imglist_list_1_main_scrollbar_default, LV_PART_SCROLLBAR|LV_STATE_DEFAULT);
//Write style state: LV_STATE_DEFAULT for &style_screen_imglist_list_1_extra_btns_main_default
static lv_style_t style_screen_imglist_list_1_extra_btns_main_default;
ui_init_style(&style_screen_imglist_list_1_extra_btns_main_default);
lv_style_set_pad_top(&style_screen_imglist_list_1_extra_btns_main_default, 5);
lv_style_set_pad_left(&style_screen_imglist_list_1_extra_btns_main_default, 5);
lv_style_set_pad_right(&style_screen_imglist_list_1_extra_btns_main_default, 5);
lv_style_set_pad_bottom(&style_screen_imglist_list_1_extra_btns_main_default, 5);
lv_style_set_border_width(&style_screen_imglist_list_1_extra_btns_main_default, 0);
lv_style_set_text_color(&style_screen_imglist_list_1_extra_btns_main_default, lv_color_hex(0x0D3055));
lv_style_set_text_font(&style_screen_imglist_list_1_extra_btns_main_default, &lv_font_GB2312_12);
lv_style_set_text_opa(&style_screen_imglist_list_1_extra_btns_main_default, 255);
lv_style_set_radius(&style_screen_imglist_list_1_extra_btns_main_default, 3);
lv_style_set_bg_opa(&style_screen_imglist_list_1_extra_btns_main_default, 255);
lv_style_set_bg_color(&style_screen_imglist_list_1_extra_btns_main_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_screen_imglist_list_1_extra_btns_main_default, LV_GRAD_DIR_NONE);
//Write style state: LV_STATE_DEFAULT for &style_screen_imglist_list_1_extra_texts_main_default
static lv_style_t style_screen_imglist_list_1_extra_texts_main_default;
ui_init_style(&style_screen_imglist_list_1_extra_texts_main_default);
lv_style_set_pad_top(&style_screen_imglist_list_1_extra_texts_main_default, 5);
lv_style_set_pad_left(&style_screen_imglist_list_1_extra_texts_main_default, 5);
lv_style_set_pad_right(&style_screen_imglist_list_1_extra_texts_main_default, 5);
lv_style_set_pad_bottom(&style_screen_imglist_list_1_extra_texts_main_default, 5);
lv_style_set_border_width(&style_screen_imglist_list_1_extra_texts_main_default, 0);
lv_style_set_text_color(&style_screen_imglist_list_1_extra_texts_main_default, lv_color_hex(0x0D3055));
lv_style_set_text_font(&style_screen_imglist_list_1_extra_texts_main_default, &lv_font_GB2312_12);
lv_style_set_text_opa(&style_screen_imglist_list_1_extra_texts_main_default, 255);
lv_style_set_radius(&style_screen_imglist_list_1_extra_texts_main_default, 3);
lv_style_set_transform_width(&style_screen_imglist_list_1_extra_texts_main_default, 0);
lv_style_set_bg_opa(&style_screen_imglist_list_1_extra_texts_main_default, 255);
lv_style_set_bg_color(&style_screen_imglist_list_1_extra_texts_main_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_screen_imglist_list_1_extra_texts_main_default, LV_GRAD_DIR_NONE);
// lv_obj_add_style(ui->screen_imglist_list_1_item0, &style_screen_imglist_list_1_extra_texts_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_imglist_ddlist_1
ui->screen_imglist_ddlist_1 = lv_dropdown_create(ui->screen_imglist);
lv_dropdown_set_options(ui->screen_imglist_ddlist_1, "ESP32C2\nESP32C3\nESP32C6\nESP32\nESP32S2\nESP32S3");
lv_obj_set_pos(ui->screen_imglist_ddlist_1, 4, 18);
lv_obj_set_size(ui->screen_imglist_ddlist_1, 120, 24);
//Write style for screen_imglist_ddlist_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_text_color(ui->screen_imglist_ddlist_1, lv_color_hex(0x0D3055), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_imglist_ddlist_1, &lv_font_GB2312_12, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->screen_imglist_ddlist_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->screen_imglist_ddlist_1, 1, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui->screen_imglist_ddlist_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui->screen_imglist_ddlist_1, lv_color_hex(0xe1e6ee), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_side(ui->screen_imglist_ddlist_1, LV_BORDER_SIDE_FULL, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->screen_imglist_ddlist_1, 8, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->screen_imglist_ddlist_1, 6, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->screen_imglist_ddlist_1, 6, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_imglist_ddlist_1, 3, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->screen_imglist_ddlist_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->screen_imglist_ddlist_1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->screen_imglist_ddlist_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_imglist_ddlist_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write style state: LV_STATE_CHECKED for &style_screen_imglist_ddlist_1_extra_list_selected_checked
static lv_style_t style_screen_imglist_ddlist_1_extra_list_selected_checked;
ui_init_style(&style_screen_imglist_ddlist_1_extra_list_selected_checked);
lv_style_set_border_width(&style_screen_imglist_ddlist_1_extra_list_selected_checked, 1);
lv_style_set_border_opa(&style_screen_imglist_ddlist_1_extra_list_selected_checked, 255);
lv_style_set_border_color(&style_screen_imglist_ddlist_1_extra_list_selected_checked, lv_color_hex(0xe1e6ee));
lv_style_set_border_side(&style_screen_imglist_ddlist_1_extra_list_selected_checked, LV_BORDER_SIDE_FULL);
lv_style_set_radius(&style_screen_imglist_ddlist_1_extra_list_selected_checked, 3);
lv_style_set_bg_opa(&style_screen_imglist_ddlist_1_extra_list_selected_checked, 255);
lv_style_set_bg_color(&style_screen_imglist_ddlist_1_extra_list_selected_checked, lv_color_hex(0x00a1b5));
lv_style_set_bg_grad_dir(&style_screen_imglist_ddlist_1_extra_list_selected_checked, LV_GRAD_DIR_NONE);
lv_obj_add_style(lv_dropdown_get_list(ui->screen_imglist_ddlist_1), &style_screen_imglist_ddlist_1_extra_list_selected_checked, LV_PART_SELECTED|LV_STATE_CHECKED);
//Write style state: LV_STATE_DEFAULT for &style_screen_imglist_ddlist_1_extra_list_main_default
static lv_style_t style_screen_imglist_ddlist_1_extra_list_main_default;
ui_init_style(&style_screen_imglist_ddlist_1_extra_list_main_default);
lv_style_set_max_height(&style_screen_imglist_ddlist_1_extra_list_main_default, 90);
lv_style_set_text_color(&style_screen_imglist_ddlist_1_extra_list_main_default, lv_color_hex(0x0D3055));
lv_style_set_text_font(&style_screen_imglist_ddlist_1_extra_list_main_default, &lv_font_GB2312_12);
lv_style_set_text_opa(&style_screen_imglist_ddlist_1_extra_list_main_default, 255);
lv_style_set_border_width(&style_screen_imglist_ddlist_1_extra_list_main_default, 1);
lv_style_set_border_opa(&style_screen_imglist_ddlist_1_extra_list_main_default, 255);
lv_style_set_border_color(&style_screen_imglist_ddlist_1_extra_list_main_default, lv_color_hex(0xe1e6ee));
lv_style_set_border_side(&style_screen_imglist_ddlist_1_extra_list_main_default, LV_BORDER_SIDE_FULL);
lv_style_set_radius(&style_screen_imglist_ddlist_1_extra_list_main_default, 3);
lv_style_set_bg_opa(&style_screen_imglist_ddlist_1_extra_list_main_default, 255);
lv_style_set_bg_color(&style_screen_imglist_ddlist_1_extra_list_main_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_screen_imglist_ddlist_1_extra_list_main_default, LV_GRAD_DIR_NONE);
lv_obj_add_style(lv_dropdown_get_list(ui->screen_imglist_ddlist_1), &style_screen_imglist_ddlist_1_extra_list_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write style state: LV_STATE_DEFAULT for &style_screen_imglist_ddlist_1_extra_list_scrollbar_default
static lv_style_t style_screen_imglist_ddlist_1_extra_list_scrollbar_default;
ui_init_style(&style_screen_imglist_ddlist_1_extra_list_scrollbar_default);
lv_style_set_radius(&style_screen_imglist_ddlist_1_extra_list_scrollbar_default, 3);
lv_style_set_bg_opa(&style_screen_imglist_ddlist_1_extra_list_scrollbar_default, 255);
lv_style_set_bg_color(&style_screen_imglist_ddlist_1_extra_list_scrollbar_default, lv_color_hex(0x00ff00));
lv_style_set_bg_grad_dir(&style_screen_imglist_ddlist_1_extra_list_scrollbar_default, LV_GRAD_DIR_NONE);
lv_obj_add_style(lv_dropdown_get_list(ui->screen_imglist_ddlist_1), &style_screen_imglist_ddlist_1_extra_list_scrollbar_default, LV_PART_SCROLLBAR|LV_STATE_DEFAULT);
//The custom code of screen_imglist.
//Update current screen layout.
lv_obj_update_layout(ui->screen_imglist);
}

View File

@ -0,0 +1,78 @@
/*
* Copyright 2025 NXP
* NXP Proprietary. This software is owned or controlled by NXP and may only be used strictly in
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms. If you do not agree to be bound by the applicable license
* terms, then you may not retain, install, activate or otherwise use the software.
*/
#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"
#include "widgets_init.h"
#include "custom.h"
void setup_scr_sscreen_burn(lv_ui *ui)
{
//Write codes sscreen_burn
ui->sscreen_burn = lv_obj_create(NULL);
lv_obj_set_size(ui->sscreen_burn, 128, 160);
lv_obj_set_scrollbar_mode(ui->sscreen_burn, LV_SCROLLBAR_MODE_OFF);
//Write style for sscreen_burn, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->sscreen_burn, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes sscreen_burn_cont_1
ui->sscreen_burn_cont_1 = lv_obj_create(ui->sscreen_burn);
lv_obj_set_pos(ui->sscreen_burn_cont_1, 0, 0);
lv_obj_set_size(ui->sscreen_burn_cont_1, 128, 160);
lv_obj_set_scrollbar_mode(ui->sscreen_burn_cont_1, LV_SCROLLBAR_MODE_OFF);
//Write style for sscreen_burn_cont_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->sscreen_burn_cont_1, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui->sscreen_burn_cont_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui->sscreen_burn_cont_1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_side(ui->sscreen_burn_cont_1, LV_BORDER_SIDE_FULL, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->sscreen_burn_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->sscreen_burn_cont_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->sscreen_burn_cont_1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->sscreen_burn_cont_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->sscreen_burn_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(ui->sscreen_burn_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->sscreen_burn_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->sscreen_burn_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->sscreen_burn_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes sscreen_burn_bar_1
ui->sscreen_burn_bar_1 = lv_bar_create(ui->sscreen_burn);
lv_obj_set_style_anim_time(ui->sscreen_burn_bar_1, 1000, 0);
lv_bar_set_mode(ui->sscreen_burn_bar_1, LV_BAR_MODE_NORMAL);
lv_bar_set_range(ui->sscreen_burn_bar_1, 0, 100);
lv_bar_set_value(ui->sscreen_burn_bar_1, 50, LV_ANIM_OFF);
lv_obj_set_pos(ui->sscreen_burn_bar_1, 4, 135);
lv_obj_set_size(ui->sscreen_burn_bar_1, 120, 20);
//Write style for sscreen_burn_bar_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->sscreen_burn_bar_1, 60, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->sscreen_burn_bar_1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->sscreen_burn_bar_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->sscreen_burn_bar_1, 10, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->sscreen_burn_bar_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write style for sscreen_burn_bar_1, Part: LV_PART_INDICATOR, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->sscreen_burn_bar_1, 255, LV_PART_INDICATOR|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->sscreen_burn_bar_1, lv_color_hex(0x2195f6), LV_PART_INDICATOR|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->sscreen_burn_bar_1, LV_GRAD_DIR_NONE, LV_PART_INDICATOR|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->sscreen_burn_bar_1, 10, LV_PART_INDICATOR|LV_STATE_DEFAULT);
//The custom code of sscreen_burn.
//Update current screen layout.
lv_obj_update_layout(ui->sscreen_burn);
}

View File

@ -8,6 +8,10 @@
#include "esp_lcd_panel_ops.h" #include "esp_lcd_panel_ops.h"
#include "esp_lvgl_port.h" #include "esp_lvgl_port.h"
#include "gui_guider.h" #include "gui_guider.h"
#include "custom.h"
#include "button_gpio.h"
#include "iot_button.h"
#include "esp_lvgl_port_knob.h"
static const char *TAG = "lcd"; static const char *TAG = "lcd";
@ -34,6 +38,55 @@ esp_lcd_panel_handle_t panel_handle = NULL;
/* LVGL display and touch */ /* LVGL display and touch */
static lv_display_t *lvgl_disp = NULL; static lv_display_t *lvgl_disp = NULL;
static lv_indev_t *lvgl_button_indev = NULL;
#define BUTTON_COUNT 3 // 假设有 3 个按钮
#define BUTTON_ACTIVE_LEVEL 0
static button_handle_t buttons[BUTTON_COUNT]; // 存储按钮句柄
static const uint32_t button_pins[BUTTON_COUNT] = {GPIO_NUM_0, GPIO_NUM_40, GPIO_NUM_41}; // 按钮 GPIO
lv_group_t *Key_Matrix_Group;
void button_event_cb(void *arg, void *usr_data)
{
iot_button_print_event((button_handle_t)arg);
uint32_t btn_idx = (uint32_t)usr_data; // 获取按钮索引
printf("Button %ld\n", btn_idx);
}
void button_init_all()
{
for (int i = 0; i < BUTTON_COUNT; i++) {
button_config_t btn_cfg;
memset(&btn_cfg, 0, sizeof(button_config_t));
button_gpio_config_t gpio_cfg = {
.gpio_num = button_pins[i],
.active_level = BUTTON_ACTIVE_LEVEL,
.enable_power_save = true,
};
esp_err_t ret = iot_button_new_gpio_device(&btn_cfg, &gpio_cfg, &buttons[i]);
assert(ret == ESP_OK);
// 绑定事件回调,并传递按钮索引
// ret = iot_button_register_cb(buttons[i], BUTTON_PRESS_DOWN, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_PRESS_UP, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_PRESS_REPEAT, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_SINGLE_CLICK, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_DOUBLE_CLICK, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_LONG_PRESS_START, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_LONG_PRESS_HOLD, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_LONG_PRESS_UP, NULL, button_event_cb, (void *)i);
// ret |= iot_button_register_cb(buttons[i], BUTTON_PRESS_END, NULL, button_event_cb, (void *)i);
ESP_ERROR_CHECK(ret);
}
}
static esp_err_t app_lvgl_init(void) static esp_err_t app_lvgl_init(void)
{ {
@ -75,7 +128,32 @@ static esp_err_t app_lvgl_init(void)
lvgl_disp = lvgl_port_add_disp(&disp_cfg); lvgl_disp = lvgl_port_add_disp(&disp_cfg);
/* Add KEY input (for selected screen) */ /* Add KEY input (for selected screen) */
const lvgl_port_nav_btns_cfg_t button_cfg = {
.disp = lvgl_disp,
.button_prev = buttons[2],
.button_enter = buttons[1],
.button_next = buttons[0],
};
lvgl_button_indev = lvgl_port_add_navigation_buttons(&button_cfg);
Key_Matrix_Group = lv_group_create(); //创建组
lv_indev_set_group(lvgl_button_indev, Key_Matrix_Group); //将组绑定到输入设备
#if USE_KEYBOARD
keyboard_init();
lv_indev_drv_t indev_drv_keyboard;
lv_indev_drv_init(&indev_drv_keyboard); /*Basic initialization*/
indev_drv_keyboard.type = LV_INDEV_TYPE_KEYPAD;
indev_drv_keyboard.read_cb = keyboard_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
indev_drv_keyboard.disp = disp_300x240;
lv_indev_t* indev_keyboard = lv_indev_drv_register(&indev_drv_keyboard);
lv_indev_drv_update(indev_keyboard,&indev_drv_keyboard);
Key_Matrix_Group = lv_group_create(); //创建组
lv_indev_set_group(indev_keyboard, Key_Matrix_Group); //将组绑定到输入设备
#endif
//ui->screen_btn_1
return ESP_OK; return ESP_OK;
} }
@ -110,10 +188,12 @@ static void app_main_display(void)
// // lv_obj_add_event_cb(btn, _app_button_cb, LV_EVENT_CLICKED, NULL); // // lv_obj_add_event_cb(btn, _app_button_cb, LV_EVENT_CLICKED, NULL);
// custom_init(&guider_ui); custom_init(&guider_ui);
setup_ui(&guider_ui); setup_ui(&guider_ui);
// events_init(&guider_ui); // events_init(&guider_ui);
lv_group_add_obj(Key_Matrix_Group,guider_ui.screen_btn_1);
lv_group_add_obj(Key_Matrix_Group,guider_ui.screen_btn_2);
lv_group_add_obj(Key_Matrix_Group,guider_ui.screen_btn_3);
/* Task unlock */ /* Task unlock */
lvgl_port_unlock(); lvgl_port_unlock();
} }
@ -156,6 +236,7 @@ void Gui_Task(void *pvParameter)
// memset(&lcd_data[0],0xff,128*160*2); // memset(&lcd_data[0],0xff,128*160*2);
// esp_lcd_panel_draw_bitmap(panel_handle, 30, 80, 128, 160, &lcd_data[0]); // esp_lcd_panel_draw_bitmap(panel_handle, 30, 80, 128, 160, &lcd_data[0]);
// vTaskDelay(1000 / portTICK_PERIOD_MS); // vTaskDelay(1000 / portTICK_PERIOD_MS);
button_init_all();
app_lvgl_init(); app_lvgl_init();
app_main_display(); app_main_display();

View File

@ -41,13 +41,10 @@
#include "esp_flash.h" #include "esp_flash.h"
#include "esp_lcd_st7735.h" #include "esp_lcd_st7735.h"
#include "button_gpio.h"
#include "iot_button.h"
#include "i2c_port.h" #include "i2c_port.h"
static const char *TAG = "main"; static const char *TAG = "main";
#define BUTTON_ACTIVE_LEVEL 0
uint8_t* load_html2Ram(wifi_html_t html) uint8_t* load_html2Ram(wifi_html_t html)
{ {
@ -64,51 +61,8 @@ uint8_t* load_html2Ram(wifi_html_t html)
return NULL; return NULL;
} }
#define BUTTON_COUNT 3 // 假设有 3 个按钮
static button_handle_t buttons[BUTTON_COUNT]; // 存储按钮句柄
static const uint32_t button_pins[BUTTON_COUNT] = {GPIO_NUM_0, GPIO_NUM_40, GPIO_NUM_41}; // 按钮 GPIO
void button_event_cb(void *arg, void *usr_data)
{
iot_button_print_event((button_handle_t)arg);
uint32_t btn_idx = (uint32_t)usr_data; // 获取按钮索引
printf("Button %ld\n", btn_idx);
}
void button_init_all()
{
for (int i = 0; i < BUTTON_COUNT; i++) {
button_config_t btn_cfg;
memset(&btn_cfg, 0, sizeof(button_config_t));
button_gpio_config_t gpio_cfg = {
.gpio_num = button_pins[i],
.active_level = BUTTON_ACTIVE_LEVEL,
.enable_power_save = true,
};
esp_err_t ret = iot_button_new_gpio_device(&btn_cfg, &gpio_cfg, &buttons[i]);
assert(ret == ESP_OK);
// 绑定事件回调,并传递按钮索引
ret = iot_button_register_cb(buttons[i], BUTTON_PRESS_DOWN, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_PRESS_UP, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_PRESS_REPEAT, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_SINGLE_CLICK, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_DOUBLE_CLICK, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_LONG_PRESS_START, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_LONG_PRESS_HOLD, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_LONG_PRESS_UP, NULL, button_event_cb, (void *)i);
ret |= iot_button_register_cb(buttons[i], BUTTON_PRESS_END, NULL, button_event_cb, (void *)i);
ESP_ERROR_CHECK(ret);
}
}
extern uint8_t* home_html_data; extern uint8_t* home_html_data;
stream_data_t wifi_interface_data; stream_data_t wifi_interface_data;
stream_data_t uart_interface_data; stream_data_t uart_interface_data;
@ -153,7 +107,7 @@ void app_main(void)
// .pull_up_en = 1 // .pull_up_en = 1
// }; // };
// gpio_config(&input_config); // gpio_config(&input_config);
button_init_all(); // button_init_all();
ESP_ERROR_CHECK(i2c_master_init()); ESP_ERROR_CHECK(i2c_master_init());
axp_init(); axp_init();