We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I wired up a tinyRTC onto I2C bus 1 on a Raspberry Pi Pico and tried running the example. But it resulted in an error:
MicroPython v1.22.2 on 2024-02-22; Raspberry Pi Pico with RP2040 >>> from machine import I2C, Pin >>> i2c = I2C(1) >>> i2c.scan() [80, 104] >>> import ds1307 >>> ds = ds1307.DS1307(i2c) >>> ds.datetime() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/lib/ds1307.py", line 124, in datetime TypeError: can't convert I2C to int
so, that would be:
... 124 | buf = self._i2c.readfrom_mem(self._addr, DATETIME_REG, 7) ...
expanded:
... @property def datetime(self) -> Tuple[int, int, int, int, int, int, int, int]: """ Get the current datetime (2023, 4, 18, 0, 10, 34, 4, 108) y, m, d, h, m, s, wd, yd :returns: (year, month, day, hour, minute, second, weekday, yearday) :rtype: Tuple[int, int, int, int, int, int, int, int] """ buf = bytearray(7) buf = self._i2c.readfrom_mem(self._addr, DATETIME_REG, 7) year = self._bcd_to_dec(buf[6]) + 2000 month = self._bcd_to_dec(buf[5]) day = self._bcd_to_dec(buf[4]) yearday = self.day_of_year(year=year, month=month, day=day) return ( year, month, day, self._bcd_to_dec(buf[2]), # hour self._bcd_to_dec(buf[1]), # minute self._bcd_to_dec(buf[0] & 0x7F), # second self._bcd_to_dec(buf[3] - self._weekday_start), # weekday yearday, ) ...
Any help is appreciated!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I wired up a tinyRTC onto I2C bus 1 on a Raspberry Pi Pico and tried running the example. But it resulted in an error:
so, that would be:
expanded:
Any help is appreciated!
The text was updated successfully, but these errors were encountered: