Skip to content

Commit d35938d

Browse files
committed
Support for 5v level-shifter on Adafruit and Pimoroni boards (awawa-dev#8)
* Add GA script for Adafruit and Pimoroni boards Build firmware automatically. These boards have a built-in level shifter. * Update README.md * Update README.md * Add Adafruit ItsyBitsy rp2040
1 parent fae32e1 commit d35938d

File tree

3 files changed

+139
-14
lines changed

3 files changed

+139
-14
lines changed

.github/workflows/push-master.yml

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,99 @@ jobs:
3434
if: (startsWith(github.event.ref, 'refs/tags') != true)
3535
with:
3636
path: |
37-
firmwares/*.uf2
37+
firmware/*.uf2
3838
3939
- uses: actions/upload-artifact@v3
4040
name: Upload artifacts (release)
4141
if: startsWith(github.ref, 'refs/tags/')
4242
with:
4343
name: firmware-release
4444
path: |
45-
firmwares/*.uf2
45+
firmware/*.uf2
46+
47+
- name: Build packages for Adafruit Feather RP2040 Scorpio (release-only)
48+
if: startsWith(github.ref, 'refs/tags/')
49+
shell: bash
50+
run: |
51+
cd build
52+
rm *.*
53+
rm ../firmware/*
54+
echo "Neopixel is using GPIO16(OUTPUT_DATA_PIN) on output 0." > ../firmware/Firmwares_for_Adafruit_Feather_RP2040_Scorpio.txt
55+
echo "SPI is using spi0 interface pins: GPIO19(OUTPUT_SPI_DATA_PIN) and GPIO18(OUTPUT_SPI_CLOCK_PIN) on output 3 and 2 respectively." >> ../firmware/Firmwares_for_Adafruit_Feather_RP2040_Scorpio.txt
56+
cmake -DOVERRIDE_DATA_PIN=16 -DOVERRIDE_SPI_DATA_PIN=19 -DOVERRIDE_SPI_CLOCK_PIN=18 -DCMAKE_BUILD_TYPE=Release ..
57+
cmake --build .
58+
zip -j ../firmware/Adafruit_Feather_RP2040_Scorpio.zip ../firmware/*
59+
60+
- uses: actions/upload-artifact@v3
61+
name: Upload artifacts (release Adafruit_Feather)
62+
if: startsWith(github.ref, 'refs/tags/')
63+
with:
64+
name: firmware-release
65+
path: |
66+
firmware/*.zip
67+
68+
- name: Build packages for Adafruit ItsyBitsy RP2040 (release-only)
69+
if: startsWith(github.ref, 'refs/tags/')
70+
shell: bash
71+
run: |
72+
cd build
73+
rm *.*
74+
rm ../firmware/*
75+
echo "Neopixel is using GPIO14(OUTPUT_DATA_PIN) on output 5." > ../firmware/Firmwares_for_Adafruit_ItsyBitsy_2040.txt
76+
cmake -DOVERRIDE_DATA_PIN=14 -DCMAKE_BUILD_TYPE=Release ..
77+
cmake --build .
78+
rm ../firmware/*_Spi.uf2
79+
zip -j ../firmware/Adafruit_ItsyBitsy_2040.zip ../firmware/*
80+
81+
- uses: actions/upload-artifact@v3
82+
name: Upload artifacts (release Adafruit_ItsyBitsy)
83+
if: startsWith(github.ref, 'refs/tags/')
84+
with:
85+
name: firmware-release
86+
path: |
87+
firmware/*.zip
88+
89+
- name: Build packages for Pimoroni Plasma Stick 2040 W (release-only)
90+
if: startsWith(github.ref, 'refs/tags/')
91+
shell: bash
92+
run: |
93+
cd build
94+
rm *.*
95+
rm ../firmware/*
96+
echo "Neopixel is using GPIO15(OUTPUT_DATA_PIN) on output PIXELS." > ../firmware/Firmwares_for_Pimoroni_Plasma_Stick_2040_W.txt
97+
cmake -DOVERRIDE_DATA_PIN=15 -DCMAKE_BUILD_TYPE=Release ..
98+
cmake --build .
99+
rm ../firmware/*_Spi.uf2
100+
zip -j ../firmware/Pimoroni_Plasma_Stick_2040_W.zip ../firmware/*
101+
102+
- uses: actions/upload-artifact@v3
103+
name: Upload artifacts (release Pimoroni_Plasma_Stick_W)
104+
if: startsWith(github.ref, 'refs/tags/')
105+
with:
106+
name: firmware-release
107+
path: |
108+
firmware/*.zip
109+
110+
- name: Build packages for Pimoroni Plasma 2040 (release-only)
111+
if: startsWith(github.ref, 'refs/tags/')
112+
shell: bash
113+
run: |
114+
cd build
115+
rm *.*
116+
rm ../firmware/*
117+
echo "Neopixel is using GPIO15(OUTPUT_DATA_PIN) on output DA." > ../firmware/Firmwares_for_Pimoroni_Plasma_2040.txt
118+
echo "SPI is using spi1 interface pins: GPIO15(OUTPUT_SPI_DATA_PIN) and GPIO14(OUTPUT_SPI_CLOCK_PIN) on output DA and CL respectively." >> ../firmware/Firmwares_for_Pimoroni_Plasma_2040.txt
119+
cmake -DOVERRIDE_DATA_PIN=15 -DOVERRIDE_SPI_INTERFACE=spi1 -DOVERRIDE_SPI_DATA_PIN=15 -DOVERRIDE_SPI_CLOCK_PIN=14 -DCMAKE_BUILD_TYPE=Release ..
120+
cmake --build .
121+
zip -j ../firmware/Pimoroni_Plasma_2040.zip ../firmware/*
122+
123+
- uses: actions/upload-artifact@v3
124+
name: Upload artifacts (release Pimoroni_Plasma)
125+
if: startsWith(github.ref, 'refs/tags/')
126+
with:
127+
name: firmware-release
128+
path: |
129+
firmware/*.zip
46130
47131
################################
48132
###### Publish Releases ########
@@ -79,6 +163,7 @@ jobs:
79163
tag_name: ${{ env.TAG }}
80164
files: |
81165
*.uf2
166+
*.zip
82167
draft: true
83168
prerelease: ${{ env.preRelease }}
84169
env:

CMakeLists.txt

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(OUTPUT_DATA_PIN 2)
77
# only certain pairs of pins are allowed for selected SPI interface (refer to "readme.md")
88
set(OUTPUT_SPI_DATA_PIN 3)
99
set(OUTPUT_SPI_CLOCK_PIN 2)
10-
set(SPI_INTERFACE spi0)
10+
set(OUTPUT_SPI_INTERFACE spi0)
1111

1212
# Use multi-segment, starting index of second led strip or OFF to disable
1313
set(SECOND_SEGMENT_INDEX OFF)
@@ -49,7 +49,43 @@ pico_sdk_init()
4949
set(HyperSerialPicoCompanionLibs FreeRTOS-Kernel FreeRTOS-Kernel-Heap1 pico_stdlib pico_multicore hardware_pio hardware_dma hardware_spi)
5050
set(HyperSerialPicoCompanionIncludes ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sdk/config)
5151
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/generated)
52-
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/firmwares)
52+
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/firmware)
53+
54+
if(NOT CMAKE_HOST_WIN32)
55+
string(ASCII 27 EscChar)
56+
set(ColorReset "${EscChar}[m")
57+
set(GreenColor "${EscChar}[32m")
58+
set(YellowColor "${EscChar}[33m")
59+
endif()
60+
61+
if (OVERRIDE_DATA_PIN)
62+
set(OUTPUT_DATA_PIN ${OVERRIDE_DATA_PIN})
63+
message( STATUS "${YellowColor}Overriding Neopixel Data GPIO: ${OUTPUT_DATA_PIN}${ColorReset}")
64+
endif()
65+
66+
if (OVERRIDE_SPI_DATA_PIN)
67+
set(OUTPUT_SPI_DATA_PIN ${OVERRIDE_SPI_DATA_PIN})
68+
message( STATUS "${YellowColor}Overriding SPI Data GPIO: ${OUTPUT_SPI_DATA_PIN}${ColorReset}")
69+
endif()
70+
71+
if (OVERRIDE_SPI_CLOCK_PIN)
72+
set(OUTPUT_SPI_CLOCK_PIN ${OVERRIDE_SPI_CLOCK_PIN})
73+
message( STATUS "${YellowColor}Overriding SPI Clock GPIO: ${OUTPUT_SPI_CLOCK_PIN}${ColorReset}")
74+
endif()
75+
76+
if (OVERRIDE_SPI_INTERFACE)
77+
set(OUTPUT_SPI_INTERFACE ${OVERRIDE_SPI_INTERFACE})
78+
message( STATUS "${YellowColor}Overriding SPI Interface: ${OUTPUT_SPI_INTERFACE}${ColorReset}")
79+
endif()
80+
81+
message( STATUS "---------------------------")
82+
message( STATUS "Neopixel Data GPIO: ${GreenColor}${OUTPUT_DATA_PIN}${ColorReset}")
83+
message( STATUS "SPI Data GPIO: ${GreenColor}${OUTPUT_SPI_DATA_PIN}${ColorReset}")
84+
message( STATUS "SPI Clock GPIO: ${GreenColor}${OUTPUT_SPI_CLOCK_PIN}${ColorReset}")
85+
message( STATUS "SPI Interface: ${GreenColor}${OUTPUT_SPI_INTERFACE}${ColorReset}")
86+
message( STATUS "---------------------------")
87+
88+
add_compile_options(-ftrack-macro-expansion=0 -fno-diagnostics-show-caret -fdiagnostics-color=auto)
5389

5490
macro(HyperSerialPicoTarget HyperSerialPicoTargetName)
5591
add_executable(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/source/main.cpp)
@@ -60,13 +96,13 @@ macro(HyperSerialPicoTarget HyperSerialPicoTargetName)
6096
pico_enable_stdio_uart(${HyperSerialPicoTargetName} 0)
6197
pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/pio/neopixel.pio OUTPUT_DIR ${CMAKE_SOURCE_DIR}/generated)
6298
pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/pio/neopixel_ws2812b.pio OUTPUT_DIR ${CMAKE_SOURCE_DIR}/generated)
63-
add_custom_command(TARGET ${HyperSerialPicoTargetName} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${HyperSerialPicoTargetName}.uf2 ${CMAKE_SOURCE_DIR}/firmwares)
99+
add_custom_command(TARGET ${HyperSerialPicoTargetName} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${HyperSerialPicoTargetName}.uf2 ${CMAKE_SOURCE_DIR}/firmware)
64100
endmacro()
65101

66102
# targets for different LED strips
67103
IF(NOT SECOND_SEGMENT_INDEX)
68104
HyperSerialPicoTarget("${CMAKE_PROJECT_NAME}_Spi")
69-
target_compile_definitions("${CMAKE_PROJECT_NAME}_Spi" PRIVATE -DSPILED_APA102 -DSPI_INTERFACE=${SPI_INTERFACE} -DDATA_PIN=${OUTPUT_SPI_DATA_PIN} -DCLOCK_PIN=${OUTPUT_SPI_CLOCK_PIN})
105+
target_compile_definitions("${CMAKE_PROJECT_NAME}_Spi" PRIVATE -DSPILED_APA102 -DSPI_INTERFACE=${OUTPUT_SPI_INTERFACE} -DDATA_PIN=${OUTPUT_SPI_DATA_PIN} -DCLOCK_PIN=${OUTPUT_SPI_CLOCK_PIN})
70106
HyperSerialPicoTarget("${CMAKE_PROJECT_NAME}_sk6812Cold")
71107
target_compile_definitions("${CMAKE_PROJECT_NAME}_sk6812Cold" PRIVATE -DNEOPIXEL_RGBW -DCOLD_WHITE -DDATA_PIN=${OUTPUT_DATA_PIN})
72108
HyperSerialPicoTarget("${CMAKE_PROJECT_NAME}_sk6812Neutral")

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Adalight serial port LED driver implementation for Raspberry Pi Pico RP2040.
55
<p align="center"><img src="https://user-images.githubusercontent.com/69086569/236885968-baab51ba-a54b-4072-9a2a-cf867f2edb4b.png" width="250" height="250"/><img src="https://user-images.githubusercontent.com/69086569/236885360-dce9cfd7-92a8-43c6-911f-649325ee8a96.png" width="250" height="250"/></p>
66

77
# Recommended boards with a built-in level shifter
8-
To ensure the LEDs will work properly with the Pico board, a 3.3V to 5V level shifter is needed. You can use an external one e.g. SN74AHCT125N or just buy a model of rp2040 that already has it built-in: Adafruit Feather RP2040 Scorpio (output: GPIO16-23), Pimoroni Plasma 2040 (GPIO14-15) or Pimoroni Plasma Stick 2040 W (GPIO15).
8+
To ensure the LEDs will work properly with the Pico board, a 3.3V to 5V level shifter is needed. You can use an external one e.g. SN74AHCT125N or just buy a model of rp2040 that already has it built-in: Adafruit Feather RP2040 Scorpio (output: GPIO16-23), Adafruit ItsyBitsy RP2040 (output: GPIO14), Pimoroni Plasma 2040 (GPIO14-15) or Pimoroni Plasma Stick 2040 W (GPIO15).
99

10-
<p align="center"><img src="https://user-images.githubusercontent.com/69086569/242393809-4e491159-76c7-4c1e-be0a-1f10cd5291f2.png" width="200" height="200"/><img src="https://user-images.githubusercontent.com/69086569/241395006-ee27175e-677b-4971-97bc-ed294eaa8f3b.png" width="200" height="200"/><img src="https://user-images.githubusercontent.com/69086569/241394387-f8193ed8-56d5-46c6-b406-911720aed605.png" width="200" height="200"/></p>
10+
<p align="center"><img src="https://user-images.githubusercontent.com/69086569/242393809-4e491159-76c7-4c1e-be0a-1f10cd5291f2.png" width="200" height="200"/><img src="https://github.com/awawa-dev/HyperSerialPico/assets/69086569/e7a2a945-be12-47b1-8e48-ffc1b11c5b2f.png" width="200" height="200"/><img src="https://user-images.githubusercontent.com/69086569/241395006-ee27175e-677b-4971-97bc-ed294eaa8f3b.png" width="200" height="200"/><img src="https://user-images.githubusercontent.com/69086569/241394387-f8193ed8-56d5-46c6-b406-911720aed605.png" width="200" height="200"/></p>
1111

1212
# Supported LED strips
1313
| LED strip / Device | Single lane | Multi-segment |
@@ -22,15 +22,19 @@ To ensure the LEDs will work properly with the Pico board, a 3.3V to 5V level sh
2222
# How to flash it?
2323
It's very easy and you don't need any special flasher.
2424

25-
First download the firmware directly from the [Release folder](https://github.com/awawa-dev/HyperSerialPico/releases).
26-
27-
For HyperHDR choose `HyperSerialPico_<type>.uf2` firmware where *type* is one of supported LEDs: sk6812 cold/neutral white, variants of ws2812 and apa102. If you are using an application other than HyperHDR, select the `classic_adalight.zip` archive, unzip it and select `classic_adalight_HyperSerialPico_<type>.uf2` firmware (note: do not use firmwares from this archive for HyperHDR, they do not support my AWA protocol extension, missing many options and are simply only backwards compatible with other applications).
25+
1) First download the firmware directly from the [Release folder](https://github.com/awawa-dev/HyperSerialPico/releases). \
26+
\
27+
For HyperHDR and generic rp2040 choose `HyperSerialPico_<type>.uf2` firmware where *type* is one of supported LEDs: sk6812 cold/neutral white, variants of ws2812 and apa102. \
28+
\
29+
Due to the often neglected issue of the required 5 volt logic necessary for the correct operation of the supported LEDs, we want to promote rp2040 boards with a built-in 3.3V to 5V level shifter and we provide firmware compiled to their GPIO specifications. You can find these firmware & short pin-out manuals in the archives: `Adafruit_Feather_RP2040_Scorpio.zip`, `Adafruit_ItsyBitsy_2040.zip`, `Pimoroni_Plasma_2040.zip`, `Pimoroni_Plasma_Stick_2040_W.zip`. Also you can read about their specific GPIO output in the `Recommended boards with a built-in level shifter` section above. \
30+
\
31+
If you are using an application other than HyperHDR, select the `classic_adalight.zip` archive, unzip it and select `classic_adalight_HyperSerialPico_<type>.uf2` firmware (note: do not use firmware from this archive for HyperHDR, they do not support my AWA protocol extension, missing many options and are simply only backwards compatible with other applications).
2832

29-
Next put your Pico board into DFU mode:
33+
3) Next put your Pico board into DFU mode:
3034
* If your Pico board has only one button (`boot`) then press & hold it and connect the board to the USB port. Then you can release the button.
3135
* If your Pico board has two buttons, connect it to the USB port. Then press & hold `boot` and `reset` buttons, then release `reset` and next release `boot` button.
3236

33-
In the system file explorer you should find new drive (e.g. called `RPI-RP2` drive) exposed by the Pico board. Drag & drop (or copy) the selected firmware to this drive.
37+
3) In the system file explorer you should find new drive (e.g. called `RPI-RP2` drive) exposed by the Pico board. Drag & drop (or copy) the selected firmware to this drive.
3438
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.
3539

3640
# HyperHDR configuration
@@ -49,7 +53,7 @@ rp2040 allows hardware SPI on corresponding pairs of pins:
4953
spi0 ⇒ Data/Clock: GPIO3/GPIO2, GPIO19/GPIO18, GPIO7/GPIO6
5054
spi1 ⇒ Data/Clock: GPIO11/GPIO10, GPI15/GPIO14, GPIO27/GPI26
5155

52-
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.
56+
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 `firmware` folder.
5357

5458
Of course, you can also build your custom firmware completely online using Github Actions. The manual can be found on [wiki](https://github.com/awawa-dev/HyperSerialPico/wiki). Be sure to follow the steps in the correct order.
5559

0 commit comments

Comments
 (0)