●定义RTC对象 pyb.RTC
●读取/设置rtc rtc.datetime([datetimetuple])
datetimetuple格式:(year, month, day, weekday, hours, minutes, seconds, subseconds) weekday is 1-7 for Monday through Sunday. subseconds counts down from 255 to 0
●设置唤醒定时器 rtc.wakeup(timeout, callback=None) timeout单位是毫秒
●获取RTC启动时间和复位源 rtc.info()
●获取/设置校正 rtc.calibration(cal) 无参数时读取校正值,有参数时设置校正值
●例子 RTC定时器2S翻转一次LED1 rtc.wakeup(2000, lambda t:pyb.LED(1).toggle())
设置/读取RTC时间
rtc = pyb.RTC() #set date time
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
#get date time
print(rtc.datetime())
|