Skip to content

Commit 3885d15

Browse files
committed
Docs improvements
1 parent 823d264 commit 3885d15

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

adafruit_emc2101/__init__.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
2222
* Adafruit CircuitPython firmware for the supported boards:
2323
https://github.com/adafruit/circuitpython/releases
24-
25-
# * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
26-
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
24+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
25+
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
2726
"""
2827

2928
from micropython import const
@@ -133,8 +132,13 @@ class SpinupTime(CV):
133132

134133

135134
class EMC2101: # pylint: disable=too-many-instance-attributes
136-
"""Driver for the EMC2101 Fan Controller.
135+
"""Basic driver for the EMC2101 Fan Controller.
136+
137137
:param ~busio.I2C i2c_bus: The I2C bus the EMC is connected to.
138+
139+
If you need control over PWM frequency and the controller's built in temperature/speed
140+
look-up table (LUT), you will need :class:`emc2101_lut.EMC2101_LUT` which extends this
141+
class to add those features, at the cost of increased memory usage.
138142
"""
139143

140144
_part_id = ROUnaryStruct(_REG_PARTID, "<B")
@@ -238,7 +242,12 @@ def manual_fan_speed(self, fan_speed):
238242
@property
239243
def lut_enabled(self):
240244
"""Enable or disable the internal look up table used to map a given temperature
241-
to a fan speed. When the LUT is disabled fan speed can be changed with `manual_fan_speed`"""
245+
to a fan speed.
246+
247+
When the LUT is disabled (the default), fan speed can be changed with `manual_fan_speed`.
248+
To actually set this to True and modify the LUT, you need to use the extended version of
249+
this driver, :class:`emc2101_lut.EMC2101_LUT`
250+
"""
242251
return not self._fan_lut_prog
243252

244253
@property

adafruit_emc2101/emc2101_lut.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
* Adafruit CircuitPython firmware for the supported boards:
2323
https://github.com/adafruit/circuitpython/releases
2424
25-
# * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
26-
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
25+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
26+
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
2727
28-
The class defined here may be used instead of adafruit_emc2101.EMC2101,
28+
The class defined here may be used instead of :class:`adafruit_emc2101.EMC2101`,
2929
if your device has enough RAM to support it. This class adds LUT control
3030
and PWM frequency control to the base feature set.
3131
"""
@@ -56,7 +56,13 @@ def _speed_to_lsb(percentage):
5656

5757
class FanSpeedLUT:
5858
"""A class used to provide a dict-like interface to the EMC2101's Temperature to Fan speed
59-
Look Up Table"""
59+
Look Up Table.
60+
61+
Keys are integer temperatures, values are fan duty cycles between 0 and 100.
62+
A max of 8 values may be stored.
63+
64+
To remove a single stored point in the LUT, assign it as `None`.
65+
"""
6066

6167
# 8 (Temperature, Speed) pairs in increasing order
6268
_fan_lut = StructArray(_LUT_BASE, "<B", 16)
@@ -135,7 +141,10 @@ def _set_lut_entry(self, idx, temp, speed):
135141

136142

137143
class EMC2101_LUT(EMC2101): # pylint: disable=too-many-instance-attributes
138-
"""Driver for the EMC2101 Fan Controller.
144+
"""Driver for the EMC2101 Fan Controller, with PWM frequency and LUT control.
145+
146+
See :class:`adafruit_emc2101.EMC2101` for the base/common functionality.
147+
139148
:param ~busio.I2C i2c_bus: The I2C bus the EMC is connected to.
140149
"""
141150

@@ -221,5 +230,5 @@ def lut_enabled(self, enable_lut):
221230

222231
@property
223232
def lut(self):
224-
"""The dict-like representation of the LUT"""
233+
"""The dict-like representation of the LUT, actually of type :class:`FanSpeedLUT`"""
225234
return self._lut

docs/examples.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ LUT Usage Example
1111
-----------------
1212

1313
Use the temperature to fan speed Look Up Table to automatically control the fan speed.
14+
This example requires more memory than the first one because it needs to use the extended
15+
:class:`adafruit_emc2101.emc2101_lut.EMC2101_LUT` driver to access LUT functionality.
1416

1517
.. literalinclude:: ../examples/emc2101_lut_example.py
1618
:caption: examples/emc2101_lut_example.py
@@ -21,6 +23,8 @@ PWM Tuning
2123
-----------------
2224

2325
Adjust the EMC2101s PWM settings to fit your application.
26+
This example requires more memory than the first one because it needs to use the extended
27+
:class:`adafruit_emc2101.emc2101_lut.EMC2101_LUT` driver to access LUT functionality.
2428

2529
.. literalinclude:: ../examples/set_pwm_freq.py
2630
:caption: examples/set_pwm_freq.py

0 commit comments

Comments
 (0)