adafruit / Adafruit_CircuitPython_EMC2101

CircuitPython driver for EMC2101 brushless fan controller
MIT License
3 stars 9 forks source link

Fix emc2101_enums import #32

Closed caternuson closed 1 year ago

caternuson commented 1 year ago

For #31.

Tested on QT PY RP2040:

Adafruit CircuitPython 8.2.2 on 2023-07-31; Adafruit QT Py RP2040 with rp2040
>>> import board
>>> from adafruit_emc2101 import EMC2101
>>> i2c = board.STEMMA_I2C()
>>> emc = EMC2101(i2c)
>>> emc.spinup_drive
3
>>> emc.spinup_drive = 0
>>> emc.spinup_drive
0
>>> 
vlycop commented 1 year ago

Hi ! OP here What about L413 and L478 ? Should they be fixed to ?

Also i am very surprise that any other part of this library don't need this .

Not patching the other line cause spinup_time to not work

(venv) pi@prusabox:~/test_emc2101 $ vi /home/pi/test_emc2101/venv/lib/python3.7/site-packages/adafruit_emc2101/__init__.py 
(venv) pi@prusabox:~/test_emc2101 $ rm -r /home/pi/test_emc2101/venv/lib/python3.7/site-packages/adafruit_emc2101/__pycache__
(venv) pi@prusabox:~/test_emc2101 $ python
Python 3.7.3 (default, Jun 29 2023, 18:03:57) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> from adafruit_emc2101.emc2101_lut import EMC2101_LUT as EMC2101
>>> i2c = board.I2C()
>>> emc = EMC2101(i2c)
>>> emc.spinup_drive
1
>>> emc.spinup_drive = 3
>>> emc.spinup_drive
3
>>> emc.spinup_time
4
>>> emc.spinup_time = 7
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/test_emc2101/venv/lib/python3.7/site-packages/adafruit_emc2101/__init__.py", line 413, in spinup_time
    from emc2101_enums import SpinupTime
ModuleNotFoundError: No module named 'emc2101_enums'

while doing so fix the issue

(venv) pi@prusabox:~/test_emc2101 $ vi /home/pi/test_emc2101/venv/lib/python3.7/site-packages/adafruit_emc2101/__init__.py 
(venv) pi@prusabox:~/test_emc2101 $ rm -r /home/pi/test_emc2101/venv/lib/python3.7/site-packages/adafruit_emc2101/__pycache__
(venv) pi@prusabox:~/test_emc2101 $ python
Python 3.7.3 (default, Jun 29 2023, 18:03:57) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> from adafruit_emc2101.emc2101_lut import EMC2101_LUT as EMC2101
>>> i2c = board.I2C()
>>> emc = EMC2101(i2c)
>>> emc.spinup_drive
3
>>> emc.spinup_drive = 1
>>> emc.spinup_drive
1
>>> emc.spinup_time
7
>>> emc.spinup_time = 4
>>> emc.spinup_time
4
>>>
caternuson commented 1 year ago

Related forum post: https://forums.adafruit.com/viewtopic.php?t=204056

Good catch. Those other imports should also be updated. Pushed those changes.

caternuson commented 1 year ago

TBH - This is one of the python-isms I'm never sure about myself. I actually like your approach better though.

caternuson commented 1 year ago

@FoamyGuy thanks for updating and closing this one up!