当前位置:网站首页>1.11 haas506 2.0开发教程-driver-RTC(仅支持2.2以上版本)
1.11 haas506 2.0开发教程-driver-RTC(仅支持2.2以上版本)
2022-06-22 11:10:00 【智云服】
haas506 2.0开发教程-driver-RTC
1.硬件图

2.开机闹钟设置
(1)案例说明
- RTC是开发板内置时钟接口,可以用于设置时间、设置开机闹钟等。
- 本案例设置一个简易自动开机闹钟。
main.py
from driver import RTC
import utime as time
import system
#串口实例化
rtc = RTC()
rtc.open()
#设置rtc时间
rtc.setTime(2022, 6, 8, 15, 34, 1)
time.sleep_ms(200)
#获取rtc时间
print(rtc.getTime())
#设置rtc时间,当rtc时间到闹钟时间时,自动开机重启
rtc.setAlarm(2022, 6, 8, 15, 34,15)
''' #关闭闹钟,添加后不会自动开机 rtc.disableAlarm() '''
#关机
system.poweroff()
#程序运行10秒后会自动重启开机
输出
(2022, 6, 8, 15, 34, 1)
#10秒后重启
(2022, 6, 8, 15, 34, 1)
#10秒后重启
(2022, 6, 8, 15, 34, 1)
...
3.Class-RTC
| open | close | getTime | setTime | setAlarm | disableAlarm |
|---|---|---|---|---|---|
| 打开并创建RTC 实例 | 关闭RTC实例 | 读取RTC 时间数据 | 设置RTC时间数据 | 设置闹钟到期时间 | 关闭闹钟 |
RTC - 创建RTC对象
- 函数原型:
rtcObj = RTC()
- 参数说明:
无
open - 打开并创建RTC 实例
函数功能:
打开并创建RTC 实例函数原型:
RTC.open()
- 参数说明:
无
close - 关闭RTC实例
函数功能:
关闭RTC实例注意事项:
需确保要关闭的RTC处于open状态函数原型:
RTC.close()
- 参数说明:
无
getTime - 读取RTC 时间数据(utc时间)
函数功能:
读取RTC 时间数据(utc时间)函数原型:
RTC.getTime()
参数说明:
无返回值:
设置成功,返回类型,元组(year, month, date, hr, min, sec)
setTime - 设置RTC时间数据(utc时间)
函数功能:
设置RTC时间数据(utc时间)函数原型:
RTC.setTime(year, month, date, hr, min, sec)
- 参数说明:
| 参数 | 类型 | 必选参数? | 说明 |
|---|---|---|---|
| 时间 | tuple | 是 | 参数元组(year, month, date, hr, min, sec) |
setAlarm - 设置闹钟到期时间(utc时间)
函数功能: 设置闹钟到期时间(utc时间),当到了到期时间就会唤醒开机
函数原型:
RTC.setAlarm(year, month, date, hr, min, sec)
- 参数说明:
| 参数 | 类型 | 必选参数? | 说明 |
|---|---|---|---|
| 时间 | tuple | 是 | 参数元组(year, month, date, hr, min, sec) |
disableAlarm - 关闭闹钟
函数功能: 关闭闹钟
函数原型:
RTC.disableAlarm()
- 参数说明:
无
边栏推荐
- Leetcode algorithm refers to offer 24 Reverse linked list
- 分治思想在海量数据处理中的应用
- xlrd. biffh. XLRDError: Excel xlsx file; Not supported solution
- R语言使用自定义函数编写深度学习阶跃step激活函数、并可视化阶跃step激活函数
- Puzzle (019) plane forward problem
- Wechat applet project example - image processing gadget (self-made low configuration version of Meitu XiuXiu)
- 迪利克雷前缀和学习笔记
- puzzle(019)平面正推问题
- 牛客练习赛94D题解
- IDE 的主题应该用亮色还是暗色?终极答案来了!
猜你喜欢

Ones attends the first "Lean Software Engineering Conference" to share performance improvement practices

Common thread scheduling methods

IDE 的主题应该用亮色还是暗色?终极答案来了!

Puzzle (019) plane forward problem

Electron adding SQLite database

微信小程序项目实例——图片处理小工具(自制低配版美图秀秀)

Should the theme of the IDE be bright or dark? Here comes the ultimate answer!

electron添加SQLite数据库

2022年遵义市土地基准地价矢量数据(WGS84)

Security risks exist in open source code: an average of 49 vulnerabilities exist in a project
随机推荐
R language performs two sample t-test on the specified covariates based on the with function, and the t.test function performs Welch two sample t-test analysis and two independent sample t-test on the
R language uses GLM function to build Poisson log linear regression model, processes three-dimensional contingency table data to build saturation model, and uses summary function to obtain model summa
交换类排序法
CVPR 2022 oral | a new motion oriented point cloud single target tracking paradigm
Rtklib postpos carding (taking single point positioning as an example)
Understanding of thread deadlock
PHP website, how to achieve the function of batch printing express orders?
[cloud picture] episode 244 three minute understanding of container image service
Getting to know elastricearch
R语言使用glm函数构建泊松对数线性回归模型处理三维列联表数据构建饱和模型、使用summary函数获取模型汇总统计信息
微信小程序项目实例——图片处理小工具(自制低配版美图秀秀)
6-13 improving load performance - application cache
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、使用可视化分析检验倾向性评分匹配后样本中的所有协变量的平衡情况
本周四晚19:00战码先锋第7期直播丨三方应用开发者如何为开源做贡献
How to improve customer conversion rate on the official website
Flink状态管理
Interpretation of basic requirements for classified protection of network security (GBT 22239-2019)
Popular understanding of TCP 3-time handshake
CF751D Difficult Mountain
SQLMap-hh