micropython-esp32 icon indicating copy to clipboard operation
micropython-esp32 copied to clipboard

APA102 Driver support

Open Hokyjack opened this issue 8 years ago • 16 comments

Hello, I have MicroPython v1.9.1-219-g3580284e installed at my ESP32 NodeMCU development board, but unfortunately I can't find APA102 library included altought it should be in ESP8266 1.9.1 microPython.

 from apa102 import APA102
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'apa102'

how should I add it so I can use it with ESP32? and one more question - is this implementation of apa102 using real HSPI (hardware SPI) or it just bit-bangs the bits?

Hokyjack avatar Jul 04 '17 20:07 Hokyjack

The APA102 driver for esp8266 is very specific to that chip (it uses inline assembler and has specific timing). So it's not straightforward to port it to the esp32. It's anyway just a bit-banging implementation.

It would be easier to write a new driver from scratch for the esp32, in Python, using the SPI peripheral (SCK and MOSI lines).

dpgeorge avatar Jul 05 '17 01:07 dpgeorge

Oh, thanks for the answer, I'll try to write my own driver then

Hokyjack avatar Jul 05 '17 16:07 Hokyjack

Also see #159

mattytrentini avatar Aug 12 '17 02:08 mattytrentini

I'm just wondering why the APA102 implementation was implemented with bit-banging on the ESP8266? I've read the conversation on PR1941 but, while there was some solid, animated discussion and excellent collaboration, I'm not sure why an SPI implementation was chosen?

Was it perhaps that hardware SPI wasn't available at the time? Or that bit-banging produced faster updates that the 80MHz SPI limit? I'm sure I'm missing something obvious!

My understanding was that it should be possible to write a pure Python APA102 driver that just takes in a machine.SPI object. This will work across all ports and be optimised where hardware SPI is available...

mattytrentini avatar Sep 03 '17 10:09 mattytrentini

Oh, and @Hokyjack, are you still looking at creating an APA102 driver? If so, you should also be aware of the end-frame issue in the ESP8266 implementation, documented in PR3037: APA102 LED "n+1" is lighted on write().

mattytrentini avatar Sep 03 '17 10:09 mattytrentini

Mention me (@mcauser) if you want me to test any code on my ESP32 (lolin32) and APA102 strip.

mcauser avatar Sep 05 '17 00:09 mcauser

My understanding was that it should be possible to write a pure Python APA102 driver that just takes in a machine.SPI object.

Yes it should work, even at low SCK frequency. But note that the SPI will use up 3 pins on the MCU whereas the APA102 only needs 2.

dpgeorge avatar Sep 05 '17 05:09 dpgeorge

With the micropython-dotstar library we can probably close this ticket? @mcauser if you could test that library I'd really appreciate it!

Also posted on the forum, for reference.

mattytrentini avatar Jan 13 '19 01:01 mattytrentini

for your library we do belive that i think Linux supportive should be inplace so what do you think about making things for linx bulit in Regards bemnet

On Jan 13, 2019 4:04 AM, "Matt Trentini" [email protected] wrote:

With the micropython-dotstar library https://github.com/mattytrentini/micropython-dotstar we can probably close this ticket? @mcauser https://github.com/mcauser if you could test that library I'd really appreciate it!

Also posted on the forum https://forum.micropython.org/viewtopic.php?f=15&t=5810, for reference.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/micropython/micropython-esp32/issues/121#issuecomment-453793388, or mute the thread https://github.com/notifications/unsubscribe-auth/APM4l3rFhG7Yk8vN9zcA36WMOGXXScRVks5vCoYjgaJpZM4ONp94 .

BEMNETADEFIS avatar Jan 15 '19 19:01 BEMNETADEFIS

@BEMNETADEFIS the current design actually works for Linux right now. The gotcha is that it requires an object (spi) to handle the SPI comms - to do this it just requires two commands; write and deinit. It should be a simple matter to create a class that forwards these methods on to an underlying implementation.

Unfortunately, as I understand, SPI comms is non-standard in Linux right now. But if you have a way of sending SPI data in Python this library could use it with minimal fuss.

mattytrentini avatar Jan 28 '19 12:01 mattytrentini

This is probably only of historical interest now, but I developed a MicroPython APA102/DotStar support library as well over the past few weeks: https://github.com/RobertJBabb/micropython_generic_apa102
The library supports the Adafruit DotStar API, the MicroPython ESP8266 APA102 API, and I added support for Matt's MicroPython SPI DotStar API after I saw his post. I focused on backward compatibilty instead of performance, so I expect that my class will be slower and consume more memory than Matt's. The repository also includes two test files that contain more compact examples of common DotStar demo code than I have seen elsewhere, perhaps that may be of interest to some. I like Matt's implementation so I will probably use his library going forward. As a newbie, what is the best way to coordinate development work with other MicroPython contributors? I enjoyed writing this library but I would like to avoid duplicating effort in the future.

RobertJBabb avatar Jan 29 '19 23:01 RobertJBabb

As a newbie, what is the best way to coordinate development work with other MicroPython contributors?

