machine.RTC.init throws exception on Pyboard 1.0
The code example in the docs fails with a surprising traceback.
rtc = machine.RTC()
rtc.init((2014, 5, 1, 4, 13, 0, 0, 0))
Outcome:
MicroPython v1.12-61-g0f16eeab2 on 2020-01-16; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>>
>>> from machine import RTC
>>> rtc = RTC()
>>> rtc.init((2014, 5, 1, 4, 13, 0, 0, 0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function takes 1 positional arguments but 2 were given
docs/library/machine.RTC.rst Fix example code, document datetime method.
This is the minimum change to fix the example code so it actually runs.
Unfortunately documenting the RTC class is difficult because it has been implemented differently for each platform. I checked STM, ESP8266 and ESP32. All implement datetime. Implementation of init is platform dependent: STM accepts no args. ESP8266 does not implement it while ESP32 requires a datetime tuple. Further, each platform implements a different set of methods and some documented methods are not implemented on any of these platforms: for example the now method.
Methods such as calibrate are inherently hardware dependent but where a method is implemented across platforms its calling signature should (in my view) be consistent.
There are other platforms where I don't own hardware so can't test. I'm stumped as to how properly to document this class.