Compare commits

...

29 commits

Author SHA1 Message Date
dherrada
974d5e6656 Fixed discord invite link 2020-07-08 16:49:04 -04:00
Scott Shawcroft
0d49a1fcd9
Merge pull request #26 from adafruit/black-update
Black reformatting with Python 3 target.
2020-04-09 09:39:42 -07:00
Kattni Rembor
0e32efa93d Black reformatting with Python 3 target. 2020-04-08 14:47:33 -04:00
sommersoft
b08aa012dd build.yml: add black formatting check
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-04-07 16:03:47 -05:00
Kattni
e2d5a2f4cd
Merge pull request #25 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2020-03-17 11:59:59 -04:00
sommersoft
ab1f24811b update code of coduct: discord moderation contact section
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-15 18:29:41 -05:00
dherrada
19712a748f Ran black, updated to pylint 2.x 2020-03-15 16:58:20 -04:00
Kattni
d9822e6690
Merge pull request #24 from sommersoft/patch_coc
Update Code of Conduct
2020-03-13 15:53:11 -04:00
sommersoft
220ddc70d8 update code of conduct 2020-03-13 13:46:12 -05:00
sommersoft
256dc1c0e5 update pylintrc for black
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-08 19:08:43 -05:00
sommersoft
42024d0f8c build.yml: move pylint, black, and Sphinx installs to each repo; add description to 'actions-ci/install.sh'
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-05 10:07:50 -06:00
siddacious
2e6caa7c1e
Merge pull request #23 from adafruit/dherrada-patch-2
Should render in pypi now
2020-01-24 07:28:30 -08:00
dherrada
c0f88087fa
Should render in pypi now 2020-01-23 15:29:58 -05:00
sommersoft
6a299d88e0 update pylint examples directive
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-01-14 17:09:19 -06:00
siddacious
dc1d8dd99c
Merge pull request #21 from adafruit/dherrada-patch-1
Moved repository from Travis to GitHub Actions
2020-01-01 12:15:49 -08:00
dherrada
d2c3788821 Moved repository from Travis to GitHub Actions 2020-01-01 14:26:25 -05:00
Carter Nelson
1bf2707c91
Merge pull request #20 from caternuson/iss15
Remove verification check
2019-11-14 20:09:30 -08:00
caternuson
65c458da1a and that 2019-11-14 16:37:39 -08:00
caternuson
82d250586d remove verification check 2019-11-14 16:34:44 -08:00
caternuson
4e90dcadb4 change verification check 2019-11-14 15:14:46 -08:00
Kattni
ed71b40dc9
Merge pull request #19 from adafruit/dherrada-patch-1
Removed building locally section from README, replaced with documenta…
2019-10-21 19:48:35 -04:00
dherrada
c2462e72a9
Added PyPi installation instructions 2019-10-18 21:37:14 -04:00
dherrada
db8dfb4289
Removed building locally section from README, replaced with documentation section 2019-10-17 18:28:51 -04:00
Kattni
395ddb7682
Merge pull request #18 from tannewt/remove_stop
Remove stop kwarg and use write_then_readinto.
2019-08-27 15:16:45 -04:00
Scott Shawcroft
df2037bddd
Correct to i2c_device 2019-08-26 17:14:26 -07:00
Scott Shawcroft
5e953fcb26
Remove stop kwarg and use write_then_readinto.
See https://github.com/adafruit/circuitpython/issues/2082 for details.
2019-08-21 16:05:25 -07:00
Kattni
0e8b9ae9bd
Merge pull request #14 from sommersoft/readme_fix_travis
Update README Travis Badge
2018-12-21 13:45:27 -06:00
sommersoft
dab1a53569 change 'travis-ci.org' to 'travis-ci.com' 2018-12-21 13:24:34 -06:00
Dan Halbert
de9017c73e
Merge pull request #13 from adafruit/lowercase_module_name
lowercase module name in setup.py (fixes #12)
2018-11-29 17:55:32 -05:00
11 changed files with 308 additions and 201 deletions

57
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: Build CI
on: [pull_request, push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Translate Repo Name For Build Tools filename_prefix
id: repo-name
run: |
echo ::set-output name=repo-name::$(
echo ${{ github.repository }} |
awk -F '\/' '{ print tolower($2) }' |
tr '_' '-'
)
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Versions
run: |
python3 --version
- name: Checkout Current Repo
uses: actions/checkout@v1
with:
submodules: true
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: adafruit/actions-ci-circuitpython-libs
path: actions-ci
- name: Install dependencies
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
run: |
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: Check formatting
run: |
black --check --target-version=py35 .
- name: PyLint
run: |
pylint $( find . -path './adafruit*.py' )
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" ))
- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
- name: Build docs
working-directory: docs
run: sphinx-build -E -W -b html . _build/html

81
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,81 @@
name: Release Actions
on:
release:
types: [published]
jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Translate Repo Name For Build Tools filename_prefix
id: repo-name
run: |
echo ::set-output name=repo-name::$(
echo ${{ github.repository }} |
awk -F '\/' '{ print tolower($2) }' |
tr '_' '-'
)
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Versions
run: |
python3 --version
- name: Checkout Current Repo
uses: actions/checkout@v1
with:
submodules: true
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: adafruit/actions-ci-circuitpython-libs
path: actions-ci
- name: Install deps
run: |
source actions-ci/install.sh
- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
- name: Upload Release Assets
# the 'official' actions version does not yet support dynamically
# supplying asset names to upload. @csexton's version chosen based on
# discussion in the issue below, as its the simplest to implement and
# allows for selecting files with a pattern.
# https://github.com/actions/upload-release-asset/issues/4
#uses: actions/upload-release-asset@v1.0.1
uses: csexton/release-asset-action@master
with:
pattern: "bundles/*"
github-token: ${{ secrets.GITHUB_TOKEN }}
upload-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check For setup.py
id: need-pypi
run: |
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
- name: Set up Python
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
env:
TWINE_USERNAME: ${{ secrets.pypi_username }}
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python setup.py sdist
twine upload dist/*

1
.gitignore vendored
View file

@ -4,7 +4,6 @@ __pycache__
_build
*.pyc
.env
build*
bundles
*.DS_Store
.eggs

View file

@ -52,7 +52,7 @@ confidence=
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
@ -119,7 +119,8 @@ spelling-store-unknown-words=no
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,XXX,TODO
# notes=FIXME,XXX,TODO
notes=FIXME,XXX
[TYPECHECK]
@ -300,7 +301,7 @@ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Good variable names which should always be accepted, separated by a comma
# good-names=i,j,k,ex,Run,_
good-names=r,g,b,i,j,k,n,ex,Run,_
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
# Include a hint for the correct naming format with invalid-name
include-naming-hint=no
@ -422,7 +423,7 @@ max-returns=6
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
min-public-methods=1
[EXCEPTIONS]

View file

@ -1,32 +0,0 @@
dist: trusty
sudo: false
language: python
python:
- '3.6'
cache:
pip: true
deploy:
- provider: releases
api_key: "$GITHUB_TOKEN"
file_glob: true
file: "$TRAVIS_BUILD_DIR/bundles/*"
skip_cleanup: true
overwrite: true
on:
tags: true
- provider: pypi
user: adafruit-travis
on:
tags: true
password:
secure: apWQJCBG0Ac5t0zXV6zLmcsYiZK42Vf8gA7dgQXwYxeQp7V+Tmfn3/F5C5mH1POfY8uiHDCDnwk0vqqpmF9jNaoJ5BG4sVh2v5CifAlE+qb+jt9GsjBjq8vlhnjOKIMdw0r64qiWMrnM2zMTcmeDQlERmdb0C/5Rbq36+azPR/zUu4P8pnk/uuJelWu68SnrSeOT7GqosEN/mloyJEesu20e8taLSzYQNZ77yx+tNzPRHhxinbIx6pXp4H2jAj5euhOyRjYZb9Qm7PswyKeKcOQLM7zcPXDN4Dwo1CMITGUuITJTk8iRXW13uXQScAEdrf1PN3rWqHc+AjgiNGYFlP7+GB69xrUe5M1AQKbCiAv/cirQ5lkkdqzYGP9TVG1yGHaf5QvVI68c0NZxy2JGpeKOXAo/YwpX61KeJGfRkFwMD3uaYnRHfCWkyIhXQKwygHhGbcOAZh+xnGpA/0Z87bqkh6Wwq9+JxsO6hfkJVPUccEey/c98ilPHzXdBSdUDGdsKQWMV+HjMJx2Nes8P0ObDMdLJz15RG80YimYpphuYSRhQEx6rACgnUS426Ax8ir94hUruBHzqz3ZzJEJ4YoLdEFbIXVqB3aAY4uBykTdm4rsa1M+JcBHmT/n6Kt/HfbN37Qxg0nHMGSXTrOWAsZHU6t9Vq7Xv+wUUWYdashc=
install:
- pip install -r requirements.txt
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
- pip install --force-reinstall pylint==1.9.2
script:
- pylint adafruit_ds3231.py
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ds3231 --library_location
.
- cd docs && sphinx-build -E -W -b html . _build/html && cd ..

View file

@ -34,13 +34,15 @@ Examples of unacceptable behavior by participants include:
* Excessive or unwelcome helping; answering outside the scope of the question
asked
* Trolling, insulting/derogatory comments, and personal or political attacks
* Promoting or spreading disinformation, lies, or conspiracy theories against
a person, group, organisation, project, or community
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate
The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be
and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self.
We value many things beyond technical expertise, including collaboration and
@ -72,10 +74,10 @@ You may report in the following ways:
In any situation, you may send an email to <support@adafruit.com>.
On the Adafruit Discord, you may send an open message from any channel
to all Community Helpers by tagging @community helpers. You may also send an
open message from any channel, or a direct message to @kattni#1507,
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
@Andon#8175.
to all Community Moderators by tagging @community moderators. You may
also send an open message from any channel, or a direct message to
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
Email and direct message reports will be kept confidential.
@ -83,7 +85,7 @@ In situations on Discord where the issue is particularly egregious, possibly
illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to Discord.
These are the steps for upholding our communitys standards of conduct.
These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the
Adafruit Community Code of Conduct. All reports will be reviewed and
@ -124,4 +126,4 @@ For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your
own moderation policy so as to avoid confusion.
own moderation policy so as to avoid confusion.

View file

@ -1,16 +1,16 @@
Introduction
============
Introduction
=============
.. image:: https://readthedocs.org/projects/adafruit-micropython-ds3231/badge/?version=latest
:target: https://circuitpython.readthedocs.io/projects/ds3231/en/latest/
:alt: Documentation Status
.. image :: https://img.shields.io/discord/327254708534116352.svg
:target: https://discord.gg/nBQh6qu
:target: https://adafru.it/discord
:alt: Discord
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_DS3231.svg?branch=master
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_DS3231
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_DS3231/workflows/Build%20CI/badge.svg
:target: https://github.com/adafruit/Adafruit_CircuitPython_DS3231/actions/
:alt: Build Status
The datasheet for the DS3231 explains that this part is an
@ -52,6 +52,31 @@ Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
Installing from PyPI
====================
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/adafruit-circuitpython-ds3231/>`_. To install for current user:
.. code-block:: shell
pip3 install adafruit-circuitpython-ds3231
To install system-wide (this may be required in some cases):
.. code-block:: shell
sudo pip3 install adafruit-circuitpython-ds3231
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-ds3231
Usage Notes
===========
@ -137,49 +162,7 @@ Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_DS3231/blob/master/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.
Building locally
================
Documentation
=============
To build this library locally you'll need to install the
`circuitpython-build-tools <https://github.com/adafruit/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-ds3231 --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.
For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.

View file

@ -62,14 +62,14 @@ from adafruit_register import i2c_bcd_datetime
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DS3231.git"
#pylint: disable-msg=too-few-public-methods
# pylint: disable-msg=too-few-public-methods
class DS3231:
"""Interface to the DS3231 RTC."""
lost_power = i2c_bit.RWBit(0x0f, 7)
lost_power = i2c_bit.RWBit(0x0F, 7)
"""True if the device has lost power since the time was set."""
disable_oscillator = i2c_bit.RWBit(0x0e, 7)
disable_oscillator = i2c_bit.RWBit(0x0E, 7)
"""True if the oscillator is disabled."""
datetime_register = i2c_bcd_datetime.BCDDateTimeRegister(0x00)
@ -78,35 +78,24 @@ class DS3231:
alarm1 = i2c_bcd_alarm.BCDAlarmTimeRegister(0x07)
"""Alarm time for the first alarm."""
alarm1_interrupt = i2c_bit.RWBit(0x0e, 0)
alarm1_interrupt = i2c_bit.RWBit(0x0E, 0)
"""True if the interrupt pin will output when alarm1 is alarming."""
alarm1_status = i2c_bit.RWBit(0x0f, 0)
alarm1_status = i2c_bit.RWBit(0x0F, 0)
"""True if alarm1 is alarming. Set to False to reset."""
alarm2 = i2c_bcd_alarm.BCDAlarmTimeRegister(0x0b, has_seconds=False)
alarm2 = i2c_bcd_alarm.BCDAlarmTimeRegister(0x0B, has_seconds=False)
"""Alarm time for the second alarm."""
alarm2_interrupt = i2c_bit.RWBit(0x0e, 1)
alarm2_interrupt = i2c_bit.RWBit(0x0E, 1)
"""True if the interrupt pin will output when alarm2 is alarming."""
alarm2_status = i2c_bit.RWBit(0x0f, 1)
alarm2_status = i2c_bit.RWBit(0x0F, 1)
"""True if alarm2 is alarming. Set to False to reset."""
def __init__(self, i2c):
self.i2c_device = I2CDevice(i2c, 0x68)
# Try and verify this is the RTC we expect by checking the rate select
# control bits which are 1 on reset and shouldn't ever be changed.
buf = bytearray(2)
buf[0] = 0x0e
with self.i2c_device as i2c_device:
i2c_device.write(buf, end=1, stop=False)
i2c_device.readinto(buf, start=1)
if (buf[1] & 0b00011000) != 0b00011000:
raise ValueError("Unable to find DS3231 at i2c address 0x68.")
@property
def datetime(self):
"""Gets the current date and time or sets the current date and time

View file

@ -18,7 +18,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
# -- General configuration ------------------------------------------------
@ -30,10 +31,10 @@ sys.path.insert(0, os.path.abspath('..'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx'
"sphinx.ext.autodoc",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
]
# Uncomment the below if you use native CircuitPython modules such as
@ -41,15 +42,26 @@ extensions = [
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["adafruit_bus_device", "adafruit_register"]
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None),
"BusDevice": (
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
None,
),
"Register": (
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
None,
),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]
# source_suffix = '.rst'
# The encoding of source files.
@ -57,21 +69,21 @@ source_suffix = ['.rst', '.md']
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# General information about the project.
project = u'Adafruit\'s DS3231 RTC Library'
copyright = u'2016, Philip Moyer'
author = u'Philip Moyer'
project = "Adafruit's DS3231 RTC Library"
copyright = "2016, Philip Moyer"
author = "Philip Moyer"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'1.0'
version = "1.0"
# The full version, including alpha/beta/rc tags.
release = u'1.0'
release = "1.0"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -92,7 +104,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
# The reST default role (used for this markup: `text`) to use for all
# documents.
@ -114,7 +126,7 @@ add_function_parentheses = True
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
@ -134,18 +146,19 @@ todo_emit_warnings = True
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
if not on_rtd: # only import and set the theme if we're building docs locally
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
except:
html_theme = 'default'
html_theme_path = ['.']
html_theme = "default"
html_theme_path = ["."]
else:
html_theme_path = ['.']
html_theme_path = ["."]
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@ -179,13 +192,13 @@ else:
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'
html_favicon = "_static/favicon.ico"
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
@ -265,34 +278,36 @@ html_favicon = '_static/favicon.ico'
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitsDS3231RTCLibrarydoc'
htmlhelp_basename = "AdafruitsDS3231RTCLibrarydoc"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'AdafruitsDS3231RTCLibrary.tex', u'Adafruit\'s DS3231 RTC Library Documentation',
u'Philip Moyer', 'manual'),
(
master_doc,
"AdafruitsDS3231RTCLibrary.tex",
"Adafruit's DS3231 RTC Library Documentation",
"Philip Moyer",
"manual",
),
]
# The name of an image file (relative to this directory) to place at the top of
@ -333,8 +348,13 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'adafruitsds3231rtclibrary', u'Adafruit\'s DS3231 RTC Library Documentation',
[author], 1)
(
master_doc,
"adafruitsds3231rtclibrary",
"Adafruit's DS3231 RTC Library Documentation",
[author],
1,
)
]
# If true, show URL addresses after external links.
@ -348,9 +368,15 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitsDS3231RTCLibrary', u'Adafruit\'s DS3231 RTC Library Documentation',
author, 'AdafruitsDS3231RTCLibrary', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitsDS3231RTCLibrary",
"Adafruit's DS3231 RTC Library Documentation",
author,
"AdafruitsDS3231RTCLibrary",
"One line description of project.",
"Miscellaneous",
),
]
# Documents to append as an appendix to all manuals.

View file

@ -5,16 +5,18 @@
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 bitbangio as io
import adafruit_ds3231
i2c = io.I2C(board.SCL, board.SDA) # Change to the appropriate I2C clock & data
# pins here!
# pins here!
# Create the RTC instance:
rtc = adafruit_ds3231.DS3231(i2c)
@ -23,23 +25,27 @@ rtc = adafruit_ds3231.DS3231(i2c)
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!
# 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, 15, 14, 15, 0, -1, -1))
t = time.struct_time((2017, 10, 29, 15, 14, 15, 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
print("Setting time to:", t) # uncomment for debugging
rtc.datetime = t
print()
#pylint: enable-msg=using-constant-test
#pylint: enable-msg=bad-whitespace
# 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(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
time.sleep(1) # wait a second

View file

@ -7,6 +7,7 @@ https://github.com/pypa/sampleproject
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
@ -14,47 +15,41 @@ from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read()
setup(
name='adafruit-circuitpython-ds3231',
name="adafruit-circuitpython-ds3231",
use_scm_version=True,
setup_requires=['setuptools_scm'],
description='CircuitPython library for DS3231 precision real-time clock.',
setup_requires=["setuptools_scm"],
description="CircuitPython library for DS3231 precision real-time clock.",
long_description=long_description,
long_description_content_type='text/x-rst',
long_description_content_type="text/x-rst",
# The project's main homepage.
url='https://github.com/adafruit/Adafruit_CircuitPython_DS3231',
url="https://github.com/adafruit/Adafruit_CircuitPython_DS3231",
# Author details
author='Adafruit Industries',
author_email='circuitpython@adafruit.com',
install_requires=['adafruit-circuitpython-register', 'adafruit-circuitpython-busdevice'],
author="Adafruit Industries",
author_email="circuitpython@adafruit.com",
install_requires=[
"adafruit-circuitpython-register",
"adafruit-circuitpython-busdevice",
],
# Choose your license
license='MIT',
license="MIT",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
'Topic :: System :: Hardware',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Hardware",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
],
# What does your project relate to?
keywords='adafruit precision real-time real time clock breakout hardware micropython circuitpython',
keywords="adafruit precision real-time real time clock breakout hardware micropython circuitpython",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
py_modules=['adafruit_ds3231'],
py_modules=["adafruit_ds3231"],
)