近期在开发esp32+lvgl 做嵌入式系统时,因为 UI 编辑太复杂,因此借用 GUI-guider,但是做出来的界面在界面切换的时候会像视频里一样滚动,并且还会错位,有没有人知道怎么办啊,急
下面是代码
——————————————————————————以下是events_init.c——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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
static void Home_btn_1_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.Qwen, guider_ui.Qwen_del, &guider_ui.Home_del, setup_scr_Qwen, LV_SCR_LOAD_ANIM_NONE, 500, 200, true, false);
break;
}
default:
break;
}
}
void events_init_Home (lv_ui *ui)
{
lv_obj_add_event_cb(ui->Home_btn_1, Home_btn_1_event_handler, LV_EVENT_ALL, ui);
}
static void Qwen_back_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.Home, guider_ui.Home_del, &guider_ui.Qwen_del, setup_scr_Home, LV_SCR_LOAD_ANIM_NONE, 500, 200, true, true);
break;
}
default:
break;
}
}
void events_init_Qwen (lv_ui *ui)
{
lv_obj_add_event_cb(ui->Qwen_back, Qwen_back_event_handler, LV_EVENT_ALL, ui);
}
void events_init(lv_ui *ui)
{
}
——————————————————————————以下是events_init.h——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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);
void events_init_Home(lv_ui *ui);
void events_init_Qwen(lv_ui *ui);
#ifdef __cplusplus
}
#endif
#endif /* EVENT_CB_H_ */
——————————————————————————以下是gui-guider.c——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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);
lv_anim_start(&anim);
}
void init_scr_del_flag(lv_ui *ui)
{
ui->Home_del = true;
ui->Qwen_del = true;
}
void setup_ui(lv_ui *ui)
{
init_scr_del_flag(ui);
setup_scr_Home(ui);
lv_scr_load(ui->Home);
}
——————————————————————————以下是gui-guider.h——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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 *Home;
bool Home_del;
lv_obj_t *g_kb_Home;
lv_obj_t *Home_TimeShow;
lv_obj_t *Home_dateshow;
lv_obj_t *Home_btn_1;
lv_obj_t *Home_btn_1_label;
lv_obj_t *Qwen;
bool Qwen_del;
lv_obj_t *g_kb_Qwen;
lv_obj_t *Qwen_send;
lv_obj_t *Qwen_send_label;
lv_obj_t *Qwen_input;
lv_obj_t *Qwen_chatm;
lv_obj_t *Qwen_back;
lv_obj_t *Qwen_back_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_Home(lv_ui *ui);
void setup_scr_Qwen(lv_ui *ui);
LV_FONT_DECLARE(lv_font_montserratMedium_45)
LV_FONT_DECLARE(lv_font_montserratMedium_16)
LV_FONT_DECLARE(lv_font_montserratMedium_30)
LV_FONT_DECLARE(lv_font_montserratMedium_12)
LV_FONT_DECLARE(lv_font_SourceHanSerifSC_Regular_16)
LV_FONT_DECLARE(lv_font_SourceHanSerifSC_Regular_12)
LV_FONT_DECLARE(lv_font_SourceHanSerifSC_Regular_18)
#ifdef __cplusplus
}
#endif
#endif
——————————————————————————以下是setup_scr_Home.c——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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_Home(lv_ui *ui)
{
//Write codes Home
ui->Home = lv_obj_create(NULL);
ui->g_kb_Home = lv_keyboard_create(ui->Home);
lv_obj_add_event_cb(ui->g_kb_Home, kb_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_flag(ui->g_kb_Home, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_style_text_font(ui->g_kb_Home, &lv_font_SourceHanSerifSC_Regular_18, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_size(ui->Home, 800, 480);
lv_obj_set_scrollbar_mode(ui->Home, LV_SCROLLBAR_MODE_OFF);
//Write style for Home, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->Home, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->Home, lv_color_hex(0x021426), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->Home, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes Home_TimeShow
ui->Home_TimeShow = lv_label_create(ui->Home);
lv_label_set_text(ui->Home_TimeShow, "12:00");
lv_label_set_long_mode(ui->Home_TimeShow, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(ui->Home_TimeShow, 40, 39);
lv_obj_set_size(ui->Home_TimeShow, 158, 45);
//Write style for Home_TimeShow, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->Home_TimeShow, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->Home_TimeShow, &lv_font_montserratMedium_45, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->Home_TimeShow, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(ui->Home_TimeShow, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->Home_TimeShow, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->Home_TimeShow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes Home_dateshow
ui->Home_dateshow = lv_label_create(ui->Home);
lv_label_set_text(ui->Home_dateshow, "23/8/2");
lv_label_set_long_mode(ui->Home_dateshow, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(ui->Home_dateshow, 64, 94);
lv_obj_set_size(ui->Home_dateshow, 105, 33);
//Write style for Home_dateshow, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->Home_dateshow, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->Home_dateshow, &lv_font_montserratMedium_30, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->Home_dateshow, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(ui->Home_dateshow, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->Home_dateshow, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->Home_dateshow, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes Home_btn_1
ui->Home_btn_1 = lv_btn_create(ui->Home);
ui->Home_btn_1_label = lv_label_create(ui->Home_btn_1);
lv_label_set_text(ui->Home_btn_1_label, "Qwen");
lv_label_set_long_mode(ui->Home_btn_1_label, LV_LABEL_LONG_WRAP);
lv_obj_align(ui->Home_btn_1_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(ui->Home_btn_1, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->Home_btn_1_label, LV_PCT(100));
lv_obj_set_pos(ui->Home_btn_1, 246, 52);
lv_obj_set_size(ui->Home_btn_1, 100, 100);
//Write style for Home_btn_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->Home_btn_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->Home_btn_1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->Home_btn_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->Home_btn_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->Home_btn_1, 5, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->Home_btn_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->Home_btn_1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->Home_btn_1, &lv_font_montserratMedium_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->Home_btn_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->Home_btn_1, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
//The custom code of Home.
//Update current screen layout.
lv_obj_update_layout(ui->Home);
//Init events for screen.
events_init_Home(ui);
}
——————————————————————————以下是setup_scr_Qwen.c——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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_Qwen(lv_ui *ui)
{
//Write codes Qwen
ui->Qwen = lv_obj_create(NULL);
ui->g_kb_Qwen = lv_keyboard_create(ui->Qwen);
lv_obj_add_event_cb(ui->g_kb_Qwen, kb_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_flag(ui->g_kb_Qwen, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_style_text_font(ui->g_kb_Qwen, &lv_font_SourceHanSerifSC_Regular_18, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_size(ui->Qwen, 800, 480);
lv_obj_set_scrollbar_mode(ui->Qwen, LV_SCROLLBAR_MODE_OFF);
//Write style for Qwen, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->Qwen, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->Qwen, lv_color_hex(0x000000), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->Qwen, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes Qwen_send
ui->Qwen_send = lv_btn_create(ui->Qwen);
ui->Qwen_send_label = lv_label_create(ui->Qwen_send);
lv_label_set_text(ui->Qwen_send_label, "发送");
lv_label_set_long_mode(ui->Qwen_send_label, LV_LABEL_LONG_WRAP);
lv_obj_align(ui->Qwen_send_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(ui->Qwen_send, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->Qwen_send_label, LV_PCT(100));
lv_obj_set_pos(ui->Qwen_send, 645, 398);
lv_obj_set_size(ui->Qwen_send, 100, 50);
//Write style for Qwen_send, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->Qwen_send, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->Qwen_send, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->Qwen_send, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->Qwen_send, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->Qwen_send, 5, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->Qwen_send, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->Qwen_send, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->Qwen_send, &lv_font_SourceHanSerifSC_Regular_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->Qwen_send, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->Qwen_send, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes Qwen_input
ui->Qwen_input = lv_textarea_create(ui->Qwen);
lv_textarea_set_text(ui->Qwen_input, "");
lv_textarea_set_placeholder_text(ui->Qwen_input, "");
lv_textarea_set_password_bullet(ui->Qwen_input, "*");
lv_textarea_set_password_mode(ui->Qwen_input, false);
lv_textarea_set_one_line(ui->Qwen_input, false);
lv_textarea_set_accepted_chars(ui->Qwen_input, "");
lv_textarea_set_max_length(ui->Qwen_input, 100);
#if LV_USE_KEYBOARD != 0 || LV_USE_ZH_KEYBOARD != 0
lv_obj_add_event_cb(ui->Qwen_input, ta_event_cb, LV_EVENT_ALL, ui->g_kb_Qwen);
#endif
lv_obj_set_pos(ui->Qwen_input, 35, 398);
lv_obj_set_size(ui->Qwen_input, 592, 58);
//Write style for Qwen_input, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_text_color(ui->Qwen_input, lv_color_hex(0x000000), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->Qwen_input, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->Qwen_input, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(ui->Qwen_input, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->Qwen_input, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->Qwen_input, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->Qwen_input, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->Qwen_input, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->Qwen_input, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui->Qwen_input, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui->Qwen_input, lv_color_hex(0xe6e6e6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_side(ui->Qwen_input, LV_BORDER_SIDE_FULL, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->Qwen_input, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->Qwen_input, 4, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(ui->Qwen_input, 4, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(ui->Qwen_input, 4, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->Qwen_input, 4, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write style for Qwen_input, Part: LV_PART_SCROLLBAR, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->Qwen_input, 255, LV_PART_SCROLLBAR|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->Qwen_input, lv_color_hex(0x2195f6), LV_PART_SCROLLBAR|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->Qwen_input, LV_GRAD_DIR_NONE, LV_PART_SCROLLBAR|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->Qwen_input, 0, LV_PART_SCROLLBAR|LV_STATE_DEFAULT);
//Write codes Qwen_chatm
ui->Qwen_chatm = lv_list_create(ui->Qwen);
lv_obj_set_pos(ui->Qwen_chatm, 34, 32);
lv_obj_set_size(ui->Qwen_chatm, 707, 343);
lv_obj_set_scrollbar_mode(ui->Qwen_chatm, LV_SCROLLBAR_MODE_OFF);
//Write style state: LV_STATE_DEFAULT for &style_Qwen_chatm_main_main_default
static lv_style_t style_Qwen_chatm_main_main_default;
ui_init_style(&style_Qwen_chatm_main_main_default);
lv_style_set_pad_top(&style_Qwen_chatm_main_main_default, 5);
lv_style_set_pad_left(&style_Qwen_chatm_main_main_default, 5);
lv_style_set_pad_right(&style_Qwen_chatm_main_main_default, 5);
lv_style_set_pad_bottom(&style_Qwen_chatm_main_main_default, 5);
lv_style_set_bg_opa(&style_Qwen_chatm_main_main_default, 125);
lv_style_set_bg_color(&style_Qwen_chatm_main_main_default, lv_color_hex(0x00305c));
lv_style_set_bg_grad_dir(&style_Qwen_chatm_main_main_default, LV_GRAD_DIR_NONE);
lv_style_set_border_width(&style_Qwen_chatm_main_main_default, 1);
lv_style_set_border_opa(&style_Qwen_chatm_main_main_default, 255);
lv_style_set_border_color(&style_Qwen_chatm_main_main_default, lv_color_hex(0xe1e6ee));
lv_style_set_border_side(&style_Qwen_chatm_main_main_default, LV_BORDER_SIDE_FULL);
lv_style_set_radius(&style_Qwen_chatm_main_main_default, 3);
lv_style_set_shadow_width(&style_Qwen_chatm_main_main_default, 0);
lv_obj_add_style(ui->Qwen_chatm, &style_Qwen_chatm_main_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write style state: LV_STATE_DEFAULT for &style_Qwen_chatm_main_scrollbar_default
static lv_style_t style_Qwen_chatm_main_scrollbar_default;
ui_init_style(&style_Qwen_chatm_main_scrollbar_default);
lv_style_set_radius(&style_Qwen_chatm_main_scrollbar_default, 3);
lv_style_set_bg_opa(&style_Qwen_chatm_main_scrollbar_default, 255);
lv_style_set_bg_color(&style_Qwen_chatm_main_scrollbar_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_Qwen_chatm_main_scrollbar_default, LV_GRAD_DIR_NONE);
lv_obj_add_style(ui->Qwen_chatm, &style_Qwen_chatm_main_scrollbar_default, LV_PART_SCROLLBAR|LV_STATE_DEFAULT);
//Write style state: LV_STATE_DEFAULT for &style_Qwen_chatm_extra_btns_main_default
static lv_style_t style_Qwen_chatm_extra_btns_main_default;
ui_init_style(&style_Qwen_chatm_extra_btns_main_default);
lv_style_set_pad_top(&style_Qwen_chatm_extra_btns_main_default, 5);
lv_style_set_pad_left(&style_Qwen_chatm_extra_btns_main_default, 5);
lv_style_set_pad_right(&style_Qwen_chatm_extra_btns_main_default, 5);
lv_style_set_pad_bottom(&style_Qwen_chatm_extra_btns_main_default, 5);
lv_style_set_border_width(&style_Qwen_chatm_extra_btns_main_default, 0);
lv_style_set_text_color(&style_Qwen_chatm_extra_btns_main_default, lv_color_hex(0x0D3055));
lv_style_set_text_font(&style_Qwen_chatm_extra_btns_main_default, &lv_font_montserratMedium_12);
lv_style_set_text_opa(&style_Qwen_chatm_extra_btns_main_default, 255);
lv_style_set_radius(&style_Qwen_chatm_extra_btns_main_default, 3);
lv_style_set_bg_opa(&style_Qwen_chatm_extra_btns_main_default, 255);
lv_style_set_bg_color(&style_Qwen_chatm_extra_btns_main_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_Qwen_chatm_extra_btns_main_default, LV_GRAD_DIR_NONE);
//Write style state: LV_STATE_DEFAULT for &style_Qwen_chatm_extra_texts_main_default
static lv_style_t style_Qwen_chatm_extra_texts_main_default;
ui_init_style(&style_Qwen_chatm_extra_texts_main_default);
lv_style_set_pad_top(&style_Qwen_chatm_extra_texts_main_default, 5);
lv_style_set_pad_left(&style_Qwen_chatm_extra_texts_main_default, 5);
lv_style_set_pad_right(&style_Qwen_chatm_extra_texts_main_default, 5);
lv_style_set_pad_bottom(&style_Qwen_chatm_extra_texts_main_default, 5);
lv_style_set_border_width(&style_Qwen_chatm_extra_texts_main_default, 0);
lv_style_set_text_color(&style_Qwen_chatm_extra_texts_main_default, lv_color_hex(0x0D3055));
lv_style_set_text_font(&style_Qwen_chatm_extra_texts_main_default, &lv_font_montserratMedium_12);
lv_style_set_text_opa(&style_Qwen_chatm_extra_texts_main_default, 255);
lv_style_set_radius(&style_Qwen_chatm_extra_texts_main_default, 3);
lv_style_set_transform_width(&style_Qwen_chatm_extra_texts_main_default, 0);
lv_style_set_bg_opa(&style_Qwen_chatm_extra_texts_main_default, 255);
lv_style_set_bg_color(&style_Qwen_chatm_extra_texts_main_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_Qwen_chatm_extra_texts_main_default, LV_GRAD_DIR_NONE);
//Write codes Qwen_back
ui->Qwen_back = lv_btn_create(ui->Qwen);
ui->Qwen_back_label = lv_label_create(ui->Qwen_back);
lv_label_set_text(ui->Qwen_back_label, " <-");
lv_label_set_long_mode(ui->Qwen_back_label, LV_LABEL_LONG_WRAP);
lv_obj_align(ui->Qwen_back_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(ui->Qwen_back, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->Qwen_back_label, LV_PCT(100));
lv_obj_set_pos(ui->Qwen_back, 35, 3);
lv_obj_set_size(ui->Qwen_back, 34, 22);
//Write style for Qwen_back, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->Qwen_back, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui->Qwen_back, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui->Qwen_back, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->Qwen_back, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->Qwen_back, 5, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->Qwen_back, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->Qwen_back, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->Qwen_back, &lv_font_montserratMedium_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->Qwen_back, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->Qwen_back, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
//The custom code of Qwen.
//Update current screen layout.
lv_obj_update_layout(ui->Qwen);
//Init events for screen.
events_init_Qwen(ui);
}
——————————————————————————以下是widgets_init.c——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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
——————————————————————————以下是widgets_init.h——————————————————————
/*
* Copyright 2024 NXP
* NXP Confidential and 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