10000 machine.RTC.init documentation is incorrect · Issue #5733 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

machine.RTC.init documentation is incorrect #5733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dhylands opened this issue Mar 7, 2020 · 5 comments
Open

machine.RTC.init documentation is incorrect #5733

dhylands opened this issue Mar 7, 2020 · 5 comments

Comments

@dhylands
Copy link
Contributor
dhylands commented Mar 7, 2020

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.

STATIC mp_obj_t pyb_rtc_datetime(size_t n_args, const mp_obj_t *args) {

The order of the arguments to datetime appears to be (year, month, day, wday, hour, minute, seconds, milliseconds)

The ESP32 machine.RTC module

STATIC mp_obj_t machine_rtc_datetime_helper(mp_uint_t n_args, const mp_obj_t *args) {

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

mp_obj_t pyb_rtc_datetime(size_t n_args, const mp_obj_t *args) {

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.

@dhylands
Copy link
Contributor Author
dhylands commented Mar 7, 2020

I think that the documentation should be updated to reflect the code, but I thought I would raise this issue to discuss that before submitting a PR.

@peterhinch
Copy link
Contributor

See #5553

@robert-hh
Copy link
Contributor
robert-hh commented May 20, 2021

Just came along the same mess while implementing a machine.RTC module for mimxrt. It seem the only port using rtc.now() is the cc3200 one, which is stale. So I went for rtc.datetime().

@evilhamsterman
Copy link

This is still messed up. The Raspberry Pi Pico doesn't have a init() function, also the wday in RTC.datetime((year, month, day, wday, hour, month, seconds, microseconds)) seems unneeded, it isn't used in any other place and it is something that can be calculated)

@peterhinch
Copy link
Contributor

You don't need wday when setting time but it is useful when reading it, and it makes sense to use the same tuple for read and write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0