Skip to content

Commit ffdb344

Browse files
authored
Merge pull request #13 from jposada202020/improving_docs
improving_docs
2 parents 85c86a3 + d9262e2 commit ffdb344

6 files changed

+64
-26
lines changed

README.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,25 @@ To install in a virtual environment in your current project:
5353
5454
Usage Example
5555
=============
56-
::
5756

58-
import board
59-
import busio
60-
import digitalio
61-
import adafruit_max31856
57+
.. code:: python3
6258
63-
# create a spi object
64-
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
59+
import board
60+
import digitalio
61+
import adafruit_max31856
6562
66-
# allocate a CS pin and set the direction
67-
cs = digitalio.DigitalInOut(board.D5)
68-
cs.direction = digitalio.Direction.OUTPUT
63+
# Create sensor object, communicating over the board's default SPI bus
64+
spi = board.SPI()
6965
70-
# create a thermocouple object with the above
71-
thermocouple = adafruit_max31856.MAX31856(spi, cs)
66+
# allocate a CS pin and set the direction
67+
cs = digitalio.DigitalInOut(board.D5)
68+
cs.direction = digitalio.Direction.OUTPUT
7269
73-
# print the temperature!
74-
print(thermocouple.temperature)
70+
# create a thermocouple object with the above
71+
thermocouple = adafruit_max31856.MAX31856(spi, cs)
72+
73+
# print the temperature!
74+
print(thermocouple.temperature)
7575
7676
7777
Contributing

adafruit_max31856.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
**Software and Dependencies:**
2323
2424
* Adafruit CircuitPython firmware for the supported boards:
25-
https://github.com/adafruit/circuitpython/releases
25+
https://circuitpython.org/downloads
2626
2727
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
28+
2829
"""
2930

3031
from time import sleep
@@ -108,11 +109,37 @@ class ThermocoupleType: # pylint: disable=too-few-public-methods
108109
class MAX31856:
109110
"""Driver for the MAX31856 Universal Thermocouple Amplifier
110111
111-
:param ~busio.SPI spi_bus: The SPI bus the MAX31856 is connected to.
112-
:param ~microcontroller.Pin cs: The pin used for the CS signal.
113-
:param ~adafruit_max31856.ThermocoupleType thermocouple_type: The type of thermocouple.\
112+
:param ~busio.SPI spi: The SPI bus the MAX31856 is connected to.
113+
:param ~microcontroller.Pin cs: The pin used for the CS signal.
114+
:param ~adafruit_max31856.ThermocoupleType thermocouple_type: The type of thermocouple.\
114115
Default is Type K.
115116
117+
**Quickstart: Importing and using the MAX31856**
118+
119+
Here is an example of using the :class:`MAX31856` class.
120+
First you will need to import the libraries to use the sensor
121+
122+
.. code-block:: python
123+
124+
import board
125+
from digitalio import DigitalInOut, Direction
126+
import adafruit_max31856
127+
128+
Once this is done you can define your `board.SPI` object and define your sensor object
129+
130+
.. code-block:: python
131+
132+
spi = board.SPI()
133+
cs = digitalio.DigitalInOut(board.D5) # Chip select of the MAX31856 board.
134+
sensor = adafruit_max31856.MAX31856(spi, cs)
135+
136+
137+
Now you have access to the :attr:`temperature` attribute
138+
139+
.. code-block:: python
140+
141+
temperature = sensor.temperature
142+
116143
"""
117144

118145
# A class level buffer to reduce allocations for reading and writing.
@@ -137,7 +164,7 @@ def __init__(self, spi, cs, thermocouple_type=ThermocoupleType.K):
137164

138165
@property
139166
def temperature(self):
140-
"""The temperature of the sensor and return its value in degrees celsius. (read-only)"""
167+
"""The temperature of the sensor and return its value in degrees Celsius. (read-only)"""
141168
self._perform_one_shot_measurement()
142169

143170
# unpack the 3-byte temperature as 4 bytes
@@ -155,7 +182,7 @@ def temperature(self):
155182

156183
@property
157184
def reference_temperature(self):
158-
"""The temperature of the cold junction in degrees celsius. (read-only)"""
185+
"""The temperature of the cold junction in degrees Celsius. (read-only)"""
159186
self._perform_one_shot_measurement()
160187

161188
raw_read = unpack(">h", self._read_register(_MAX31856_CJTH_REG, 2))[0]

docs/examples.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/max31856_simpletest.py
77
:caption: examples/max31856_simpletest.py
88
:linenos:
9+
10+
Thresholds and Fault example
11+
----------------------------
12+
13+
Example showing how to use thresholds
14+
15+
.. literalinclude:: ../examples/max31856_thresholds_and_faults.py
16+
:caption: examples/max31856_thresholds_and_faults.py
17+
:linenos:

docs/index.rst

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

26+
Adafruit Universal Thermocouple Amplifier MAX31856 Breakout Learning Guide <https://learn.adafruit.com/adafruit-max31856-thermocouple-amplifier>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

31+
Adafruit Universal Thermocouple Amplifier MAX31856 Breakout <https://www.adafruit.com/product/3263>
32+
2933
.. toctree::
3034
:caption: Other Links
3135

examples/max31856_simpletest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
# SPDX-License-Identifier: MIT
33

44
import board
5-
import busio
65
import digitalio
76
import adafruit_max31856
87

9-
# create a spi object
10-
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
8+
# Create sensor object, communicating over the board's default SPI bus
9+
spi = board.SPI()
1110

1211
# allocate a CS pin and set the direction
1312
cs = digitalio.DigitalInOut(board.D5)

examples/max31856_thresholds_and_faults.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
import time
55
import board
6-
import busio
76
import digitalio
87
import adafruit_max31856
98

10-
# create a spi object
11-
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
9+
# Create sensor object, communicating over the board's default SPI bus
10+
spi = board.SPI()
1211

1312
# allocate a CS pin and set the direction
1413
cs = digitalio.DigitalInOut(board.D0)

0 commit comments

Comments
 (0)