diff --git a/README.rst b/README.rst index 0f8b6ed..ca431ea 100644 --- a/README.rst +++ b/README.rst @@ -64,10 +64,9 @@ Usage Example import time import board - import busio from adafruit_emc2101 import EMC2101 - i2c = busio.I2C(board.SCL, board.SDA) + i2c = board.I2C() # uses board.SCL and board.SDA emc = EMC2101(i2c) print("Setting fan speed to 25%") diff --git a/adafruit_emc2101/__init__.py b/adafruit_emc2101/__init__.py index 0ccec77..4e68a95 100644 --- a/adafruit_emc2101/__init__.py +++ b/adafruit_emc2101/__init__.py @@ -15,14 +15,20 @@ **Hardware:** -* `Adafruit EMC2101 Breakout `_ +* `Adafruit EMC2101 Breakout + `_ (Product ID: 4808) **Software and Dependencies:** * Adafruit CircuitPython firmware for the supported boards: - https://github.com/adafruit/circuitpython/releases -* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice -* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register + https://circuitpython.org/downloads + +* Adafruit's Bus Device library: + https://github.com/adafruit/Adafruit_CircuitPython_BusDevice + +* Adafruit's Register library: + https://github.com/adafruit/Adafruit_CircuitPython_Register + """ from micropython import const @@ -136,6 +142,34 @@ class EMC2101: # pylint: disable=too-many-instance-attributes :param ~busio.I2C i2c_bus: The I2C bus the EMC is connected to. + + **Quickstart: Importing and using the device** + + Here is an example of using the :class:`EMC2101` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + from adafruit_emc2101.emc2101_lut import EMC2101_LUT as EMC2101 + + Once this is done you can define your `board.I2C` object and define your sensor object + + .. code-block:: python + + i2c = board.I2C() # uses board.SCL and board.SDA + emc = EMC2101(i2c) + + Now you have access to the :attr:`manual_fan_speed` attribute to setup the + desired fanspeed + + .. code-block:: python + + emc.manual_fan_speed = 25 + + + + If you need control over PWM frequency and the controller's built in temperature/speed look-up table (LUT), you will need :class:`emc2101_lut.EMC2101_LUT` which extends this class to add those features, at the cost of increased memory usage. @@ -282,7 +316,7 @@ def spinup_time(self, spin_time): @property def spinup_drive(self): - """The drive strengh of the fan on spinup in % max RPM""" + """The drive strength of the fan on spinup in % max RPM""" return self._spin_drive @spinup_drive.setter diff --git a/adafruit_emc2101/emc2101_lut.py b/adafruit_emc2101/emc2101_lut.py index 3679215..1f98992 100644 --- a/adafruit_emc2101/emc2101_lut.py +++ b/adafruit_emc2101/emc2101_lut.py @@ -15,15 +15,19 @@ **Hardware:** -* `Adafruit EMC2101 Breakout `_ +* `Adafruit EMC2101 Breakout `_ (Product ID: 4808) **Software and Dependencies:** * Adafruit CircuitPython firmware for the supported boards: - https://github.com/adafruit/circuitpython/releases + https://circuitpython.org/downloads + +* Adafruit's Bus Device library: + https://github.com/adafruit/Adafruit_CircuitPython_BusDevice + +* Adafruit's Register library: + https://github.com/adafruit/Adafruit_CircuitPython_Register -* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice -* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register The class defined here may be used instead of :class:`adafruit_emc2101.EMC2101`, if your device has enough RAM to support it. This class adds LUT control diff --git a/docs/index.rst b/docs/index.rst index 105b82f..dd01527 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,10 +23,12 @@ Table of Contents .. toctree:: :caption: Tutorials + EMC2101 Fan Controller and Temperature sensor Learning Guide .. toctree:: :caption: Related Products + EMC2101 Fan Controller and Temperature sensor .. toctree:: :caption: Other Links diff --git a/examples/emc2101_lut_example.py b/examples/emc2101_lut_example.py index 2e4ce04..9211320 100644 --- a/examples/emc2101_lut_example.py +++ b/examples/emc2101_lut_example.py @@ -3,10 +3,9 @@ # SPDX-License-Identifier: MIT import time import board -import busio from adafruit_emc2101.emc2101_lut import EMC2101_LUT as EMC2101 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() # uses board.SCL and board.SDA FAN_MAX_RPM = 1700 emc = EMC2101(i2c) diff --git a/examples/emc2101_set_pwm_freq.py b/examples/emc2101_set_pwm_freq.py index 78df320..454f850 100644 --- a/examples/emc2101_set_pwm_freq.py +++ b/examples/emc2101_set_pwm_freq.py @@ -3,10 +3,9 @@ # SPDX-License-Identifier: MIT import time import board -import busio from adafruit_emc2101.emc2101_lut import EMC2101_LUT as EMC2101 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() # uses board.SCL and board.SDA emc = EMC2101(i2c) emc.set_pwm_clock(use_preset=False) diff --git a/examples/emc2101_simpletest.py b/examples/emc2101_simpletest.py index 567792c..90a1672 100644 --- a/examples/emc2101_simpletest.py +++ b/examples/emc2101_simpletest.py @@ -3,11 +3,9 @@ # SPDX-License-Identifier: MIT import time import board -import busio from adafruit_emc2101 import EMC2101 -i2c = busio.I2C(board.SCL, board.SDA) - +i2c = board.I2C() # uses board.SCL and board.SDA emc = EMC2101(i2c) while True: print("Setting fan speed to 25%")