LVGL 总结

编程入门 行业动态 更新时间:2024-10-28 02:33:11

<a href=https://www.elefans.com/category/jswz/34/1724642.html style=LVGL 总结"/>

LVGL 总结

LVGL软件版本是V8.0

1、 lv_style_set_img_recolor_opa()设置图片不透明百分比。

2、LVGL显示png 、jpg、bmp格式文件需要添加相关的解码库,而且需要需要打开相应的宏定义【lodepng.h >> LV_PNG_USE_LV_FILESYSTEM 1】。相关解码库,可以下载LVGL最新版本,在最新版本的extra文件夹中有相关编解码源文件。

3、注意检查LVGL官网在线转换工具生成的bin文件,是否符合要求;推荐使用下面的工具生成bin文件。在使用下面工具生成bin文件时,需要确保文件路径和文件名称中不包括中文或特殊字符。​​​​​​Lvgl_image_convert_tool: 基于LVGl图片转换离线版封装的小工具,不仅有界面,还可以一键生成到项目里哦 (gitee)

lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE));/*设置边框颜色*/
lv_style_set_border_width(&style, 5);/*设置边框的宽度*/
lv_style_set_border_opa(&style, LV_OPA_50);/*设置边框的透明度*/
lv_style_set_border_side(&style, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT);/*设置显示的边框,当前设置的效果为显示下边框和右边框*/

/*设置边界*/

lv_style_set_outline_width(&style, 2);/*设置轮廓的宽度*/
lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE));/* 设置轮廓的颜色*/
lv_style_set_outline_pad(&style, 8); /*设置轮廓与边框的距离*/lv_style_set_text_color(&style, lv_palette_main(LV_PALETTE_BLUE));/*设置文本颜色*/
lv_style_set_text_letter_space(&style, 5);/*设置字符间距*/
lv_style_set_text_line_space(&style, 20);/*设置线距*/
lv_style_set_text_decor(&style, LV_TEXT_DECOR_UNDERLINE);/*设置文本下划线*/

/*背景渐变色设置*/

 lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));lv_style_set_bg_grad_color(&style, lv_palette_main(LV_PALETTE_BLUE));lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);/*Shift the gradient to the bottom*/lv_style_set_bg_main_stop(&style, 128);/*设置背景色起始位置 0-255*/                 lv_style_set_bg_grad_stop(&style, 192);/*设置背景渐变色起始位置 0-255*/

/*状态过渡*/

/*** Initialize a transition descriptor.* @param tr        pointer to a transition descriptor to initialize* @param props     an array with the properties to transition. The last element must be zero.* @param path_cb   an animation path (ease) callback. If `NULL` liner path will be used.* @param time      duration of the transition in [ms] 图片过渡过程时间* @param delay     delay before the transition in [ms] 进行过渡过程之前的等待时间* @param user_data any custom data that will be saved in the transition animation and will be available when `path_cb` is called* @example* const static lv_style_prop_t trans_props[] = { LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, 0 };*  static lv_style_transition_dsc_t trans1;*  lv_style_transition_dsc_init(&trans1, trans_props, NULL, 300, 0, NULL);*/
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data);lv_obj_add_style(obj_warning, &style_base, 0);/* 设置style_base 为样式*/
lv_obj_add_style(obj_warning, &style_warning, 0);/*style_warning 替换 style_base */

/* 动画操作说明 */

lv_anim_t a;
lv_anim_init(&a);/*初始化对象*/
lv_anim_set_var(&a, arc);/*设置动作实体*/
lv_anim_set_exec_cb(&a, set_angle);/*设置反馈动作*/
lv_anim_set_time(&a, 1000);/*设置总动作时间*/
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);    /*Just for the demo*//*设置播放次数,当前设置为无限重复动作*/
lv_anim_set_repeat_delay(&a, 1000);/*设置重复延时时间,即两次动作的间隔时间*/
lv_anim_set_values(&a, 80, 100);/*设置动作的起始位置,0-100*/lv_anim_set_playback_time(&a, 10000);/*设置回放时间*/
lv_anim_start(&a);/*启动动画*/

4、Text 文本输出颜色自定义字体。

lv_label_set_recolor(label,true);     // 开启着色模式
// 开启文本着色模式后 可以用一下方式设置文本的颜色  颜色和文本用 #包住
lv_label_set_text(label,"#颜色1 文本1# , #颜色2 文本2# , #颜色3 文本3#");    // 设置文本/*** Enable the recoloring by in-line commands* @param label         pointer to a label object* @param en            true: enable recoloring, false: disable* @example "This is a #ff0000 red# word"*/
void lv_label_set_recolor(lv_obj_t * obj, bool en);

更多推荐

LVGL 总结

本文发布于:2024-02-05 08:51:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1673922.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:LVGL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!