QUERY · ISSUE
machine.RTC.init throws exception on Pyboard 1.0
docsport-stm32
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
CANDIDATE · ISSUE
esp8266: pyb.RTC differences with pyboard implementation
I've found differences between the esp8266 and pyboard implementations of pyb.RTC that make them incompatible:
- The pyboard code implements pyb.RTC as a class definition with a constructor, for esp8266 it is an instance of the class (I hope I'm describing that distinction correctly):
Micro Python v1.4.3-159-g3ce212e-dirty on 2015-06-14; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import pyb
>>> pyb.RTC
<class 'RTC'>
>>> rtc = pyb.RTC()
>>> rtc
<RTC>
Micro Python v1.4.3-133-g7ed58cb-dirty on 2015-06-10; ESP module with ESP8266
Type "help()" for more information.
>>> import pyb
>>> pyb.RTC
<RTC>
>>> rtc = pyb.RTC()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object not callable
- The pyboard 8-tuple includes the week day as 1-7 for Monday-Sunday, esp8266 uses 0-6.
- The last entry in the pyboard 8-tuple is a 'SubSeconds' counter that goes down from 255 to 0 during each second. The last entry in the esp8266 8-tuple is a
microsecondsmilliseconds counter that goes up from 0 to 999.