From 84d0bf71ac8e2d0347c794b5bb9be60b20c96aba Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sat, 23 Mar 2019 09:25:34 -0500 Subject: [PATCH 1/5] add Blinka to 'setup.py->install_requires'; add PyPI install & standard stuff to README --- README.rst | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a85e0ab..f414212 100644 --- a/README.rst +++ b/README.rst @@ -39,6 +39,32 @@ libraries. Please ensure they are also available on the CircuitPython filesystem This is easily achieved by downloading `a library and driver bundle `_. +Installing from PyPI +-------------------- + If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section. +On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from +PyPI `_. To install for current user: + +.. code-block:: shell + + pip3 install adafruit-circuitpython-pcf8523 + +To install system-wide (this may be required in some cases): + +.. code-block:: shell + + sudo pip3 install adafruit-circuitpython-pcf8523 + +To install in a virtual environment in your current project: + +.. code-block:: shell + + mkdir project-name && cd project-name + python3 -m venv .env + source .env/bin/activate + pip3 install adafruit-circuitpython-pcf8523 + + Usage Notes =========== @@ -115,3 +141,61 @@ After the RTC is set, you retrieve the alarm status by reading the if rtc.alarm_status: print("wake up!") rtc.alarm_status = False + +Contributing +============ + +Contributions are welcome! Please read our `Code of Conduct +`_ +before contributing to help this project stay welcoming. + +Building locally +================ + +Zip release files +----------------- + +To build this library locally you'll need to install the +`circuitpython-build-tools `_ package. + +.. code-block:: shell + + python3 -m venv .env + source .env/bin/activate + pip install circuitpython-build-tools + +Once installed, make sure you are in the virtual environment: + +.. code-block:: shell + + source .env/bin/activate + +Then run the build: + +.. code-block:: shell + + circuitpython-build-bundles --filename_prefix adafruit-circuitpython-pcf8523 --library_location . + +Sphinx documentation +----------------------- + +Sphinx is used to build the documentation based on rST files and comments in the code. First, +install dependencies (feel free to reuse the virtual environment from above): + +.. code-block:: shell + + python3 -m venv .env + source .env/bin/activate + pip install Sphinx sphinx-rtd-theme + +Now, once you have the virtual environment activated: + +.. code-block:: shell + + cd docs + sphinx-build -E -W -b html . _build/html + +This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to +view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to +locally verify it will pass. + diff --git a/setup.py b/setup.py index 139b554..290828a 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ author='Adafruit Industries', author_email='circuitpython@adafruit.com', - install_requires=['adafruit-circuitpython-register', 'adafruit-circuitpython-busdevice'], + install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-register', 'adafruit-circuitpython-busdevice'], # Choose your license license='MIT', From 06a48d8e4abfbb8bbe5be88678441e78a635754b Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sat, 23 Mar 2019 09:26:40 -0500 Subject: [PATCH 2/5] renamed example file to match naming convention --- examples/demo.py | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 examples/demo.py diff --git a/examples/demo.py b/examples/demo.py deleted file mode 100644 index 04ee374..0000000 --- a/examples/demo.py +++ /dev/null @@ -1,44 +0,0 @@ -# Simple demo of reading and writing the time for the PCF8523 real-time clock. -# Change the if False to if True below to set the time, otherwise it will just -# print the current date and time every second. Notice also comments to adjust -# for working with hardware vs. software I2C. - -import time -import board -# For hardware I2C (M0 boards) use this line: -import busio as io -# Or for software I2C (ESP8266) use this line instead: -#import bitbangio as io - -import adafruit_pcf8523 - -# Change to the appropriate I2C clock & data pins here! -i2c_bus = io.I2C(board.SCL, board.SDA) - -# Create the RTC instance: -rtc = adafruit_pcf8523.PCF8523(i2c_bus) - -# Lookup table for names of days (nicer printing). -days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") - - -#pylint: disable-msg=bad-whitespace -#pylint: disable-msg=using-constant-test -if False: # change to True if you want to set the time! - # year, mon, date, hour, min, sec, wday, yday, isdst - t = time.struct_time((2017, 10, 29, 10, 31, 0, 0, -1, -1)) - # you must set year, mon, date, hour, min, sec and weekday - # yearday is not supported, isdst can be set but we don't do anything with it at this time - print("Setting time to:", t) # uncomment for debugging - rtc.datetime = t - print() -#pylint: enable-msg=using-constant-test -#pylint: enable-msg=bad-whitespace - -# Main loop: -while True: - t = rtc.datetime - #print(t) # uncomment for debugging - print("The date is {} {}/{}/{}".format(days[int(t.tm_wday)], t.tm_mday, t.tm_mon, t.tm_year)) - print("The time is {}:{:02}:{:02}".format(t.tm_hour, t.tm_min, t.tm_sec)) - time.sleep(1) # wait a second From 7d1dbffaec0e4766ce1941a3be869ca17a5a9ea0 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sat, 23 Mar 2019 09:29:08 -0500 Subject: [PATCH 3/5] forgot 'git add' --- examples/pcf8523_simpletest.py | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 examples/pcf8523_simpletest.py diff --git a/examples/pcf8523_simpletest.py b/examples/pcf8523_simpletest.py new file mode 100644 index 0000000..04ee374 --- /dev/null +++ b/examples/pcf8523_simpletest.py @@ -0,0 +1,44 @@ +# Simple demo of reading and writing the time for the PCF8523 real-time clock. +# Change the if False to if True below to set the time, otherwise it will just +# print the current date and time every second. Notice also comments to adjust +# for working with hardware vs. software I2C. + +import time +import board +# For hardware I2C (M0 boards) use this line: +import busio as io +# Or for software I2C (ESP8266) use this line instead: +#import bitbangio as io + +import adafruit_pcf8523 + +# Change to the appropriate I2C clock & data pins here! +i2c_bus = io.I2C(board.SCL, board.SDA) + +# Create the RTC instance: +rtc = adafruit_pcf8523.PCF8523(i2c_bus) + +# Lookup table for names of days (nicer printing). +days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") + + +#pylint: disable-msg=bad-whitespace +#pylint: disable-msg=using-constant-test +if False: # change to True if you want to set the time! + # year, mon, date, hour, min, sec, wday, yday, isdst + t = time.struct_time((2017, 10, 29, 10, 31, 0, 0, -1, -1)) + # you must set year, mon, date, hour, min, sec and weekday + # yearday is not supported, isdst can be set but we don't do anything with it at this time + print("Setting time to:", t) # uncomment for debugging + rtc.datetime = t + print() +#pylint: enable-msg=using-constant-test +#pylint: enable-msg=bad-whitespace + +# Main loop: +while True: + t = rtc.datetime + #print(t) # uncomment for debugging + print("The date is {} {}/{}/{}".format(days[int(t.tm_wday)], t.tm_mday, t.tm_mon, t.tm_year)) + print("The time is {}:{:02}:{:02}".format(t.tm_hour, t.tm_min, t.tm_sec)) + time.sleep(1) # wait a second From 70b93359de45c3b9cd19f551b6e7f13575acb820 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sat, 23 Mar 2019 09:50:30 -0500 Subject: [PATCH 4/5] update 'docs/examples.rst' with new filename --- docs/examples.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/examples.rst b/docs/examples.rst index 1958898..0c1e7dd 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -1,6 +1,6 @@ Demo ---- -.. literalinclude:: ../examples/demo.py - :caption: examples/demo.py +.. literalinclude:: ../examples/pcf8523_simpletest.py + :caption: examples/pcf8523_simpletest.py :linenos: From d29d294f9b59c7e41c52e38b08bb7ff1660fe84d Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sat, 23 Mar 2019 09:57:07 -0500 Subject: [PATCH 5/5] paste fail --- README.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/README.rst b/README.rst index f414212..6e0b11f 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,6 @@ This is easily achieved by downloading Installing from PyPI -------------------- - If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section. On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from PyPI `_. To install for current user: