Skip to content

Split file for low mem like samd21 #6

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
Mar 19, 2021
Merged

Conversation

rpavlik
Copy link
Contributor

@rpavlik rpavlik commented Mar 14, 2021

I figured since this was the second time I poked at this, I should publish it in a better way. A .mpy file of the main library now lets you do basic fan monitoring, temp monitoring, and speed setting on a SAMD21 like the QT Py. The extra functionality (LUT, PWM frequency) was moved to a derived class in a separate file.

I haven't tested the full thing yet, just the small base class.

@ladyada
Copy link
Member

ladyada commented Mar 14, 2021

@rpavlik i can dig it :) please tag/assign me once its passing CI!

@rpavlik
Copy link
Contributor Author

rpavlik commented Mar 15, 2021

Looks like it's passing CI. I'll try the "full version"
out on my CP Bluefruit or Clue soon (hopefully tonight) since pushing untested code makes me nervous

@tannewt tannewt requested a review from ladyada March 15, 2021 23:11
@ladyada
Copy link
Member

ladyada commented Mar 16, 2021

@caternuson do you by chance have one of these? if not i can test it later!

@caternuson
Copy link
Contributor

@ladyada sry, i do not. (but will add to list to snag one eventually)

@rpavlik
Copy link
Contributor Author

rpavlik commented Mar 16, 2021

Surprised not everybody is on the adabox list :) (Edit: Oh, they probably don't have the emc2101, not the dev boards)

Interestingly, the current (old) version of the library doesn't work with the LUT example:

code.py output:
Traceback (most recent call last):
  File "code.py", line 16, in <module>
  File "adafruit_emc2101.py", line 142, in __setitem__
  File "adafruit_emc2101.py", line 193, in _set_lut
AttributeError: 'int' object has no attribute '__set__'

The PWM example seems to work in that it does not error, both before and after my change. I can't find my fan at the moment 🤦

@rpavlik
Copy link
Contributor Author

rpavlik commented Mar 16, 2021

OK, so I fixed that too, but in the process I found some inefficiencies in that class and managed to save 2640 bytes of ram on an nrf52840

@rpavlik rpavlik force-pushed the split branch 2 times, most recently from 96a3a11 to 685ceb2 Compare March 16, 2021 19:50
@rpavlik rpavlik mentioned this pull request Mar 16, 2021
@rpavlik rpavlik mentioned this pull request Mar 16, 2021
@rpavlik
Copy link
Contributor Author

rpavlik commented Mar 16, 2021

OK, I can confirm that this now appears to work (at least that the i2c trace looks OK, my fan is MIA at the moment...), confirmed with and without LUT usage. Ready to review and merge.

I did rebase on top of #9 which should be merged first: that fixes the LUT stuff that was apparently broken when I got here.

@ladyada ladyada requested a review from caternuson March 17, 2021 15:32
@caternuson
Copy link
Contributor

Looks good. Tested with QT PY.

Adafruit CircuitPython 6.1.0 on 2021-01-21; Adafruit QT Py M0 with samd21e18
>>> import board
>>> import adafruit_emc2101
>>> emc = adafruit_emc2101.EMC2101(board.I2C())
>>> emc.fan_speed
737.0
>>> emc.manual_fan_speed = 50
>>> emc.fan_speed
3527.11
>>> emc.fan_speed
2577.57
>>> 

Also made sure emc2101_simpletest.py worked (no external temperature sensor):

Adafruit CircuitPython 6.1.0 on 2021-01-21; Adafruit QT Py M0 with samd21e18
>>> import emc2101_simpletest
Setting fan speed to 25%
Fan speed 1205.63
Setting fan speed to 50%
Fan speed 2543.57
Setting fan speed to 75%
Fan speed 3536.35
Setting fan speed to 100%
Fan speed 3545.63
External temperature: 127.0 C
Internal temperature: 24 C

@caternuson caternuson merged commit ba9c879 into adafruit:main Mar 19, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 24, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO08X to 1.1.0 from 1.0.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO08x#19 from adafruit/patch-test
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO08x#14 from yugyesh/patch-3

Updating https://github.com/adafruit/Adafruit_CircuitPython_CAP1188 to 1.2.7 from 1.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_CAP1188#20 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_EMC2101 to 1.1.5 from 1.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_EMC2101#7 from rpavlik/slim-lut
  > Merge pull request adafruit/Adafruit_CircuitPython_EMC2101#6 from rpavlik/split
  > Merge pull request adafruit/Adafruit_CircuitPython_EMC2101#9 from rpavlik/fix-lut
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 3.5.8 from 3.5.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#130 from adafruit/anecdata-patch-2
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_TLC5947 to 1.3.4 from 1.3.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_TLC5947#24 from adafruit/REUSE
  > "Increase duplicate code check threshold "
  > Re-added pylint install to build.yml
  > Removed pylint process from github workflow
  > Hardcoded Black and REUSE versions
  > Added pre-commit-config file
  > Added pre-commit and SPDX copyright

Updating https://github.com/adafruit/Adafruit_CircuitPython_TLV493D to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_TLV493D#11 from lubarb/setup-edit
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Cycling_Speed_and_Cadence to 1.1.4 from 1.1.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Cycling_Speed_and_Cadence#6 from adafruit/pre-commit
  > "Increase duplicate code check threshold "
  > Re-added pylint install to build.yml
  > Removed pylint process from github workflow
  > Hardcoded Black and REUSE versions
  > Added pre-commit-config file
  > Added pre-commit and SPDX copyright

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.6.0 from 1.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#18 from kmatch98/icon_palette
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#25 from jposada202020/main
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#24 from kmatch98/touch_fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_HID to 4.2.0 from 4.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_HID#62 from jfurcean/add-led-status
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 0.14.1 from 0.14.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#48 from FoamyGuy/readinto_fallback
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#49 from kmatch98/readinto_fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_MIDI to 1.3.4 from 1.3.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_MIDI#34 from adafruit/test-lint
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.3.0 from 0.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#19 from adafruit/add-tests
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#18 from adafruit/jepler-rxuart-example
  > "Increase duplicate code check threshold "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants