Skip to content

Commit bcf211c

Browse files
committed
docs
1 parent f546de7 commit bcf211c

File tree

1 file changed

+102
-25
lines changed

1 file changed

+102
-25
lines changed

adafruit_tla202x/__init__.py

Lines changed: 102 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,91 @@ def is_valid(cls, value):
6464

6565

6666
class DataRate(CV):
67-
"""Options for ``data_rate``, for selecting the rate at which samples are taken while measuring
68-
the voltage across the input pins"""
67+
"""Options for :py:attr:`~adafruit_tla202x.TLA2024.data_rate`, to select the rate at which
68+
samples are taken while measuring the voltage across the input pins
69+
70+
+-------------------------------+-------------------------+
71+
| Rate | Measurement Rate |
72+
+===============================+=========================+
73+
| :py:const:`Rate.RATE_128SPS` | 128 Samples per second |
74+
+-------------------------------+-------------------------+
75+
| :py:const:`Rate.RATE_250SPS` | 250 Samples per second |
76+
+-------------------------------+-------------------------+
77+
| :py:const:`Rate.RATE_490SPS` | 490 Samples per second |
78+
+-------------------------------+-------------------------+
79+
| :py:const:`Rate.RATE_920SPS` | 920 Samples per second |
80+
+-------------------------------+-------------------------+
81+
| :py:const:`Rate.RATE_1600SPS` | 1600 Samples per second |
82+
+-------------------------------+-------------------------+
83+
| :py:const:`Rate.RATE_2400SPS` | 2400 Samples per second |
84+
+-------------------------------+-------------------------+
85+
| :py:const:`Rate.RATE_3300SPS` | 3300 Samples per second |
86+
+-------------------------------+-------------------------+
6987
7088
71-
class Mode(CV):
72-
"""Options for ``mode``
73-
74-
In Continuous mode, measurements are taken continuously and calling ``voltage`` will
75-
return the latest measurement.
89+
"""
7690

77-
Setting the mode to ONE_SHOT makes the ADC take a single
78-
measurement and then goes into a low power state."""
7991

92+
DataRate.add_values(
93+
(
94+
("RATE_128SPS", 0x0, 128, None),
95+
("RATE_250SPS", 0x1, 250, None),
96+
("RATE_490SPS", 0x2, 490, None),
97+
("RATE_920SPS", 0x3, 920, None),
98+
("RATE_1600SPS", 0x4, 1600, None),
99+
("RATE_2400SPS", 0x5, 2400, None),
100+
("RATE_3300SPS", 0x6, 3300, None),
101+
)
102+
)
80103

81-
class Range(CV):
82-
"""Options for ``range``, used to select the measurement range by adjusting the
83-
gain of the internal amplifier"""
84104

105+
class Mode(CV):
106+
"""Options for :py:attr:`~adafruit_tla202x.TLA2024.mode`
107+
108+
+----------------------------+--------------------------------------------------------------+
109+
| Mode | Description |
110+
+============================+==============================================================+
111+
| :py:const:`Mode.CONTINUOUS`| In Continuous mode, measurements are taken |
112+
| | |
113+
| | continuously and getting |
114+
| | :py:attr:`~adafruit_tla202x.TLA2024.voltage` |
115+
| | |
116+
| | will return the latest measurement. |
117+
+----------------------------+--------------------------------------------------------------+
118+
| :py:const:`Mode.ONE_SHOT` | Setting the mode to :py:data:`~Mode.ONE_SHOT` takes a single |
119+
| | |
120+
| | measurement and then goes into a low power state. |
121+
+----------------------------+--------------------------------------------------------------+
85122
86-
class Mux(CV):
87-
"""Options for ``mux`` to choose the inputs that voltage will be measured across"""
123+
"""
88124

89125

90126
Mode.add_values(
91127
(("CONTINUOUS", 0, "Continuous", None), ("ONE_SHOT", 1, "One Shot", None),)
92128
)
93129

130+
131+
class Range(CV):
132+
"""Options for :py:attr:`~adafruit_tla202x.TLA2024.range`, used to select the measurement range
133+
by adjusting the gain of the internal amplifier
134+
135+
+--------------------------------+-------------------+------------+
136+
| Range | Measurement Range | Resolution |
137+
+================================+===================+============+
138+
| :py:const:`Range.RANGE_6_144V` | ±6.144 V | 3 mV |
139+
+--------------------------------+-------------------+------------+
140+
| :py:const:`Range.RANGE_4_096V` | ±4.096 V | 2 mV |
141+
+--------------------------------+-------------------+------------+
142+
| :py:const:`Range.RANGE_2_048V` | ±2.048 V | 1 mV |
143+
+--------------------------------+-------------------+------------+
144+
| :py:const:`Range.RANGE_1_024V` | ±1.024 V | 0.5 mV |
145+
+--------------------------------+-------------------+------------+
146+
| :py:const:`Range.RANGE_0_512V` | ±0.512 V | 0.25 mV |
147+
+--------------------------------+-------------------+------------+
148+
149+
"""
150+
151+
94152
Range.add_values(
95153
(
96154
("RANGE_6_144V", 0x0, 6.144, 3),
@@ -101,17 +159,34 @@ class Mux(CV):
101159
("RANGE_0_256V", 0x5, 0.256, 0.125),
102160
)
103161
)
104-
DataRate.add_values(
105-
(
106-
("RATE_128SPS", 0x0, 128, None),
107-
("RATE_250SPS", 0x1, 250, None),
108-
("RATE_490SPS", 0x2, 490, None),
109-
("RATE_920SPS", 0x3, 920, None),
110-
("RATE_1600SPS", 0x4, 1600, None),
111-
("RATE_2400SPS", 0x5, 2400, None),
112-
("RATE_3300SPS", 0x6, 3300, None),
113-
)
114-
)
162+
163+
164+
class Mux(CV):
165+
"""Options for :py:attr:`~adafruit_tla202x.TLA2024.mux` to choose the inputs that voltage will
166+
be measured across
167+
168+
+-------------------------------+--------------+--------------+
169+
| Mux | Positive Pin | Negative Pin |
170+
+===============================+==============+==============+
171+
| :py:const:`Mux.MUX_AIN0_AIN1` | AIN 0 | AIN 1 |
172+
+-------------------------------+--------------+--------------+
173+
| :py:const:`Mux.MUX_AIN0_AIN3` | AIN 0 | AIN 3 |
174+
+-------------------------------+--------------+--------------+
175+
| :py:const:`Mux.MUX_AIN1_AIN3` | AIN 1 | AIN 3 |
176+
+-------------------------------+--------------+--------------+
177+
| :py:const:`Mux.MUX_AIN2_AIN3` | AIN 2 | AIN 3 |
178+
+-------------------------------+--------------+--------------+
179+
| :py:const:`Mux.MUX_AIN0_GND` | AIN 0 | GND |
180+
+-------------------------------+--------------+--------------+
181+
| :py:const:`Mux.MUX_AIN1_GND` | AIN 1 | GND |
182+
+-------------------------------+--------------+--------------+
183+
| :py:const:`Mux.MUX_AIN2_GND` | AIN 2 | GND |
184+
+-------------------------------+--------------+--------------+
185+
| :py:const:`Mux.MUX_AIN3_GND` | AIN 3 | GND |
186+
+-------------------------------+--------------+--------------+
187+
188+
"""
189+
115190

116191
Mux.add_values(
117192
(
@@ -125,6 +200,8 @@ class Mux(CV):
125200
("MUX_AIN3_GND", 0x7, "AIN 3 to GND", None),
126201
)
127202
)
203+
204+
128205
# TODO: Verify/fix negative voltages
129206
# * check sign conversion
130207
# implement AnalogIo/ AnalogRead API

0 commit comments

Comments
 (0)