Skip to content

Commit

Permalink
Fix SPI pinout (#4)
Browse files Browse the repository at this point in the history
* Fix default SPI pinout

* Update doc about SPI allowed pins

* Fix spi1 interface

* Convert to tabs
  • Loading branch information
awawa-dev committed Jun 11, 2023
1 parent 50196dd commit 0642d39
Show file tree
Hide file tree
Showing 5 changed files with 450 additions and 445 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# User configuration section starts here

# Default output data pin for the LED strip
# Default output data pin for the non-SPI LED strips (only for sk6812/ws2812b)
set(OUTPUT_DATA_PIN 2)

# Default output clock pin for the LED strip (SPI leds only, not for sk6812/ws2812b)
set(OUTPUT_CLOCK_PIN 3)
# Default output data/clocks pin for the SPI LED strips (only for apa102, not for sk6812/ws2812b)
# only certain pairs of pins are allowed for selected SPI interface (refer to "readme.md")
set(OUTPUT_SPI_DATA_PIN 3)
set(OUTPUT_SPI_CLOCK_PIN 2)
set(SPI_INTERFACE spi0)

# Use multi-segment, starting index of second led strip or OFF to disable
set(SECOND_SEGMENT_INDEX OFF)
Expand Down Expand Up @@ -62,7 +65,7 @@ endmacro()
# targets for different LED strips
IF(NOT SECOND_SEGMENT_INDEX)
HyperSerialPicoTarget("HyperSerialPico_Spi")
target_compile_definitions(HyperSerialPico_Spi PRIVATE -DSPILED_APA102 -DDATA_PIN=${OUTPUT_DATA_PIN} -DCLOCK_PIN=${OUTPUT_CLOCK_PIN})
target_compile_definitions(HyperSerialPico_Spi PRIVATE -DSPILED_APA102 -DSPI_INTERFACE=${SPI_INTERFACE} -DDATA_PIN=${OUTPUT_SPI_DATA_PIN} -DCLOCK_PIN=${OUTPUT_SPI_CLOCK_PIN})
HyperSerialPicoTarget("HyperSerialPico_sk6812Cold")
target_compile_definitions(HyperSerialPico_sk6812Cold PRIVATE -DNEOPIXEL_RGBW -DCOLD_WHITE -DDATA_PIN=${OUTPUT_DATA_PIN})
HyperSerialPicoTarget("HyperSerialPico_sk6812Neutral")
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ In the system file explorer you should find new drive (e.g. called `RPI-RP2` dri
The Pico will reset automaticly after the upload and after few seconds it will be ready to use by HyperHDR as a serial port device using Adalight driver.

# HyperHDR configuration
Make sure you have enabled `AWA protocol` and `Esp8266/ESP32/Rp2040 handshake` options.
You can leave the speed at `2000000` because the CDC driver should use the highest possible speed automatically (at least it happens on Windows).
You need HyperHDR v20 or newer. Make sure you have enabled `AWA protocol` and `Esp8266/ESP32/Rp2040 handshake` options. You can leave the speed at `2000000` because the CDC driver should use the highest possible speed automatically (at least it happens on Windows).

![obraz](https://user-images.githubusercontent.com/69086569/236870662-12f67d14-c2ca-4ba1-b6a3-e34c27949d19.png)

# Default pinout

**LED output (SK6812/WS281x):** GPIO2 for Data
**LED output (SPI LEDs):** GPIO2 for Data, GPIO3 for Clock
**LED output (SPI LEDs):** GPIO3 for Data, GPIO2 for Clock

rp2040 allows hardware SPI on corresponding pairs of pins:
spi0 ⇒ Data/Clock: GPIO3/GPIO2, GPIO19/GPIO18, GPIO7/GPIO6
spi1 ⇒ Data/Clock: GPIO11/GPIO10, GPI15/GPIO14, GPIO27/GPI26

Pinout can be changed, but you need to make changes to CMakeList.txt (`OUTPUT_DATA_PIN`/`OUTPUT_CLOCK_PIN`) and recompile the project. Also multi-segment mode can be enabled in this file: `SECOND_SEGMENT_INDEX` option at the beginning and optionally `SECOND_SEGMENT_REVERSED`.
Once compiled, the results can be found in the `firmwares` folder.
Pinout can be changed, but you need to make changes to `CMakeList.txt` (e.g. `OUTPUT_DATA_PIN` / `OUTPUT_SPI_DATA_PIN` / `OUTPUT_SPI_CLOCK_PIN`) and recompile the project. Also multi-segment mode can be enabled in this file: `SECOND_SEGMENT_INDEX` option at the beginning and optionally `SECOND_SEGMENT_REVERSED`. Once compiled, the results can be found in the `firmwares` folder.

# Some benchmark results

Expand Down
2 changes: 1 addition & 1 deletion include/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Base
#if defined(NEOPIXEL_RGBW) || defined(NEOPIXEL_RGB)
ledStrip1 = new LED_DRIVER(ledsNumber, DATA_PIN);
#else
ledStrip1 = new LED_DRIVER(ledsNumber, DATA_PIN, CLOCK_PIN);
ledStrip1 = new LED_DRIVER(ledsNumber, SPI_INTERFACE, DATA_PIN, CLOCK_PIN);
#endif
}
}
Expand Down
Loading

0 comments on commit 0642d39

Please sign in to comment.