之前没有定义rtc,所以读取失败,重新定义rtc = pyb.RTC()之后,读取成功了,但是,不是设置的时间。
复位,时间还是错误的时间,没法,重新上电之后,读取时间正确,仔细查看,发现,如果连续读取时间的话,还是有问题,就是后一次读取的时间居然比前一次的时间早,很奇怪哦
rtc = pyb.RTC()
>>> print(rtc.datetime())
(2015, 1, 1, 4, 0, 0, 0, 255)
>>> rtc.datetime((2018,6, 26, 2,16, 25, 0, 0))
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 2, 175)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 32, 252)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 33, 0)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 34, 141)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 40, 239)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 40, 80)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 40, 35)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 41, 245)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 41, 205)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 41, 160)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 25, 41, 115)
>>>
此内容由EEWORLD论坛网友kangkls原创,如需转载或用于商业用途需征得作者同意并注明出处
本帖最后由 kangkls 于 2018-6-26 17:19 编辑
http://www.jslaser.com高性价比激光测距传感器
print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 16, 96)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 27, 241)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 37, 204)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 37, 56)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 46, 58, 110)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 0, 244)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 1, 100)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 2, 179)
>>> print(rtc.datetime())
(2018, 6, 26, 2, 16, 47, 2, 126)
>>>
仔细查看,发现,如果连续读取时间的话,还是有问题,就是后一次读取的时间居然比前一次的时间早,很奇怪哦
http://www.jslaser.com高性价比激光测距传感器
datetimetuple格式:(year, month, day, weekday, hours, minutes, seconds, subseconds)
weekday is 1-7 for Monday through Sunday.
subseconds counts down from 255 to 0
就是有点不习惯。这样做的初衷是什么呢?
http://www.jslaser.com高性价比激光测距传感器