It's best to start by discussing on the https://forum.micropython.org

dpgeorge avatar Jan 31 '19 07:01 dpgeorge

do i need to develop library I do have an experiance of developing python libraries before how can i create this Recommed me for bigger challange

On Jan 28, 2019 3:26 PM, "Matt Trentini" [email protected] wrote:

@BEMNETADEFIS https://github.com/BEMNETADEFIS the current design actually works for Linux right now. The gotcha is that it requires an object (spi) to handle the SPI comms - to do this it just requires two commands; write and deinit. It should be a simple matter to create a class that forwards these methods on to an underlying implementation.

Unfortunately, as I understand, SPI comms is non-standard in Linux right now. But if you have a way of sending SPI data in Python this library could use it with minimal fuss.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micropython/micropython-esp32/issues/121#issuecomment-458112355, or mute the thread https://github.com/notifications/unsubscribe-auth/APM4lwEB9CM7o_pe7CfobuzBqY-m3hTXks5vHuyDgaJpZM4ONp94 .

BEMNETADEFIS avatar Feb 03 '19 17:02 BEMNETADEFIS

@RobertJBabb As Damien mentioned, raising a topic in the forum is the best bet. Sorry I hadn't stumbled on your effort but I'll be sure to take a look at your implementation!

@BEMNETADEFIS To allow the APA102 driver to work on Linux you just need to come up with a Python class that can satisfy the SPI requirements of the APA102 driver. As mentioned, that means you just need a write and a deinit (and even the latter is not strictly necessary if you don't ever return the resources). Let me know if you need more assistance.

mattytrentini avatar Feb 04 '19 05:02 mattytrentini

the more micropython is avaliable for liunx and hacker zones it become more innovative that why i rised such questions for me linux have python plagin including Apt-get update python.org python 5 # /4/3 that can help for more progressive progrsmming that why i know this question is certainly difficult but does it fits for the exsiting inapplicability of micropython in linux Single board computer for linux linux devices and much related techologies become an accessible So it do huge challange and have numerious opportunities Regards bemnet

On Feb 3, 2019 8:09 PM, "Bemnet Adefrcis" [email protected] wrote:

do i need to develop library I do have an experiance of developing python libraries before how can i create this Recommed me for bigger challange

On Jan 28, 2019 3:26 PM, "Matt Trentini" [email protected] wrote:

@BEMNETADEFIS https://github.com/BEMNETADEFIS the current design actually works for Linux right now. The gotcha is that it requires an object (spi) to handle the SPI comms - to do this it just requires two commands; write and deinit. It should be a simple matter to create a class that forwards these methods on to an underlying implementation.

Unfortunately, as I understand, SPI comms is non-standard in Linux right now. But if you have a way of sending SPI data in Python this library could use it with minimal fuss.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micropython/micropython-esp32/issues/121#issuecomment-458112355, or mute the thread https://github.com/notifications/unsubscribe-auth/APM4lwEB9CM7o_pe7CfobuzBqY-m3hTXks5vHuyDgaJpZM4ONp94 .

BEMNETADEFIS avatar Feb 08 '19 13:02 BEMNETADEFIS

the problem that inapplicability for programming PIC32mx series mcus sam32 series and intel atom series Using arduio clone modules In my application study python more effective than other in device development so i am also liunx netive user so i worrid about the applications that i want to program using microoython with no library development experiance in python programming that why i ask If i do have an ability and experiance i will contibute it but i can have no experiance so i post the question becouse it not my specality and level of expertise Regards bemnet

On Feb 5, 2019 2:11 AM, wrote:

the more micropython is avaliable for liunx and hacker zones it become more innovative that why i rised such questions for me linux have python plagin including Apt-get update python.org python 5 # /4/3 that can help for more progressive progrsmming that why i know this question is certainly difficult but does it fits for the exsiting inapplicability of micropython in linux Single board computer for linux linux devices and much related techologies become an accessible So it do huge challange and have numerious opportunities Regards bemnet

On Feb 3, 2019 8:09 PM, "Bemnet Adefrcis" [email protected] wrote:

do i need to develop library I do have an experiance of developing python libraries before how can i create this Recommed me for bigger challange

On Jan 28, 2019 3:26 PM, "Matt Trentini" [email protected] wrote:

@BEMNETADEFIS https://github.com/BEMNETADEFIS the current design actually works for Linux right now. The gotcha is that it requires an object (spi) to handle the SPI comms - to do this it just requires two commands; write and deinit. It should be a simple matter to create a class that forwards these methods on to an underlying implementation.

Unfortunately, as I understand, SPI comms is non-standard in Linux right now. But if you have a way of sending SPI data in Python this library could use it with minimal fuss.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micropython/micropython-esp32/issues/121#issuecomment-458112355, or mute the thread https://github.com/notifications/unsubscribe-auth/APM4lwEB9CM7o_pe7CfobuzBqY-m3hTXks5vHuyDgaJpZM4ONp94 .

BEMNETADEFIS avatar Feb 08 '19 13:02 BEMNETADEFIS