chore: update some code and docs to use v9 API (#5876)

Co-authored-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
zylalx1
2024-04-10 15:17:44 +08:00
committed by GitHub
parent 0143320f1f
commit 47ec2784d8
54 changed files with 115 additions and 117 deletions
+3 -3
View File
@@ -71,9 +71,9 @@ For example:
#include "demos/lv_demos.h"
...
static lv_disp_t* hal_init(void)
static lv_display_t* hal_init(void)
{
lv_disp_t* disp = NULL;
lv_display_t* disp = NULL;
...
/* TODO: init display and indev */
@@ -86,7 +86,7 @@ int main(int argc, char ** argv)
{
lv_init();
lv_disp_t* disp = hal_init();
lv_display_t* disp = hal_init();
if (disp == NULL) {
LV_LOG_ERROR("lv_demos initialization failure!");
return 1;
+10 -10
View File
@@ -77,9 +77,9 @@ static void empty_screen_cb(void)
static void moving_wallpaper_cb(void)
{
lv_obj_set_style_pad_all(lv_screen_active(), 0, 0);
LV_IMG_DECLARE(img_benchmark_cogwheel_rgb);
LV_IMAGE_DECLARE(img_benchmark_cogwheel_rgb);
lv_obj_t * img = lv_img_create(lv_screen_active());
lv_obj_t * img = lv_image_create(lv_screen_active());
lv_obj_set_size(img, lv_pct(150), lv_pct(150));
lv_image_set_src(img, &img_benchmark_cogwheel_rgb);
lv_image_set_inner_align(img, LV_IMAGE_ALIGN_TILE);
@@ -120,7 +120,7 @@ static void multiple_rgb_images_cb(void)
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
lv_obj_set_style_pad_row(lv_screen_active(), 20, 0);
LV_IMG_DECLARE(img_benchmark_cogwheel_rgb);
LV_IMAGE_DECLARE(img_benchmark_cogwheel_rgb);
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 116;
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 116) / 116;
@@ -131,7 +131,7 @@ static void multiple_rgb_images_cb(void)
for(y = 0; y < ver_cnt; y++) {
int32_t x;
for(x = 0; x < hor_cnt; x++) {
lv_obj_t * obj = lv_img_create(lv_screen_active());
lv_obj_t * obj = lv_image_create(lv_screen_active());
lv_image_set_src(obj, &img_benchmark_cogwheel_rgb);
if(x == 0) lv_obj_add_flag(obj, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
@@ -146,7 +146,7 @@ static void multiple_argb_images_cb(void)
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
lv_obj_set_style_pad_row(lv_screen_active(), 20, 0);
LV_IMG_DECLARE(img_benchmark_cogwheel_argb);
LV_IMAGE_DECLARE(img_benchmark_cogwheel_argb);
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 116;
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 116) / 116;
@@ -157,7 +157,7 @@ static void multiple_argb_images_cb(void)
for(y = 0; y < ver_cnt; y++) {
int32_t x;
for(x = 0; x < hor_cnt; x++) {
lv_obj_t * obj = lv_img_create(lv_screen_active());
lv_obj_t * obj = lv_image_create(lv_screen_active());
lv_image_set_src(obj, &img_benchmark_cogwheel_argb);
if(x == 0) lv_obj_add_flag(obj, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
@@ -172,7 +172,7 @@ static void rotated_argb_image_cb(void)
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
lv_obj_set_style_pad_row(lv_screen_active(), 20, 0);
LV_IMG_DECLARE(img_benchmark_cogwheel_argb);
LV_IMAGE_DECLARE(img_benchmark_cogwheel_argb);
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 116;
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 116) / 116;
@@ -183,7 +183,7 @@ static void rotated_argb_image_cb(void)
for(y = 0; y < ver_cnt; y++) {
int32_t x;
for(x = 0; x < hor_cnt; x++) {
lv_obj_t * obj = lv_img_create(lv_screen_active());
lv_obj_t * obj = lv_image_create(lv_screen_active());
lv_image_set_src(obj, &img_benchmark_cogwheel_argb);
if(x == 0) lv_obj_add_flag(obj, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
@@ -241,7 +241,7 @@ static void multiple_arcs_cb(void)
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_ROW_WRAP);
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
LV_IMG_DECLARE(img_benchmark_cogwheel_argb);
LV_IMAGE_DECLARE(img_benchmark_cogwheel_argb);
int32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / lv_dpx(160);
int32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 16) / lv_dpx(160);
@@ -761,7 +761,7 @@ static lv_obj_t * card_create(void)
lv_obj_set_size(panel, 270, 120);
lv_obj_set_style_pad_all(panel, 8, 0);
LV_IMG_DECLARE(img_transform_avatar_15);
LV_IMAGE_DECLARE(img_transform_avatar_15);
lv_obj_t * child = lv_image_create(panel);
lv_obj_align(child, LV_ALIGN_LEFT_MID, 0, 0);
lv_image_set_src(child, &img_transform_avatar_15);
File diff suppressed because one or more lines are too long
@@ -445,7 +445,7 @@ img_lv_demo_music_cover_1_map[] = {
};
const lv_img_dsc_t img_lv_demo_music_cover_1 = {
const lv_image_dsc_t img_lv_demo_music_cover_1 = {
.header.w = 428,
.header.h = 428,
.header.cf = LV_COLOR_FORMAT_ARGB8888,
@@ -185,7 +185,7 @@ const LV_ATTRIBUTE_MEM_ALIGN uint8_t img_lv_demo_music_cover_2_map[] = {
};
lv_img_dsc_t img_lv_demo_music_cover_2 = {
const lv_image_dsc_t img_lv_demo_music_cover_2 = {
.header.w = 176,
.header.h = 175,
.header.cf = LV_COLOR_FORMAT_ARGB8888,
@@ -445,7 +445,7 @@ img_lv_demo_music_cover_2_map[] = {
};
const lv_img_dsc_t img_lv_demo_music_cover_2 = {
const lv_image_dsc_t img_lv_demo_music_cover_2 = {
.header.w = 428,
.header.h = 428,
.header.cf = LV_COLOR_FORMAT_ARGB8888,
@@ -185,7 +185,7 @@ const LV_ATTRIBUTE_MEM_ALIGN uint8_t img_lv_demo_music_cover_3_map[] = {
};
lv_img_dsc_t img_lv_demo_music_cover_3 = {
const lv_image_dsc_t img_lv_demo_music_cover_3 = {
.header.w = 176,
.header.h = 175,
.header.cf = LV_COLOR_FORMAT_ARGB8888,
@@ -444,7 +444,7 @@ img_lv_demo_music_cover_3_map[] = {
};
const lv_img_dsc_t img_lv_demo_music_cover_3 = {
const lv_image_dsc_t img_lv_demo_music_cover_3 = {
.header.w = 428,
.header.h = 428,
.header.cf = LV_COLOR_FORMAT_ARGB8888,
@@ -55,7 +55,7 @@ img_render_lvgl_logo_argb8888_map[] = {
0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0xd7, 0x33, 0x01, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd9, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd6, 0x33, 0x00, 0x01, 0xd7, 0x33, 0x01, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd6, 0x33, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd7, 0x33, 0x00, 0x00, 0xd9, 0x28, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x1c, 0x1c, 0x25, 0x23, 0x1e, 0x1e, 0x33, 0x22, 0x1e, 0x1e, 0x33, 0x23, 0x1e, 0x1e, 0x33, 0x23, 0x1e, 0x1e, 0x33, 0x23, 0x1e, 0x1e, 0x33, 0x20, 0x20, 0x20, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const lv_img_dsc_t img_render_lvgl_logo_argb8888 = {
const lv_image_dsc_t img_render_lvgl_logo_argb8888 = {
.header.cf = LV_COLOR_FORMAT_ARGB8888,
.header.w = 30,
.header.h = 30,
@@ -56,7 +56,7 @@ img_render_lvgl_logo_rgb565_map[] = {
0xff, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x7e, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x5d, 0xff, 0x7e, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0x5d, 0xef, 0x5d, 0xef, 0x5d, 0xef, 0x5d, 0xef, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
const lv_img_dsc_t img_render_lvgl_logo_rgb565 = {
const lv_image_dsc_t img_render_lvgl_logo_rgb565 = {
.header.cf = LV_COLOR_FORMAT_RGB565,
.header.w = 30,
.header.h = 30,
@@ -195,7 +195,7 @@ img_render_lvgl_logo_rgb888_map[] = {
0xe7, 0xe6, 0xe6, 0xfb, 0xfa, 0xfa, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
};
const lv_img_dsc_t img_render_lvgl_logo_rgb888 = {
const lv_image_dsc_t img_render_lvgl_logo_rgb888 = {
.header.cf = LV_COLOR_FORMAT_RGB888,
.header.w = 30,
.header.h = 30,
@@ -55,7 +55,7 @@ img_render_lvgl_logo_xrgb8888_map[] = {
0xff, 0xff, 0xff, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe6, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe6, 0xf8, 0xff, 0xed, 0xed, 0xf9, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xe7, 0xe7, 0xf8, 0xff, 0xed, 0xed, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xee, 0xee, 0xef, 0xff, 0xe8, 0xe7, 0xe7, 0xff, 0xe8, 0xe7, 0xe7, 0xff, 0xe8, 0xe7, 0xe7, 0xff, 0xe8, 0xe7, 0xe7, 0xff, 0xe8, 0xe7, 0xe7, 0xff, 0xfc, 0xfb, 0xfb, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
const lv_img_dsc_t img_render_lvgl_logo_xrgb8888 = {
const lv_image_dsc_t img_render_lvgl_logo_xrgb8888 = {
.header.cf = LV_COLOR_FORMAT_XRGB8888,
.header.w = 30,
.header.h = 30,
+4 -4
View File
@@ -331,10 +331,10 @@ static lv_obj_t * image_obj_create(lv_obj_t * parent, int32_t col, int32_t row,
static void image_core_cb(lv_obj_t * parent, bool recolor)
{
LV_IMG_DECLARE(img_render_lvgl_logo_xrgb8888);
LV_IMG_DECLARE(img_render_lvgl_logo_rgb888);
LV_IMG_DECLARE(img_render_lvgl_logo_rgb565);
LV_IMG_DECLARE(img_render_lvgl_logo_argb8888);
LV_IMAGE_DECLARE(img_render_lvgl_logo_xrgb8888);
LV_IMAGE_DECLARE(img_render_lvgl_logo_rgb888);
LV_IMAGE_DECLARE(img_render_lvgl_logo_rgb565);
LV_IMAGE_DECLARE(img_render_lvgl_logo_argb8888);
const void * srcs[] = {
&img_render_lvgl_logo_argb8888,
&img_render_lvgl_logo_xrgb8888,
+2 -2
View File
@@ -146,7 +146,7 @@ static void obj_test_task_cb(lv_timer_t * tmr)
obj = lv_button_create(main_page);
lv_obj_set_size(obj, 100, 70);
lv_obj_set_style_bg_image_src(obj, LV_SYMBOL_DUMMY"Text from\nstyle", 0);
lv_obj_delete_async(obj); /*Delete on next call of `lv_task_handler` (so not now)*/
lv_obj_delete_async(obj); /*Delete on next call of `lv_timer_handler` (so not now)*/
break;
case 5:
@@ -299,7 +299,7 @@ static void obj_test_task_cb(lv_timer_t * tmr)
obj = lv_table_create(main_page);
lv_table_set_cell_value(obj, 0, 0, "0,0");
lv_table_set_cell_value_fmt(obj, 3, 0, "%d,%d", 5, 0);
lv_table_set_row_cnt(obj, 5);
lv_table_set_row_count(obj, 5);
lv_table_set_cell_value_fmt(obj, 1, 0, "%s", "1,0");
lv_table_set_cell_value(obj, 1, 3, "1,3");
break;
@@ -266,7 +266,7 @@ void lv_demo_vector_graphic(void)
lv_draw_buf_t * draw_buf = lv_draw_buf_create(WIDTH, HEIGHT, LV_COLOR_FORMAT_ARGB8888, LV_STRIDE_AUTO);
lv_draw_buf_clear(draw_buf, NULL);
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
lv_canvas_set_draw_buf(canvas, draw_buf);
lv_obj_add_event_cb(canvas, delete_event_cb, LV_EVENT_DELETE, NULL);
+1 -1
View File
@@ -841,7 +841,7 @@ static void analytics_create(lv_obj_t * parent)
lv_scale_section_set_style(section, LV_PART_INDICATOR, &scale3_section3_indicator_style);
lv_scale_section_set_style(section, LV_PART_ITEMS, &scale3_section3_tick_style);
LV_IMG_DECLARE(img_demo_widgets_needle);
LV_IMAGE_DECLARE(img_demo_widgets_needle);
lv_obj_t * needle = lv_image_create(scale3);
lv_image_set_src(needle, &img_demo_widgets_needle);
lv_image_set_pivot(needle, 3, 4);