Skip to content

Commit

Permalink
RP2040: Get WS2812 LEDs working
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Sep 22, 2024
1 parent bf344fd commit 0a01bb1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
- 3.0+ version of the ESP32 Arduino Core now required.
- USB-CDC (aka native USB) appears to be broken in the 3.0 core. Will eventually hang if sending a lot of data both directions at the same time. Use one of the standard UART interfaces until this is fixed.

- Raspberry Pi Pico (RP2040)
- WS2812 LED strips work now.

### New Peripherals

- ADS1100 Analog-to-Digital Converter:
Expand Down
1 change: 1 addition & 0 deletions DEPS_CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ arduino-cli config add board_manager.additional_urls https://github.com/earlephi
arduino-cli core update-index
arduino-cli core install rp2040:rp2040
arduino-cli lib install [email protected]
arduino-cli lib install "Adafruit NeoPixel"
````
4 changes: 2 additions & 2 deletions HARDWARE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

| Chip | Status | Board Tested | Notes |
| :-------- | :------: | :--------------- |------ |
| RP2040 | :green_heart: | Raspberry Pi Pico (W) | WiFi only on W version. No WS1812 LED support.
| RP2040 | :green_heart: | Raspberry Pi Pico (W) |

# Single Board Computers

Expand Down Expand Up @@ -102,7 +102,7 @@ See the [Support](https://github.com/denko-rb/denko-piboard?tab=readme-ov-file#s
| Maxim OneWire | :green_heart: | S | `OneWire::Bus` | No overdrive
| Infrared Emitter | :green_heart: | S | `PulseIO::IRTransmitter` | Except SAM3X, RA4M1
| Infrared Receiver | :heart: | S | `PulseIO::IRReceiver` | Doable with existing library
| WS2812 | :green_heart: | S | See LED table | Except RP2040, RA4M1
| WS2812 | :green_heart: | S | See LED table | Except RA4M1
| ESP32-PCNT | :heart: | H | - | Only ESP32. Pulse counter (for encoders)
| ESP32-MCPWM | :heart: | H | - | Only ESP32. Motor control PWM

Expand Down
2 changes: 1 addition & 1 deletion lib/denko_cli/targets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ class DenkoCLI::Generator
esp32: STANDARD_PACKAGES,

# RP2040 can't use WS2812 yet.
rp2040: STANDARD_PACKAGES - [:led_array],
rp2040: STANDARD_PACKAGES,
}
end
13 changes: 12 additions & 1 deletion src/lib/DenkoLEDArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#ifdef ESP32
#include <esp.c>
#endif

#ifdef ARDUINO_ARCH_RP2040
Adafruit_NeoPixel ledArray;
#endif
#endif

//
Expand All @@ -32,7 +36,14 @@ void Denko::showLEDArray() {
#ifdef ESP32
espShow(pin, &auxMsg[WS2812_DATA_OFFSET], val, true);

// memcpy method for everything else.
// Pre-init instance (one PIO) on Pi Pico.
#elif defined(ARDUINO_ARCH_RP2040)
ledArray.setPin(pin);
ledArray.updateLength(val);
memcpy(ledArray.getPixels(), &auxMsg[WS2812_DATA_OFFSET], val);
ledArray.show();

// Reinit and memcpy for everything else.
#else
// Setup a new LED array object.
Adafruit_NeoPixel ledArray(val, pin, NEO_GRB + NEO_KHZ800);
Expand Down

0 comments on commit 0a01bb1

Please sign in to comment.