← index #5733PR #5419
Related · high · value 3.350
QUERY · ISSUE

machine.RTC.init documentation is incorrect

openby dhylandsopened 2020-03-07updated 2022-10-18

The machine.RTC documentation has some discrepancies.

The ESP8266 machine.RTC modules doesn't appear to have an init function, but rather has a datetime function.
https://github.com/micropython/micropython/blob/8db5d2d1f13aa6413be11bc13c94df72296a0070/ports/esp8266/machine_rtc.c#L127
The order of the arguments to datetime appears to be (year, month, day, wday, hour, minute, seconds, milliseconds)

The ESP32 machine.RTC module
https://github.com/micropython/micropython/blob/8db5d2d1f13aa6413be11bc13c94df72296a0070/ports/esp32/machine_rtc.c#L87
has an init function and a datetime function. The order of the arguments for datetime and init appears to be (year, month, day, hour, minute, seconds, microseconds)

The stm32 machine.RTC module forwards to pyb.RTC
https://github.com/micropython/micropython/blob/8db5d2d1f13aa6413be11bc13c94df72296a0070/ports/stm32/rtc.c#L515
which has an init function and datetime function, but the init function doesn't take any srguments. The datetime function appears to use the order (year, month, day, wday, hour, month, seconds, microseconds)

The documentation documents an init function with arguments in a different order to any of the above and doesnt't mention a datetime function.

And the EPS8266 appears to take milliseconds as the last argument, whereas the others take microseconds.

CANDIDATE · PULL REQUEST

[ESP8266] [Documentation] Add note that machine.RTC is not fully sup…

closedby oceanitesopened 2019-12-14updated 2019-12-17
docsport-esp8266

For the ESP8266 port, some methods of machine.RTC are not supported.

Add a note in the ESP8266 documentation, that RTC.now(), RTC.init(), RTC.deinit() and RTC.irq() with a handler keyword is currently not supported.

Supported are only RTC.ALARM0, RTC.alarm(), RTC.alarm_left(), RTC.datetime(), RTC.irq() and RTC.memory():

>>> from machine import rtc
>>> rtc = RTC()
>>> dir(rtc)
['__class__', 'ALARM0', 'alarm', 'alarm_left', 'datetime', 'irq', 'memory']

This is mentioned in #3220, #3710 and in #2701.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied