peterhinch / micropython-samples

Assorted code ideas, unofficial MP FAQ, plus index to my other repositories.
MIT License
459 stars 91 forks source link

DS3231 Portable Pyboard readfrom_mem_into #9

Open pacmac opened 5 years ago

pacmac commented 5 years ago

Hi Peter;

Just tried to run the portable version as I have both esp8266 and pyboards to calibrate, but on the pyboard it fails as the pyboard I2C does not include readfrom_mem_into:

from ds3231 import DS3231
import pyb
i2c = pyb.I2C(1, pyb.I2C.MASTER)
ds = DS3231(i2c)
ds.rtc_test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ds3231.py", line 111, in rtc_test
  File "ds3231.py", line 97, in await_transition
AttributeError: 'I2C' object has no attribute 'readfrom_mem_into'

I tested this on the pyboard-d-sf2, have not yet tried on the pyboard 1.1.

peterhinch commented 5 years ago

Thanks for the report. I haven't yet tested this on the Pyboard D - alas I'm wrestling with porting my micropower uasyncio version to that platform.

From a quick look, if you're using the portable version you should instantiate the I2C using machine rather than pyb. I'd be very interested to hear the outcome if you do get it working.