可以显示中文了
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# 收集当前目录下所有 .c 文件
|
||||
file(GLOB_RECURSE SRC_LIST "*.c")
|
||||
|
||||
idf_component_register(SRCS ${SRC_LIST}
|
||||
idf_component_register(
|
||||
SRCS ${SRC_LIST}
|
||||
PRIV_REQUIRES spi_flash esp_driver_spi esp_driver_gpio esp_timer
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#define LV_CONF_INCLUDE_SIMPLE 1
|
||||
#define LV_LVGL_H_INCLUDE_SIMPLE
|
||||
#include "lv_conf.h"
|
||||
|
||||
/* 然后包含 lvgl.h */
|
||||
|
||||
@@ -1,81 +1,31 @@
|
||||
#include "lv_helloworld.h"
|
||||
|
||||
|
||||
static lv_style_t style_btn;
|
||||
static lv_style_t style_button_pressed;
|
||||
static lv_style_t style_button_red;
|
||||
|
||||
static lv_color_t darken(const lv_color_filter_dsc_t * dsc, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
LV_UNUSED(dsc);
|
||||
return lv_color_darken(color, opa);
|
||||
}
|
||||
|
||||
static void style_init(void)
|
||||
{
|
||||
/*Create a simple button style*/
|
||||
lv_style_init(&style_btn);
|
||||
lv_style_set_radius(&style_btn, 10);
|
||||
lv_style_set_bg_opa(&style_btn, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&style_btn, lv_palette_lighten(LV_PALETTE_GREY, 3));
|
||||
lv_style_set_bg_grad_color(&style_btn, lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_bg_grad_dir(&style_btn, LV_GRAD_DIR_VER);
|
||||
|
||||
lv_style_set_border_color(&style_btn, lv_color_black());
|
||||
lv_style_set_border_opa(&style_btn, LV_OPA_20);
|
||||
lv_style_set_border_width(&style_btn, 2);
|
||||
|
||||
lv_style_set_text_color(&style_btn, lv_color_black());
|
||||
|
||||
/*Create a style for the pressed state.
|
||||
*Use a color filter to simply modify all colors in this state*/
|
||||
static lv_color_filter_dsc_t color_filter;
|
||||
lv_color_filter_dsc_init(&color_filter, darken);
|
||||
lv_style_init(&style_button_pressed);
|
||||
lv_style_set_color_filter_dsc(&style_button_pressed, &color_filter);
|
||||
lv_style_set_color_filter_opa(&style_button_pressed, LV_OPA_20);
|
||||
|
||||
/*Create a red style. Change only some colors.*/
|
||||
lv_style_init(&style_button_red);
|
||||
lv_style_set_bg_color(&style_button_red, lv_palette_main(LV_PALETTE_RED));
|
||||
lv_style_set_bg_grad_color(&style_button_red, lv_palette_lighten(LV_PALETTE_RED, 3));
|
||||
}
|
||||
LV_FONT_DECLARE(my_cn_font);
|
||||
|
||||
/**
|
||||
* Create styles from scratch for buttons.
|
||||
*/
|
||||
void lv_example_get_started_1(void)
|
||||
{
|
||||
/*Initialize the style*/
|
||||
style_init();
|
||||
/*Change the active screen's background color*/
|
||||
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);
|
||||
|
||||
/*Create a button and use the new styles*/
|
||||
lv_obj_t * btn = lv_button_create(lv_screen_active());
|
||||
/* Remove the styles coming from the theme
|
||||
* Note that size and position are also stored as style properties
|
||||
* so lv_obj_remove_style_all will remove the set size and position too */
|
||||
lv_obj_remove_style_all(btn);
|
||||
lv_obj_set_pos(btn, 10, 10);
|
||||
lv_obj_set_size(btn, 120, 50);
|
||||
lv_obj_add_style(btn, &style_btn, 0);
|
||||
lv_obj_add_style(btn, &style_button_pressed, LV_STATE_PRESSED);
|
||||
static lv_style_t style_label;
|
||||
lv_style_init(&style_label);
|
||||
lv_style_set_text_font(&style_label, &my_cn_font); // 关键:设置字体
|
||||
|
||||
/*Add a label to the button*/
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Button");
|
||||
lv_obj_center(label);
|
||||
/*Create a white label, set its text and align it to the center*/
|
||||
lv_obj_t *label = lv_label_create(lv_screen_active());
|
||||
lv_obj_add_style(label, &style_label, 0);
|
||||
lv_label_set_text(label, "Hello world 你好世界!");
|
||||
lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Create another button and use the red style too*/
|
||||
lv_obj_t * btn2 = lv_button_create(lv_screen_active());
|
||||
lv_obj_remove_style_all(btn2); /*Remove the styles coming from the theme*/
|
||||
lv_obj_set_pos(btn2, 10, 80);
|
||||
lv_obj_set_size(btn2, 120, 50);
|
||||
lv_obj_add_style(btn2, &style_btn, 0);
|
||||
lv_obj_add_style(btn2, &style_button_red, 0);
|
||||
lv_obj_add_style(btn2, &style_button_pressed, LV_STATE_PRESSED);
|
||||
lv_obj_set_style_radius(btn2, LV_RADIUS_CIRCLE, 0); /*Add a local style too*/
|
||||
lv_obj_t *btn = lv_button_create(lv_screen_active()); /*Add a button the current screen*/
|
||||
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
|
||||
lv_obj_set_size(btn, 120, 50); /*Set its size*/
|
||||
|
||||
label = lv_label_create(btn2);
|
||||
lv_label_set_text(label, "Button 2");
|
||||
lv_obj_center(label);
|
||||
lv_obj_t *label2 = lv_label_create(btn); /*Add a label to the button*/
|
||||
lv_label_set_text(label2, "Button"); /*Set the labels text*/
|
||||
lv_obj_center(label2);
|
||||
}
|
||||
@@ -699,7 +699,7 @@
|
||||
/** Enable handling large font and/or fonts with a lot of characters.
|
||||
* The limit depends on the font size, font face and bpp.
|
||||
* A compiler error will be triggered if a font needs it. */
|
||||
#define LV_FONT_FMT_TXT_LARGE 0
|
||||
#define LV_FONT_FMT_TXT_LARGE 1
|
||||
|
||||
/** Enables/disables support for compressed fonts. */
|
||||
#define LV_USE_FONT_COMPRESSED 0
|
||||
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "lvgl.h"
|
||||
#include "lvgl/lvgl.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 0x1D0000,
|
||||
storage, data, spiffs, , 0xF0000,
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
lv_font_conv --font HarmonyOS_Sans_SC_Regular.ttf --size 16 --bpp 1 --range 0x20-0x7F --range 0x3000-0x303F --range 0xFF00-0xFFEF --range 0x4E00-0x9FFF --format lvgl --output my_cn_font.c
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+147419
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user