Skip to content
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

Rp2040 pio ledstrip #4818

Merged
merged 44 commits into from May 21, 2023
Merged

Rp2040 pio ledstrip #4818

merged 44 commits into from May 21, 2023

Conversation

Papa-DMan
Copy link
Contributor

What does this implement/fix?

While waiting for fastled to push a release with their rp2040 support, finishing my uni courses, and some encouragement from members in this community I decided to take a look at writing a write a very basic led strip driver for the rp2040 from scratch

This driver utilizes the programmable IO state machines in the RP2040, I wrote out the assembly code for a couple of known chipset timings.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#2917

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040

Example entry for config.yaml:

# Example config.yaml
light:
  - platform: rp2040_pio_led_strip
    name: led_strip
    id: led_strip
    pin: GPIO13
    num_leds: 10
    pio: 0
    rgb_order: GRB
    chipset: WS2812B

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@probot-esphome
Copy link

Hey there @Papa-DMan,
Thanks for submitting this pull request! Can you add yourself as a codeowner for this integration? This way we can notify you if a bug report for this integration is reported.
In __init__.py of the integration, please add:

CODEOWNERS = ["@Papa-DMan"]

And run script/build_codeowners.py

(message by NeedsCodeownersLabel)

@Papa-DMan
Copy link
Contributor Author

Papa-DMan commented May 16, 2023

Okay I've figured it out. When the api call was made to run platformio pkg exec --package platformio/tool-rp2040tools -- pioasm pio_path pio_path.h it was picking up my local pioasm installation instead. Upon removing it I got the error:
Using tool-rp2040tools@1.0.2 package Error: [Errno 2] No such file or directory: 'pioasm'
like you did. Apparently rp2040tools doesn't come with the pioasm like I thought it did. Upon some further digging I discovered that there is in fact a separate platformio package by earlephilhower:
earlephilhower/tool-pioasm-rp2040-earlephilhower
that would provide the pioasm tool. I installed that package locally and changed the api call to use that package instead, and when compiling test6.yaml the assembly portion doesn't fail out.

@jesserockz
Copy link
Member

I have pushed some more changes to make the whole thing very dynamic, and allows multiple led strips etc. Untested, but compiles.

@Papa-DMan
Copy link
Contributor Author

Okay so I've just tested it with my scope and it is putting out the right times both when selecting a chipset and using custom timings in the yaml. However all the data is zero instead of the pixel data regardless of what the light is set to.

@jesserockz
Copy link
Member

I will set up a board today to actually test it

rgb order is already correct in buffer, so dont name these rgb etc
@jesserockz
Copy link
Member

Ok I have fixed it and it now sends the actual pixel out, but its only sending a single pixel, not the 8 i have configured

@jesserockz
Copy link
Member

Is this fully working for you with multiple pixels?

@Papa-DMan
Copy link
Contributor Author

Papa-DMan commented May 17, 2023

It is somewhat working with multiple Pixels. I am only getting about half of the configured Pixels getting lit up, and when they are the color isn't correct. On my 300 LED WS2812B test strip I set to full red the result is a pattern of 8 pixels at red 9 pixels at blue and 8 pixels at green for the first half of the strip, the second half is off.

@jesserockz
Copy link
Member

That is the exact result I was getting. Will try your latest commit

@jesserockz
Copy link
Member

Dang off-by-1 bugs...haha

Working perfectly now

@jesserockz jesserockz changed the title Rp2040 ledstrip Rp2040 pio ledstrip May 21, 2023
@jesserockz jesserockz merged commit a15ac06 into esphome:dev May 21, 2023
24 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants