使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第十五讲)

news2025/6/6 22:50:15
这一期讲解lvgl中日历控件的基础使用,Calendar 部件是一个经典日历,它具有以下功能:

• 通过一个7x7矩阵显示任何月份
• 显示日期名称
• 突出显示当前日期(今天)
• 突出显示任何用户定义的日期
日历是一个可编辑的小部件,它允许使用编码器或键盘导航以及指针类型的输入设备来选择和点击日期。为了使日历更具灵活性,默认情况下它不显示当前年份或月份。相反,有一些可选的 “标题” 可以附加到日历上。

日历小部件在底层使用了 Button Matrix 部件来将日期排列成矩阵形式。

• LV_PART_MAIN 日历的背景。使用所有与背景相关的样式属性。
• LV_PART_ITEMS 指日期和日期名称。
设置了按钮矩阵控制标志以区分按钮,并添加了一个自定义绘制事件来按如下方式修改按钮的属性:
o 日期名称没有边框,没有背景,用灰色绘制
o 矩阵中上个月和下个月的天数有 LV_BUTTONMATRIX_CTRL_DISABLED 标志
o 今天(你指定的日期)有较厚的边框(使用主题的主色) - 突出显示的日期具有一定透明度的主题主颜色。
默认主题在工程中的样子具体如下图所示:
在这里插入图片描述
在GUI_Guider平台提供多种模块去设置日历控件,具体如下图所示:
在这里插入图片描述
(1) mian:指的是当前主体的阴影、边框与背景。
(2) header:指的是日历的标题颜色背景以及字体大小颜色设置。
(3) weekday names:是日历中每个周的字体大小和格式
(4) highlight day:是指图中29好的状态就是高亮状态,这里可以修改颜色以及字体大小和格式。
(5) today:指代码设置当天的标识状态,目前是灰色背景,在该界面中可以修改背景颜色以及字体大小和格式。
(6) days in other month:将日历中当前月份的其他日期设置,可以设置背景颜色以及字体的大小颜色和格式。
(7) days in current month:将日历中当前月份的日期设置,可以设置背景颜色以及字体的大小颜色和格式。

以下是具体的代码:
//Write codes screen_1_calendar_1
//在 screen_1 屏幕上创建了一个日历组件 screen_1_calendar_1。
ui->screen_1_calendar_1 = lv_calendar_create(ui->screen_1);
//设置当前日期
screen_1_calendar_1_today.year = 2025;
screen_1_calendar_1_today.month = 5;
screen_1_calendar_1_today.day = 28;
lv_calendar_set_today_date(ui->screen_1_calendar_1, screen_1_calendar_1_today.year, screen_1_calendar_1_today.month, screen_1_calendar_1_today.day);
//显示日期
lv_calendar_set_showed_date(ui->screen_1_calendar_1, screen_1_calendar_1_today.year, screen_1_calendar_1_today.month);
//高亮显示日期
screen_1_calendar_1_highlihted_days[0].year = 2025;
screen_1_calendar_1_highlihted_days[0].month = 5;
screen_1_calendar_1_highlihted_days[0].day = 29;
lv_calendar_set_highlighted_dates(ui->screen_1_calendar_1, screen_1_calendar_1_highlihted_days, 1);
//Write style state: LV_STATE_DEFAULT for &style_screen_1_calendar_1_main_main_default
//设置样式
static lv_style_t style_screen_1_calendar_1_main_main_default;
ui_init_style(&style_screen_1_calendar_1_main_main_default);

lv_style_set_border_width(&style_screen_1_calendar_1_main_main_default, 1);
lv_style_set_border_opa(&style_screen_1_calendar_1_main_main_default, 255);
lv_style_set_border_color(&style_screen_1_calendar_1_main_main_default, lv_color_hex(0xc0c0c0));
lv_style_set_border_side(&style_screen_1_calendar_1_main_main_default, LV_BORDER_SIDE_FULL);
lv_style_set_bg_opa(&style_screen_1_calendar_1_main_main_default, 255);
lv_style_set_bg_color(&style_screen_1_calendar_1_main_main_default, lv_color_hex(0xffffff));
lv_style_set_bg_grad_dir(&style_screen_1_calendar_1_main_main_default, LV_GRAD_DIR_NONE);
lv_style_set_shadow_width(&style_screen_1_calendar_1_main_main_default, 0);
lv_style_set_radius(&style_screen_1_calendar_1_main_main_default, 0);
lv_obj_add_style(ui->screen_1_calendar_1, &style_screen_1_calendar_1_main_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);

//Write style state: LV_STATE_DEFAULT for &style_screen_1_calendar_1_extra_header_main_default
// 头部样式
static lv_style_t style_screen_1_calendar_1_extra_header_main_default;
ui_init_style(&style_screen_1_calendar_1_extra_header_main_default);

lv_style_set_text_color(&style_screen_1_calendar_1_extra_header_main_default, lv_color_hex(0xffffff));
lv_style_set_text_font(&style_screen_1_calendar_1_extra_header_main_default, &lv_font_montserratMedium_12);
lv_style_set_text_opa(&style_screen_1_calendar_1_extra_header_main_default, 255);
lv_style_set_bg_opa(&style_screen_1_calendar_1_extra_header_main_default, 255);
lv_style_set_bg_color(&style_screen_1_calendar_1_extra_header_main_default, lv_color_hex(0x2195f6));
lv_style_set_bg_grad_dir(&style_screen_1_calendar_1_extra_header_main_default, LV_GRAD_DIR_NONE);
lv_obj_add_style(screen_1_calendar_1_header, &style_screen_1_calendar_1_extra_header_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);

//Write style state: LV_STATE_DEFAULT for &style_screen_1_calendar_1_main_items_default
//日历按钮矩阵项样式
static lv_style_t style_screen_1_calendar_1_main_items_default;
ui_init_style(&style_screen_1_calendar_1_main_items_default);

lv_style_set_bg_opa(&style_screen_1_calendar_1_main_items_default, 0);
lv_style_set_border_width(&style_screen_1_calendar_1_main_items_default, 1);
lv_style_set_border_opa(&style_screen_1_calendar_1_main_items_default, 255);
lv_style_set_border_color(&style_screen_1_calendar_1_main_items_default, lv_color_hex(0xc0c0c0));
lv_style_set_border_side(&style_screen_1_calendar_1_main_items_default, LV_BORDER_SIDE_FULL);
lv_style_set_text_color(&style_screen_1_calendar_1_main_items_default, lv_color_hex(0x0D3055));
lv_style_set_text_font(&style_screen_1_calendar_1_main_items_default, &lv_font_montserratMedium_12);
lv_style_set_text_opa(&style_screen_1_calendar_1_main_items_default, 255);
lv_obj_add_style(lv_calendar_get_btnmatrix(ui->screen_1_calendar_1), &style_screen_1_calendar_1_main_items_default, LV_PART_ITEMS|LV_STATE_DEFAULT);

下一期讲解日历控件如何添加回调。
本文章由威三学社出品
对课程感兴趣可以私信联系

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2402204.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Vue中实现表格吸底滚动条效果,列太多时左右滚动条始终显示在页面中

1、安装 npm install el-table-horizontal-scroll 2、全局注册&#xff08;main.js&#xff09; import horizontalScroll from el-table-horizontal-scrollVue.use(horizontalScroll) 如下图&#xff0c;在main.js加上上面的代码 3、表格内引用 <el-table :data"…

BeeWorks 协同办公能力:局域网内企业级协作的全场景重构

在企业数字化办公场景中&#xff0c;BeeWorks 以强大的协同办公能力&#xff0c;将局域网内的通讯、协作、业务流程整合为统一整体。作为专注于企业级局域网环境的协作平台&#xff0c;其不仅提供即时通讯基础功能&#xff0c;更通过办公工具集成、会议能力强化、业务系统对接等…

C++课设:高效的日程管理系统

名人说&#xff1a;路漫漫其修远兮&#xff0c;吾将上下而求索。—— 屈原《离骚》 创作者&#xff1a;Code_流苏(CSDN)&#xff08;一个喜欢古诗词和编程的Coder&#x1f60a;&#xff09; 专栏介绍&#xff1a;《编程项目实战》 目录 一、C日程管理系统的时代价值1. 为什么选…

功能测试、性能测试、安全测试详解

&#x1f345; 点击文末小卡片&#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快 一、功能测试 1、单接口功能 手工测试中的单个业务模块&#xff0c;一般对应一个接口 例如&#xff1a; 登录业务------登录接口 加入购物车业务------加入购…

提示词指南 --- 提示词的基本结构

提示词指南 --- 提示词的基本结构以及三种角色 什么是Prompt (提示词)Prompt的基本结构和三种角色提示词的三种核心“角色”&#xff08;Role&#xff09; 真实例子 什么是Prompt (提示词) 我们可以把“Prompt&#xff08;提示词&#xff09;”想象成和AI聊天时你说的“一句话…

20250605使用boot-repair来恢复WIN10和ubuntu22.04.6双系统的启动

rootrootrootroot-X99-Turbo:~$ sudo apt-get install boot-repair rootrootrootroot-X99-Turbo:~$ sudo add-apt-repository ppa:yannubuntu/boot-repair rootrootrootroot-X99-Turbo:~$ sudo apt-get install boot-repair 20250605使用boot-repair来恢复WIN10和ubuntu22.04.6…

接口安全SOAPOpenAPIRESTful分类特征导入项目联动检测

1 、 API 分类特征 SOAP - WSDL OpenApi - Swagger RESTful - /v1/api/ 2 、 API 常见漏洞 OWASP API Security TOP 10 2023 3 、 API 检测流程 接口发现&#xff0c;遵循分类&#xff0c;依赖语言&#xff0c; V1/V2 多版本等 Method &#xff1a;请求方法 攻击方…

视频汇聚平台EasyCVR“明厨亮灶”方案筑牢旅游景区餐饮安全品质防线

一、背景分析​ 1&#xff09;政策监管刚性需求​&#xff1a;国家食品安全战略及 2024年《关于深化智慧城市发展的指导意见》要求构建智慧餐饮场景&#xff0c;推动数字化监管。多地将“AI明厨亮灶”纳入十四五规划考核&#xff0c;要求餐饮单位操作可视化并具备风险预警能力…

