← index #5733PR #10607
Likely Duplicate · high · value 5.449
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

ports/RTC: Attempt to reduce the inconsistencies between the port's RTC implementation.

mergedby robert-hhopened 2023-01-28updated 2024-12-20
portsdocs

This PR follows the issue #10578 and #5553 and other discussions about the topic. It consists of the commits:

  • docs/quickref: Fix the documentation of rtc.datetime(), which makes the documentation of rtc.datetime() consistent to the implementation for all ports.
  • mimxrt/machine_rtc.c: Drop rtc.now() Keep it at the WiPy port for legacy,
  • ports/RTC: Rework the availability and interface of rtc.init(), which drops rtc.init() from the SAMD port and makes it consistent to the documentation and the WiPy port for the ports ESP32 and MIMXRT. But rtc.init() could as well be dropped for the latter ones and just kept for WiPy.

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