Skip to content

Improving_docs #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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%")
Expand Down
44 changes: 39 additions & 5 deletions adafruit_emc2101/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@

**Hardware:**

* `Adafruit EMC2101 Breakout <https://adafruit.com/product/4808>`_
* `Adafruit EMC2101 Breakout
<https://adafruit.com/product/4808>`_ (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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions adafruit_emc2101/emc2101_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@

**Hardware:**

* `Adafruit EMC2101 Breakout <https://adafruit.com/product/4808>`_
* `Adafruit EMC2101 Breakout <https://adafruit.com/product/4808>`_ (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
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ Table of Contents
.. toctree::
:caption: Tutorials

EMC2101 Fan Controller and Temperature sensor Learning Guide <https://learn.adafruit.com/emc2101-fan-controller-and-temperature-sensor>

.. toctree::
:caption: Related Products

EMC2101 Fan Controller and Temperature sensor <https://www.adafruit.com/product/4808>

.. toctree::
:caption: Other Links
Expand Down
3 changes: 1 addition & 2 deletions examples/emc2101_lut_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions examples/emc2101_set_pwm_freq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions examples/emc2101_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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%")
Expand Down