Skip to content

Commit 8296605

Browse files
authored
Merge pull request #16 from jposada202020/improving_docs
Improving docs and adding title in the examples.rst
2 parents 5e14554 + 3c08383 commit 8296605

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed

adafruit_pct2075.py

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
1717
**Hardware:**
1818
19-
* Adafruit PCT2075 Breakout: https://www.adafruit.com/products/4369
19+
* Adafruit PCT2075 Temperature Sensor Breakout: https://www.adafruit.com/products/4369
2020
2121
**Software and Dependencies:**
2222
2323
* Adafruit CircuitPython firmware for the supported boards:
24-
https://github.com/adafruit/circuitpython/releases
24+
https://circuitpython.org/downloads
2525
2626
2727
@@ -67,20 +67,47 @@ class FaultCount:
6767

6868
class PCT2075:
6969
"""Driver for the PCT2075 Digital Temperature Sensor and Thermal Watchdog.
70+
7071
:param ~busio.I2C i2c_bus: The I2C bus the PCT2075 is connected to.
71-
:param address: The I2C device address for the sensor. Default is ``0x37``.
72+
:param address: The I2C device address for the sensor. Default is :const:`0x37`
73+
74+
**Quickstart: Importing and using the PCT2075 temperature sensor**
75+
76+
Here is one way of importing the `PCT2075` class so you can use it with the name ``pct``.
77+
First you will need to import the libraries to use the sensor
78+
79+
.. code-block:: python
80+
81+
import busio
82+
import board
83+
import adafruit_pct2075
84+
85+
Once this is done you can define your `busio.I2C` object and define your sensor object
86+
87+
.. code-block:: python
88+
89+
i2c = busio.I2C(board.SCL, board.SDA)
90+
pct = adafruit_pct2075.PCT2075(i2c)
91+
92+
Now you have access to the temperature using the attribute :attr:`temperature`.
93+
94+
.. code-block:: python
95+
96+
temperature = pct.temperature
97+
7298
"""
7399

74100
def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
75101
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
76102

77103
_temperature = ROUnaryStruct(PCT2075_REGISTER_TEMP, ">h")
78104
mode = RWBit(PCT2075_REGISTER_CONFIG, 1, register_width=1)
79-
"""Sets the alert mode. In comparitor mode, the sensor acts like a thermostat and will activate
105+
"""Sets the alert mode. In comparator mode, the sensor acts like a thermostat and will activate
80106
the INT pin according to `high_temp_active_high` when an alert is triggered. The INT pin will be
81-
deactiveated when the temperature falls below `temperature_hysteresis`. In interrupt mode the
82-
INT pin is activated once when a temperature fault is detected, and once more when the
83-
temperature falls below `temperature_hysteresis`. In interrupt mode, the alert is cleared by
107+
deactivated when the temperature falls below :attr:`temperature_hysteresis`.
108+
In interrupt mode the INT pin is activated once when a temperature fault
109+
is detected, and once more when the temperature falls below
110+
:attr:`temperature_hysteresis`. In interrupt mode, the alert is cleared by
84111
reading a property"""
85112

86113
shutdown = RWBit(PCT2075_REGISTER_CONFIG, 0, 1)
@@ -97,13 +124,14 @@ def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
97124

98125
@property
99126
def temperature(self):
100-
"""Returns the current temperature in degress celsius. Resolution is 0.125 degrees C"""
127+
"""Returns the current temperature in degrees Celsius.
128+
Resolution is 0.125 degrees Celsius"""
101129
return (self._temperature >> 5) * 0.125
102130

103131
@property
104132
def high_temperature_threshold(self):
105133
"""The temperature in degrees celsius that will trigger an alert on the INT pin if it is
106-
exceeded. Resolution is 0.5 degrees C."""
134+
exceeded. Resolution is 0.5 degrees Celsius"""
107135
return (self._high_temperature_threshold >> 7) * 0.5
108136

109137
@high_temperature_threshold.setter
@@ -112,9 +140,12 @@ def high_temperature_threshold(self, value):
112140

113141
@property
114142
def temperature_hysteresis(self):
115-
"""The temperature hysteresis value defines the bottom of the temperature range in degrees
116-
C in which the temperature is still considered high". `temperature_hysteresis` must be
117-
lower than `high_temperature_threshold`. Resolution is 0.5 degrees C.
143+
"""The temperature hysteresis value defines the bottom
144+
of the temperature range in degrees Celsius in which
145+
the temperature is still considered high.
146+
:attr:`temperature_hysteresis` must be lower than
147+
:attr:`high_temperature_threshold`.
148+
Resolution is 0.5 degrees Celsius
118149
"""
119150
return (self._temp_hysteresis >> 7) * 0.5
120151

@@ -130,8 +161,8 @@ def temperature_hysteresis(self, value):
130161
def faults_to_alert(self):
131162
"""The number of consecutive high temperature faults required to raise an alert. An fault
132163
is tripped each time the sensor measures the temperature to be greater than
133-
`high_temperature_threshold`. The rate at which the sensor measures the temperature
134-
is defined by `delay_between_measurements`.
164+
:attr:`high_temperature_threshold`. The rate at which the sensor measures the temperature
165+
is defined by :attr:`delay_between_measurements`.
135166
"""
136167

137168
return self._fault_queue_length

docs/examples.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Ensure your device works with this simple test.
77
:caption: examples/pct2075_high_temp_alert_example.py
88
:linenos:
99

10+
11+
High temperature alert example
12+
------------------------------
13+
14+
Shows a basic example on how to use the high temperature alert mode
15+
1016
.. literalinclude:: ../examples/pct2075_simpletest.py
1117
:caption: examples/pct2075_simpletest.py
1218
:linenos:

0 commit comments

Comments
 (0)