1
- Introduction
1
+ Introduction
2
2
============
3
3
4
4
.. image :: https://readthedocs.org/projects/adafruit-micropython-ds3231/badge/?version=latest
5
5
:target: https://circuitpython.readthedocs.io/projects/ds3231/en/latest/
6
6
:alt: Documentation Status
7
7
8
- .. image :: https://badges.gitter.im/adafruit/circuitpython .svg
9
- :target: https://gitter.im/adafruit/circuitpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
10
- :alt: Gitter
8
+ .. image :: https://img.shields.io/discord/327254708534116352 .svg
9
+ :target: https://discord.gg/nBQh6qu
10
+ :alt: Discord
11
11
12
12
The datasheet for the DS3231 explains that this part is an
13
13
"Extremely Accurate I²C-Integrated RTC/TCXO/Crystal". And,
@@ -33,16 +33,19 @@ timekeeping, even when main power is lost. Great for
33
33
datalogging and clocks, or anything where you need to
34
34
really know the time.
35
35
36
- .. image :: 3013-01.jpg
36
+ .. image :: ../docs/_static/ 3013-01.jpg
37
37
38
38
Dependencies
39
39
=============
40
+ This driver depends on:
40
41
41
- This driver depends on the `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register >`_
42
- and `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice >`_
43
- libraries. Please ensure they are also available on the CircuitPython filesystem.
42
+ * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython >`_
43
+ * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice >`_
44
+ * `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register >`_
45
+
46
+ Please ensure all dependencies are available on the CircuitPython filesystem.
44
47
This is easily achieved by downloading
45
- `a library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle >`_.
48
+ `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle >`_.
46
49
47
50
Usage Notes
48
51
===========
@@ -59,16 +62,16 @@ Of course, you must import the library to use it:
59
62
import time
60
63
61
64
All the Adafruit RTC libraries take an instantiated and active I2C object
62
- (from the `busio ` library) as an argument to their constructor. The way to
65
+ (from the `` busio ` ` library) as an argument to their constructor. The way to
63
66
create an I2C object depends on the board you are using. For boards with labeled
64
67
SCL and SDA pins, you can:
65
68
66
69
.. code :: python
67
70
68
71
from board import *
69
72
70
- You can also use pins defined by the onboard `microcontroller ` through the
71
- `microcontroller.pin ` module.
73
+ You can also use pins defined by the onboard `` microcontroller ` ` through the
74
+ `` microcontroller.pin ` ` module.
72
75
73
76
Now, to initialize the I2C bus:
74
77
@@ -86,15 +89,15 @@ the RTC object:
86
89
Date and time
87
90
-------------
88
91
89
- To set the time, you need to set ``datetime `` to a `time.struct_time ` object:
92
+ To set the time, you need to set ``datetime `` to a `` time.struct_time ` ` object:
90
93
91
94
.. code :: python
92
95
93
96
rtc.datetime = time.struct_time((2017 ,1 ,9 ,15 ,6 ,0 ,0 ,9 ,- 1 ))
94
97
95
98
After the RTC is set, you retrieve the time by reading the ``datetime ``
96
- attribute and access the standard attributes of a struct_time such as `tm_year `,
97
- `tm_hour ` and `tm_min `.
99
+ attribute and access the standard attributes of a struct_time such as `` tm_year ` `,
100
+ `` tm_hour `` and `` tm_min ` `.
98
101
99
102
.. code :: python
100
103
@@ -106,14 +109,14 @@ Alarm
106
109
-----
107
110
108
111
To set the time, you need to set ``alarm1 `` or ``alarm2 `` to a tuple with a
109
- `time.struct_time ` object and string representing the frequency such as "hourly":
112
+ `` time.struct_time ` ` object and string representing the frequency such as "hourly":
110
113
111
114
.. code :: python
112
115
113
116
rtc.alarm1 = (time.struct_time((2017 ,1 ,9 ,15 ,6 ,0 ,0 ,9 ,- 1 )), " daily" )
114
117
115
118
After the RTC is set, you retrieve the alarm status by reading the corresponding
116
- `alarm1_status ` or `alarm2_status ` attributes. Once True, set it back to False
119
+ `` alarm1_status `` or `` alarm2_status ` ` attributes. Once True, set it back to False
117
120
to reset.
118
121
119
122
.. code :: python
@@ -122,10 +125,56 @@ to reset.
122
125
print (" wake up!" )
123
126
rtc.alarm1_status = False
124
127
125
- API Reference
126
- =============
128
+ Contributing
129
+ ============
130
+
131
+ Contributions are welcome! Please read our `Code of Conduct
132
+ <https://github.com/adafruit/Adafruit_CircuitPython_DS3231/blob/master/CODE_OF_CONDUCT.md> `_
133
+ before contributing to help this project stay welcoming.
134
+
135
+ Building locally
136
+ ================
137
+
138
+ To build this library locally you'll need to install the
139
+ `circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools >`_ package.
140
+
141
+ .. code-block :: shell
142
+
143
+ python3 -m venv .env
144
+ source .env/bin/activate
145
+ pip install circuitpython-build-tools
146
+
147
+ Once installed, make sure you are in the virtual environment:
148
+
149
+ .. code-block :: shell
150
+
151
+ source .env/bin/activate
152
+
153
+ Then run the build:
154
+
155
+ .. code-block :: shell
156
+
157
+ circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ds3231 --library_location .
158
+
159
+ Sphinx documentation
160
+ -----------------------
161
+
162
+ Sphinx is used to build the documentation based on rST files and comments in the code. First,
163
+ install dependencies (feel free to reuse the virtual environment from above):
164
+
165
+ .. code-block :: shell
166
+
167
+ python3 -m venv .env
168
+ source .env/bin/activate
169
+ pip install Sphinx sphinx-rtd-theme
170
+
171
+ Now, once you have the virtual environment activated:
172
+
173
+ .. code-block :: shell
127
174
128
- .. toctree ::
129
- :maxdepth: 2
175
+ cd docs
176
+ sphinx-build -E -W -b html . _build/html
130
177
131
- api
178
+ This will output the documentation to ``docs/_build/html ``. Open the index.html in your browser to
179
+ view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
180
+ locally verify it will pass.
0 commit comments