adafruit / adafruit_circuitpython_pcf8523 Goto Github PK
View Code? Open in Web Editor NEWAdafruit CircuitPython drivers for the PCF8523 realtime clock.
License: MIT License
Adafruit CircuitPython drivers for the PCF8523 realtime clock.
License: MIT License
I tried accessing the PCF8523 on an Adalogger Featherwing following the example but get this error when setting the time.
>>> import busio
>>> import adafruit_pcf8523
>>> import time
>>> from board import *
>>> myI2C = busio.I2C(SCL, SDA)
>>> rtc = adafruit_pcf8523.PCF8523(myI2C)
>>> rtc.datetime = time.struct_time((2017,1,9,15,6,0,0,9,-1))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "libraries/drivers/pcf8523/adafruit_pcf8523.py", line 121, in datetime
File "libraries/helpers/register/adafruit_register/i2c_bcd_datetime.py", line 81, in __set__
AttributeError: 'struct_time' object has no attribute 'second'
There are missing type annotations for some functions in this library.
The typing
module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:
try:
from typing import List, Tuple
except ImportError:
pass
Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:
def wrap_text_to_pixels(
string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:
If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github
There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs
and Check your code with pre-commit
contain the tools to install and commands to run locally to run the checks.
If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev
channel.
The following locations are reported by mypy to be missing type annotations:
Add a Basic DisplayIO Based Example
We would like to have a basic displayio example for this library. The example should be written for microcontrollers with a built-in display. At a minimum it should show a Label on the display and update it with live readings from the sensor.
The example should not be overly complex, it's intended to be a good starting point for displayio based projects that utilize this sensor library. Try to keep all visual content as near to the top left corner as possible in order to best fascilitate devices with small built-in display resolutions.
The new example should follow the naming convention examples/libraryname_displayio_simpletest.py
with "libraryname" being replaced by the actual name of this library.
You can find an example of a Pull Request that adds this kind of example here: adafruit/Adafruit_CircuitPython_BME680#72
We have a guide that covers the process of contributing with git and github: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github
If you're interested in contributing but need additional help, or just want to say hi, feel free to join the Discord server to ask questions: https://adafru.it/discord
Using the M0 Express and the Adalogger FeatherWing - RTC + SD Add-on. Alarm function can be called with "minutely" frequency without error, but return value from alarm is not correct and alarm_status never becomes True.
Works as expected when frequency is set to "hourly".
Code:
import time
import busio
from board import *
import sys
import adafruit_pcf8523
myI2C = busio.I2C(SCL, SDA)
rtc = adafruit_pcf8523.PCF8523(myI2C)
rtc.datetime = time.struct_time((2017,10,15,16,59,0,0,9,-1))
rtc.alarm_interrupt = True
rtc.alarm = (time.struct_time((2017,10,15,17,00,0,0,9,-1)), "minutely")
t = rtc.datetime
a = rtc.alarm
print(rtc.alarm_interrupt)
print(t)
print(a)
print(t.tm_hour, t.tm_min)
while True:
time.sleep(10)
t = rtc.datetime
print(t.tm_hour, t.tm_min)
if rtc.alarm_status:
print("wake up!")
rtc.alarm_status = False
Output:
code.py output:
struct_time(tm_year=2017, tm_mon=10, tm_mday=15, tm_hour=16, tm_min=15, tm_sec=0, tm_wday=0, tm_yday=-1, tm_isdst=-1)
(struct_time(tm_year=2017, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=1, tm_isdst=-1), None)
16 15
16 15
16 15
16 15
16 15
16 15
16 16
16 16
16 16
16 16
16 16
16 16
16 17
16 17
16 17
This needs a couple finishing touches for PyPI:
setup.py->install_requires
Hi -
1st method:
I have added dtoverlay=i2c_rtc,pcf8523 in the boot/config.txt
i2cdetect -y 1 shows UU instead 0x68.
I soldered the crystal oscillator and rtc chip started keeping track of time after setting the time, let's say 1pm Although, when I shutdown the system for 10 mins approx., rtc chip should give me 1:10pm, but its giving me 1:01pm time. There is a battery coin cell as well. It seems like rtc loses 10mins time after complete shutdown of the system and when I turn on the system(via main power supply) the time would start from where it was left before like 1:01pm.
I dont know how to fix this issue. Please suggest.
2nd method:
When I comment out dtoverlay and it obviousl shows me 0x68. In this case, I am not losing time even after I turn on the system after 10 mins. Seems like library is writing 0b000 to enable battery switch over. That's exactly what we want. Although, how to get Time Zone?
I do not know how to write to control register3 while device is in reserved address mode (0xUU). Any suggestions would be appreciated.
Thanks,
Akshay
Originally posted by @TinManAkshay in #27 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.