Skip to content

Commit 9749e44

Browse files
Merge pull request #22 from jposada202020/improving_docs
improving_docs
2 parents 4be3f87 + cc824ce commit 9749e44

File tree

4 files changed

+50
-24
lines changed

4 files changed

+50
-24
lines changed

README.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,33 @@ Usage Notes
7272

7373
Of course, you must import the library to use it:
7474

75-
.. code:: python
75+
.. code:: python3
7676
77-
import busio
77+
import board
7878
import adafruit_ds1307
7979
import time
8080
8181
All the Adafruit RTC libraries take an instantiated and active I2C object
82-
(from the ``busio`` library) as an argument to their constructor. The way to
82+
(from the ``board`` library) as an argument to their constructor. The way to
8383
create an I2C object depends on the board you are using. For boards with labeled
8484
SCL and SDA pins, you can:
8585

8686
.. code:: python
8787
88-
from board import *
89-
90-
You can also use pins defined by the onboard ``microcontroller`` through the
91-
``microcontroller.pin`` module.
88+
import board
9289
9390
Now, to initialize the I2C bus:
9491

9592
.. code:: python
9693
97-
myI2C = busio.I2C(SCL, SDA)
94+
i2c = board.I2C()
9895
9996
Once you have created the I2C interface object, you can use it to instantiate
10097
the RTC object:
10198

10299
.. code:: python
103100
104-
rtc = adafruit_ds1307.DS1307(myI2C)
101+
rtc = adafruit_ds1307.DS1307(i2c)
105102
106103
To set the time, you need to set ``datetime`` to a `time.struct_time` object:
107104

adafruit_ds1307.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
2828
**Software and Dependencies:**
2929
30-
* Adafruit CircuitPython firmware (0.8.0+) for the ESP8622 and M0-based boards:
31-
https://github.com/adafruit/circuitpython/releases
30+
* Adafruit CircuitPython firmware for the supported boards:
31+
https://circuitpython.org/downloads
32+
3233
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
34+
3335
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3436
3537
**Notes:**
@@ -49,7 +51,42 @@
4951

5052

5153
class DS1307:
52-
"""Interface to the DS1307 RTC."""
54+
"""Interface to the DS1307 RTC.
55+
56+
:param ~busio.I2C i2c_bus: The I2C bus the device is connected to
57+
58+
**Quickstart: Importing and using the device**
59+
60+
Here is an example of using the :class:`DS1307` class.
61+
First you will need to import the libraries to use the sensor
62+
63+
.. code-block:: python
64+
65+
import time
66+
import board
67+
import adafruit_ds1307
68+
69+
Once this is done you can define your `board.I2C` object and define your sensor object
70+
71+
.. code-block:: python
72+
73+
i2c = board.I2C() # uses board.SCL and board.SDA
74+
rtc = adafruit_ds1307.DS1307(i2c)
75+
76+
Now you can give the current time to the device.
77+
78+
.. code-block:: python
79+
80+
t = time.struct_time((2017, 10, 29, 15, 14, 15, 0, -1, -1))
81+
rtc.datetime = t
82+
83+
You can access the current time accessing the :attr:`datetime` attribute.
84+
85+
.. code-block:: python
86+
87+
current_time = rtc.datetime
88+
89+
"""
5390

5491
disable_oscillator = i2c_bit.RWBit(0x0, 7)
5592
"""True if the oscillator is disabled."""

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit DS1307 Real Time Clock Assembled Breakout Board Learning Guide <https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

examples/ds1307_simpletest.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,10 @@
88

99
import time
1010
import board
11-
12-
# For hardware I2C (M0 boards) use this line:
13-
import busio as io
14-
15-
# Or for software I2C (ESP8266) use this line instead:
16-
# import bitbangio as io
17-
1811
import adafruit_ds1307
1912

20-
# Change to the appropriate I2C clock & data pins here!
21-
i2c_bus = io.I2C(board.SCL, board.SDA)
22-
23-
# Create the RTC instance:
24-
rtc = adafruit_ds1307.DS1307(i2c_bus)
13+
i2c = board.I2C()
14+
rtc = adafruit_ds1307.DS1307(i2c)
2515

2616
# Lookup table for names of days (nicer printing).
2717
days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")

0 commit comments

Comments
 (0)