仓库自动化搬运:自动叉车与AGV选型要点及核心技术解析

自动叉车与AGV均可实现自主作业&#xff0c;无需人工驾驶即可搬运托盘化货物。然而&#xff0c;这两种解决方案存在一些关键差异。 自动叉车与AGV的对比 自动叉车与AGV是截然不同的车辆&#xff0c;其差异主要源于原始设计&#xff1a; 自动叉车是制造商对传统手动叉车进行改…

NLP学习路线图(二十五):注意力机制

在自然语言处理领域&#xff0c;序列模型一直扮演着核心角色。从早期的循环神经网络&#xff08;RNN&#xff09;到如今一统天下的Transformer模型&#xff0c;注意力机制&#xff08;Attention Mechanism&#xff09; 的引入堪称一场革命。它彻底改变了模型处理序列信息的方式…

05 APP 自动化- Appium 单点触控 多点触控

文章目录 一、单点触控查看指针的指针位置实现手势密码&#xff1a; 二、多点触控 一、单点触控 查看指针的指针位置 方便查看手势密码-九宫格每个点的坐标 实现手势密码&#xff1a; 执行手势操作&#xff1a; 按压起点 -> 移动到下一点 -> 依次移动 -> 释放&am…

[AI绘画]sd学习记录(一)软件安装以及文生图界面初识、提示词写法

目录 目录一、安装软件二、文生图各部分模块 1. 下载新模型 & 画出第一张图2. 提示词输入 2.1 设置2.2 扩展模型2.3 扩展模型权重调整2.4 其他提示词输入2.5 负向提示词2.6 生成参考 3. 采样方法4. 噪声调度器5. 迭代步数6. 提示词引导系数 一、安装软件 软件安装&…

SpringBoot(八) --- SpringBoot原理

目录 一、配置优先级 二、Bean的管理 1. Bean的作用域 2. 第三方Bean 三、SpringBoot原理 1. 起步依赖 2. 自动配置 3. 自动配置原理分析 3.1 源码解析 3.2 Conditional 一、配置优先级 SpringBoot项目当中支持三类配置文件&#xff1a; application.properties a…

C# 类和继承(抽象成员)

抽象成员 抽象成员是指设计为被覆写的函数成员。抽象成员有以下特征。 必须是一个函数成员。也就是说&#xff0c;字段和常量不能为抽象成员。必须用abstract修饰符标记。不能有实现代码块。抽象成员的代码用分号表示。 例如&#xff0c;下面取自一个类定义的代码声明了两个抽…

鸿蒙仓颉语言开发实战教程:商城登录页

听说Pura80要来了&#xff1f;感觉华为的新品像下饺子一样&#xff0c;让人目不暇接&#xff0c;每隔几天就有发布会看&#xff0c;真不错呀。 节后第一天&#xff0c;为了缓解大家假期的疲惫&#xff0c;咱们今天做点简单的内容&#xff0c;就是商城的登录页面。 其实这一次分…

JavaScript 数组与流程控制:从基础操作到实战应用

在 JavaScript 编程的世界里&#xff0c;数组是一种极为重要的数据结构&#xff0c;它就像是一个有序的 “收纳盒”&#xff0c;能够将多个值整齐地存储起来。而流程控制语句则像是 “指挥官”&#xff0c;能够按照特定的逻辑对数组进行遍历和操作。接下来&#xff0c;就让我们…

SkyWalking架构深度解析:分布式系统监控的利器

一、SkyWalking概述 SkyWalking是一款开源的APM(应用性能监控)系统&#xff0c;专门为微服务、云原生和容器化架构设计。它由Apache软件基金会孵化并毕业&#xff0c;已成为分布式系统监控领域的明星项目。 核心特性 ‌分布式追踪‌&#xff1a;跨服务调用链路的完整追踪‌服务…

vue2中的render函数

<script> export default {components: {},name: "renderElems",render (h, context) {return this.$attrs.vnode;},updated() {} } </script> <style scoped> </style>分析一下上面.vue组件&#xff1a; 组件结构&#xff1a; 这是一个非…

PARADISE:用于新生儿缺氧缺血性脑病(HIE)疾病识别与分割的个性化和区域适应性方法|文献速递-深度学习医疗AI最新文献

Title 题目 PARADISE: Personalized and regional adaptation for HIE disease identification and segmentation PARADISE&#xff1a;用于新生儿缺氧缺血性脑病&#xff08;HIE&#xff09;疾病识别与分割的个性化和区域适应性方法 1 文献速递介绍 缺氧缺血性脑病&…

WordPress子主题RiPro-V5van无授权全开源版(源码下载)

WordPress子主题RiPro-V5van无授权全开源版&#xff0c;直接上使用方法:WordPress后台上传就行 这个主题是1.0版本开源的&#xff0c;有能力的可以二次开发一下加一些自己喜欢的功能。 源码下载&#xff1a;https://download.csdn.net/download/m0_66047725/90952148 更多资…