Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

APA102 Driver support #121

Open
Open

Description

@Hokyjack

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?

Activity

  1. dpgeorge commented on Jul 5, 2017

    @dpgeorge
    Member

    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).

  2. Hokyjack commented on Jul 5, 2017

    @Hokyjack
    Author

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

  3. mattytrentini commented on Aug 12, 2017

    @mattytrentini
    Sponsor

    Also see #159

  4. mattytrentini commented on Sep 3, 2017

    @mattytrentini
    Sponsor

    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...

  5. mattytrentini commented on Sep 3, 2017

    @mattytrentini
    Sponsor

    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().

  6. mcauser commented on Sep 5, 2017

    @mcauser
    Contributor

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

  7. dpgeorge commented on Sep 5, 2017

    @dpgeorge
    Member

    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.

  8. mattytrentini commented on Jan 13, 2019

    @mattytrentini
    Sponsor

    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.

  9. BEMNETADEFIS commented on Jan 15, 2019

    @BEMNETADEFIS
  10. mattytrentini commented on Jan 28, 2019

    @mattytrentini
    Sponsor

    @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.

  11. RobertJBabb commented on Jan 29, 2019

    @RobertJBabb

    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.

  12. dpgeorge commented on Jan 31, 2019

    @dpgeorge
    Member

    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

  13. BEMNETADEFIS commented on Feb 3, 2019

    @BEMNETADEFIS
  14. mattytrentini commented on Feb 4, 2019

    @mattytrentini
    Sponsor

    @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.

  15. BEMNETADEFIS commented on Feb 8, 2019

    @BEMNETADEFIS
  16. BEMNETADEFIS commented on Feb 8, 2019

    @BEMNETADEFIS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions