调整颜色设置,增加Guider支持

This commit is contained in:
YuXifeng 2025-03-31 17:58:04 +08:00
parent 5a25244f59
commit e8796702d6
25 changed files with 6979 additions and 24 deletions

View File

@ -4,7 +4,7 @@ file(GLOB PORT_SRCS "wifi/*.c" )
file(GLOB FILE_SYS_SRCS "file_system/spiffs.c" "file_system/file_encryptor.c" )
if(CONFIG_IDF_TARGET_ESP32S2)
file(GLOB PORT_GUI "GUI/lvgl_task.c" )
file(GLOB PORT_GUI "GUI/lvgl_task.c" "GUI/custom/*.c" "GUI/generated/*.c" "GUI/generated/guider_fonts/*.c")
# elseif(CONFIG_IDF_TARGET_ESP32C3)
file(GLOB PORT_USB "usb_serial_task.c" )
endif()
@ -14,6 +14,9 @@ idf_component_register(SRCS "main.c" "Receiver.c" "flasher_tool.c"
${FILE_SYS_SRCS}
${PORT_USB}
${PORT_GUI}
INCLUDE_DIRS "GUI/custom/"
INCLUDE_DIRS "GUI/generated/"
INCLUDE_DIRS "GUI/generated/guider_fonts/"
INCLUDE_DIRS "."
INCLUDE_DIRS "GUI/"
INCLUDE_DIRS "file_system/"

42
main/GUI/custom/custom.c Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright 2023 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.
*/
/*********************
* INCLUDES
*********************/
#include <stdio.h>
#include "lvgl.h"
#include "custom.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**
* Create a demo application
*/
void custom_init(lv_ui *ui)
{
/* Add your codes here */
}

23
main/GUI/custom/custom.h Normal file
View File

@ -0,0 +1,23 @@
/*
* Copyright 2023 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.
*/
#ifndef __CUSTOM_H_
#define __CUSTOM_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "gui_guider.h"
void custom_init(lv_ui *ui);
#ifdef __cplusplus
}
#endif
#endif /* EVENT_CB_H_ */

View File

@ -0,0 +1,7 @@
GEN_CSRCS += $(notdir $(wildcard $(PRJ_DIR)/custom/*.c))
DEPPATH += --dep-path $(PRJ_DIR)/custom
VPATH += :$(PRJ_DIR)/custom
CFLAGS += "-I$(PRJ_DIR)/custom"

View File

@ -0,0 +1,42 @@
/*
* Copyright 2023 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.
*/
/*
* lv_conf_ext.h for custom lvconf file.
* Created on: Feb 8, 2023
* example :
* #undef LV_FONT_FMT_TXT_LARGE
* #define LV_FONT_FMT_TXT_LARGE 1
*/
#ifndef LV_CONF_EXT_H
#define LV_CONF_EXT_H
/* common code begin */
/* common code end */
#if LV_USE_GUIDER_SIMULATOR
/* code for simulator begin */
/* code for simulator end */
#else
/* code for board begin */
/* code for board end */
#endif
#endif /* LV_CONF_EXT_H */

View File

@ -0,0 +1,23 @@
/*
* 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 "events_init.h"
#include <stdio.h>
#include "lvgl.h"
#if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
#include "freemaster_client.h"
#endif
void events_init(lv_ui *ui)
{
}

View File

@ -0,0 +1,25 @@
/*
* 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.
*/
#ifndef EVENTS_INIT_H_
#define EVENTS_INIT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "gui_guider.h"
void events_init(lv_ui *ui);
#ifdef __cplusplus
}
#endif
#endif /* EVENT_CB_H_ */

View File

@ -0,0 +1,16 @@
# images
include $(PRJ_DIR)/generated/images/images.mk
# GUI Guider fonts
include $(PRJ_DIR)/generated/guider_fonts/guider_fonts.mk
# GUI Guider customer fonts
include $(PRJ_DIR)/generated/guider_customer_fonts/guider_customer_fonts.mk
GEN_CSRCS += $(notdir $(wildcard $(PRJ_DIR)/generated/*.c))
DEPPATH += --dep-path $(PRJ_DIR)/generated
VPATH += :$(PRJ_DIR)/generated
CFLAGS += "-I$(PRJ_DIR)/generated"

View File

@ -0,0 +1,84 @@
/*
* 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"
#if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
#include "gg_external_data.h"
#endif
void ui_init_style(lv_style_t * style)
{
if (style->prop_cnt > 1)
lv_style_reset(style);
else
lv_style_init(style);
}
void ui_load_scr_animation(lv_ui *ui, lv_obj_t ** new_scr, bool new_scr_del, bool * old_scr_del, ui_setup_scr_t setup_scr,
lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool is_clean, bool auto_del)
{
lv_obj_t * act_scr = lv_scr_act();
#if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
if(auto_del) {
gg_edata_task_clear(act_scr);
}
#endif
if (auto_del && is_clean) {
lv_obj_clean(act_scr);
}
if (new_scr_del) {
setup_scr(ui);
}
lv_scr_load_anim(*new_scr, anim_type, time, delay, auto_del);
*old_scr_del = auto_del;
}
void ui_animation(void * var, int32_t duration, int32_t delay, int32_t start_value, int32_t end_value, lv_anim_path_cb_t path_cb,
uint16_t repeat_cnt, uint32_t repeat_delay, uint32_t playback_time, uint32_t playback_delay,
lv_anim_exec_xcb_t exec_cb, lv_anim_start_cb_t start_cb, lv_anim_ready_cb_t ready_cb, lv_anim_deleted_cb_t deleted_cb)
{
lv_anim_t anim;
lv_anim_init(&anim);
lv_anim_set_var(&anim, var);
lv_anim_set_exec_cb(&anim, exec_cb);
lv_anim_set_values(&anim, start_value, end_value);
lv_anim_set_time(&anim, duration);
lv_anim_set_delay(&anim, delay);
lv_anim_set_path_cb(&anim, path_cb);
lv_anim_set_repeat_count(&anim, repeat_cnt);
lv_anim_set_repeat_delay(&anim, repeat_delay);
lv_anim_set_playback_time(&anim, playback_time);
lv_anim_set_playback_delay(&anim, playback_delay);
if (start_cb) {
lv_anim_set_start_cb(&anim, start_cb);
}
if (ready_cb) {
lv_anim_set_ready_cb(&anim, ready_cb);
}
if (deleted_cb) {
lv_anim_set_deleted_cb(&anim, deleted_cb);
}
lv_anim_start(&anim);
}
void init_scr_del_flag(lv_ui *ui)
{
ui->screen_del = true;
}
void setup_ui(lv_ui *ui)
{
init_scr_del_flag(ui);
setup_scr_screen(ui);
lv_scr_load(ui->screen);
}

View File

@ -0,0 +1,62 @@
/*
* 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.
*/
#ifndef GUI_GUIDER_H
#define GUI_GUIDER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "lvgl.h"
typedef struct
{
lv_obj_t *screen;
bool screen_del;
lv_obj_t *screen_cont_1;
lv_obj_t *screen_btn_1;
lv_obj_t *screen_btn_1_label;
lv_obj_t *screen_btn_2;
lv_obj_t *screen_btn_2_label;
lv_obj_t *screen_btn_3;
lv_obj_t *screen_btn_3_label;
}lv_ui;
typedef void (*ui_setup_scr_t)(lv_ui * ui);
void ui_init_style(lv_style_t * style);
void ui_load_scr_animation(lv_ui *ui, lv_obj_t ** new_scr, bool new_scr_del, bool * old_scr_del, ui_setup_scr_t setup_scr,
lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool is_clean, bool auto_del);
void ui_animation(void * var, int32_t duration, int32_t delay, int32_t start_value, int32_t end_value, lv_anim_path_cb_t path_cb,
uint16_t repeat_cnt, uint32_t repeat_delay, uint32_t playback_time, uint32_t playback_delay,
lv_anim_exec_xcb_t exec_cb, lv_anim_start_cb_t start_cb, lv_anim_ready_cb_t ready_cb, lv_anim_deleted_cb_t deleted_cb);
void init_scr_del_flag(lv_ui *ui);
void setup_ui(lv_ui *ui);
extern lv_ui guider_ui;
void setup_scr_screen(lv_ui *ui);
LV_FONT_DECLARE(lv_font_GB2312_16)
LV_FONT_DECLARE(lv_font_montserratMedium_16)
LV_FONT_DECLARE(lv_font_montserratMedium_12)
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,21 @@
/*
* Copyright 2023 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.
*/
#ifndef GUIDER_CUSTOMER_FONTS_H
#define GUIDER_CUSTOMER_FONTS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "lv_font.h"
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,6 @@
GEN_CSRCS += $(notdir $(wildcard $(PRJ_DIR)/generated/guider_customer_fonts/*.c))
DEPPATH += --dep-path $(PRJ_DIR)/generated/guider_customer_fonts
VPATH += :$(PRJ_DIR)/generated/guider_customer_fonts
CFLAGS += "-I$(PRJ_DIR)/generated/guider_customer_fonts"

View File

@ -0,0 +1 @@
GEN_CSRCS += lv_font_GB2312_16.c lv_font_montserratMedium_16.c lv_font_montserratMedium_12.c

View File

@ -0,0 +1,6 @@
-include $(PRJ_DIR)/generated/guider_fonts/fonts_list.mk
DEPPATH += --dep-path $(PRJ_DIR)/generated/guider_fonts
VPATH += :$(PRJ_DIR)/generated/guider_fonts
CFLAGS += "-I$(PRJ_DIR)/generated/guider_fonts"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
-include $(PRJ_DIR)/generated/images/images_list.mk
-include $(PRJ_DIR)/generated/images/lottie_list.mk
DEPPATH += --dep-path $(PRJ_DIR)/generated/images
VPATH += :$(PRJ_DIR)/generated/images
CFLAGS += "-I$(PRJ_DIR)/generated/images"

View File

@ -0,0 +1 @@
GEN_CSRCS +=

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
GEN_CSRCS +=

View File

@ -0,0 +1,125 @@
/*
* 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(lv_ui *ui)
{
//Write codes screen
ui->screen = lv_obj_create(NULL);
lv_obj_set_size(ui->screen, 128, 160);
lv_obj_set_scrollbar_mode(ui->screen, LV_SCROLLBAR_MODE_OFF);
//Write style for screen, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->screen, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_cont_1
ui->screen_cont_1 = lv_obj_create(ui->screen);
lv_obj_set_pos(ui->screen_cont_1, 0, 0);
lv_obj_set_size(ui->screen_cont_1, 128, 160);
lv_obj_set_scrollbar_mode(ui->screen_cont_1, LV_SCROLLBAR_MODE_OFF);
//Write style for screen_cont_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->screen_cont_1, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui->screen_cont_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui->screen_cont_1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_side(ui->screen_cont_1, LV_BORDER_SIDE_FULL, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->screen_cont_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->screen_cont_1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->screen_cont_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->screen_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(ui->screen_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->screen_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->screen_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_cont_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_btn_1
ui->screen_btn_1 = lv_btn_create(ui->screen);
ui->screen_btn_1_label = lv_label_create(ui->screen_btn_1);
lv_label_set_text(ui->screen_btn_1_label, "烧录");
lv_label_set_long_mode(ui->screen_btn_1_label, LV_LABEL_LONG_WRAP);
lv_obj_align(ui->screen_btn_1_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_1, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_1_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_1, 11, 8);
lv_obj_set_size(ui->screen_btn_1, 105, 40);
//Write style for screen_btn_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->screen_btn_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->screen_btn_1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->screen_btn_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->screen_btn_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_btn_1, 5, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_btn_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->screen_btn_1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_btn_1, &lv_font_GB2312_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->screen_btn_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->screen_btn_1, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_btn_2
ui->screen_btn_2 = lv_btn_create(ui->screen);
ui->screen_btn_2_label = lv_label_create(ui->screen_btn_2);
lv_label_set_text(ui->screen_btn_2_label, "镜像");
lv_label_set_long_mode(ui->screen_btn_2_label, LV_LABEL_LONG_WRAP);
lv_obj_align(ui->screen_btn_2_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_2, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_2_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_2, 11, 58);
lv_obj_set_size(ui->screen_btn_2, 105, 40);
//Write style for screen_btn_2, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->screen_btn_2, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->screen_btn_2, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->screen_btn_2, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->screen_btn_2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_btn_2, 5, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_btn_2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->screen_btn_2, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_btn_2, &lv_font_GB2312_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->screen_btn_2, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->screen_btn_2, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_btn_3
ui->screen_btn_3 = lv_btn_create(ui->screen);
ui->screen_btn_3_label = lv_label_create(ui->screen_btn_3);
lv_label_set_text(ui->screen_btn_3_label, "设置");
lv_label_set_long_mode(ui->screen_btn_3_label, LV_LABEL_LONG_WRAP);
lv_obj_align(ui->screen_btn_3_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_3, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_3_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_3, 11, 106);
lv_obj_set_size(ui->screen_btn_3, 105, 40);
//Write style for screen_btn_3, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->screen_btn_3, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->screen_btn_3, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->screen_btn_3, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->screen_btn_3, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_btn_3, 5, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_btn_3, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->screen_btn_3, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_btn_3, &lv_font_GB2312_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->screen_btn_3, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->screen_btn_3, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
//The custom code of screen.
//Update current screen layout.
lv_obj_update_layout(ui->screen);
}

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 "gui_guider.h"
#include "widgets_init.h"
#include <stdlib.h>
__attribute__((unused)) void kb_event_cb (lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *kb = lv_event_get_target(e);
if(code == LV_EVENT_READY || code == LV_EVENT_CANCEL) {
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
}
}
__attribute__((unused)) void ta_event_cb (lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
#if LV_USE_KEYBOARD || LV_USE_ZH_KEYBOARD
lv_obj_t *ta = lv_event_get_target(e);
#endif
lv_obj_t *kb = lv_event_get_user_data(e);
if (code == LV_EVENT_FOCUSED || code == LV_EVENT_CLICKED)
{
#if LV_USE_ZH_KEYBOARD != 0
lv_zh_keyboard_set_textarea(kb, ta);
#endif
#if LV_USE_KEYBOARD != 0
lv_keyboard_set_textarea(kb, ta);
#endif
lv_obj_move_foreground(kb);
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
}
if (code == LV_EVENT_CANCEL || code == LV_EVENT_DEFOCUSED)
{
#if LV_USE_ZH_KEYBOARD != 0
lv_zh_keyboard_set_textarea(kb, ta);
#endif
#if LV_USE_KEYBOARD != 0
lv_keyboard_set_textarea(kb, ta);
#endif
lv_obj_move_background(kb);
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
}
}
#if LV_USE_ANALOGCLOCK != 0
void clock_count(int *hour, int *min, int *sec)
{
(*sec)++;
if(*sec == 60)
{
*sec = 0;
(*min)++;
}
if(*min == 60)
{
*min = 0;
if(*hour < 12)
{
(*hour)++;
} else {
(*hour)++;
*hour = *hour %12;
}
}
}
#endif

View File

@ -0,0 +1,30 @@
/*
* 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.
*/
#ifndef WIDGET_INIT_H
#define WIDGET_INIT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "lvgl.h"
#include "gui_guider.h"
__attribute__((unused)) void kb_event_cb(lv_event_t *e);
__attribute__((unused)) void ta_event_cb(lv_event_t *e);
#if LV_USE_ANALOGCLOCK != 0
void clock_count(int *hour, int *min, int *sec);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -7,9 +7,12 @@
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lvgl_port.h"
#include "gui_guider.h"
static const char *TAG = "lcd";
lv_ui guider_ui;
/* LCD IO and panel */
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_handle_t panel_handle = NULL;
@ -79,32 +82,37 @@ static esp_err_t app_lvgl_init(void)
static void app_main_display(void)
{
lv_obj_t *scr = lv_scr_act();
// lv_obj_t *scr = lv_scr_act();
/* Task lock */
lvgl_port_lock(0);
// /* Task lock */
// lvgl_port_lock(0);
/* Your LVGL objects code here .... */
// /* Your LVGL objects code here .... */
/* Label */
lv_obj_t *label = lv_label_create(scr);
lv_obj_set_width(label, EXAMPLE_LCD_H_RES);
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
#if LVGL_VERSION_MAJOR == 8
lv_label_set_recolor(label, true);
lv_label_set_text(label, "Hello world");
#else
lv_label_set_text(label, LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"\n "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING);
#endif
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
// /* Label */
// lv_obj_t *label = lv_label_create(scr);
// lv_obj_set_width(label, EXAMPLE_LCD_H_RES);
// lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
// #if LVGL_VERSION_MAJOR == 8
// lv_label_set_recolor(label, true);
// lv_label_set_text(label, "Hello world");
// #else
// lv_label_set_text(label, LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"\n "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING);
// #endif
// lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
/* Button */
lv_obj_t *btn = lv_btn_create(scr);
label = lv_label_create(btn);
lv_label_set_text_static(label, "Rotate screen");
lv_obj_align(btn, LV_ALIGN_BOTTOM_MID, 0, -30);
// lv_obj_add_event_cb(btn, _app_button_cb, LV_EVENT_CLICKED, NULL);
// /* Button */
// lv_obj_t *btn = lv_btn_create(scr);
// label = lv_label_create(btn);
// lv_label_set_text_static(label, "Rotate screen");
// lv_obj_align(btn, LV_ALIGN_BOTTOM_MID, 0, -30);
// // lv_obj_add_event_cb(btn, _app_button_cb, LV_EVENT_CLICKED, NULL);
// custom_init(&guider_ui);
setup_ui(&guider_ui);
// events_init(&guider_ui);
/* Task unlock */
lvgl_port_unlock();
@ -130,7 +138,7 @@ void Gui_Task(void *pvParameter)
.reset_gpio_num = GPIO_NUM_37,
.rgb_endian = LCD_RGB_ENDIAN_RGB,
.bits_per_pixel = 16,
.color_space = ESP_LCD_COLOR_SPACE_BGR,
.color_space = ESP_LCD_COLOR_SPACE_RGB,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_st7735(io_handle, &panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
@ -139,7 +147,7 @@ void Gui_Task(void *pvParameter)
esp_lcd_panel_swap_xy(panel_handle, false);
esp_lcd_panel_mirror(panel_handle, false, false);//设置旋转
esp_lcd_panel_invert_color(panel_handle,false);//设置反色
esp_lcd_panel_invert_color(panel_handle,true);//设置反色
// uint8_t* lcd_data;
// lcd_data = malloc(128*160*2);