tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
622 stars 196 forks source link

Simplify examples/ws2812 #675

Closed sago35 closed 6 months ago

sago35 commented 6 months ago

The WS2812 example had variations due to its dependency on led and the different PIN names used. With this PR, boards with WS2812 now have machine.WS2812 available. This PR makes the following changes:

sago35 commented 6 months ago

My main motivation was to create an example of running WS2812 on waveshare-rp2040-zero. However, adding the new variation required many changes, so I created this PR. Going forward, this example will work without changes as long as machine.WS2812 is defined.

I have tested the following for verification and confirmed that at least the build is successful.

tinygo build -o /tmp/out.uf2 -target arduino               ./examples/ws2812/
tinygo build -o /tmp/out.uf2 -target digispark             ./examples/ws2812/
tinygo build -o /tmp/out.uf2 -target qtpy                  ./examples/ws2812/
tinygo build -o /tmp/out.bin -target m5stamp-c3            ./examples/ws2812/
tinygo build -o /tmp/out.uf2 -target thingplus-rp2040      ./examples/ws2812/
tinygo build -o /tmp/out.uf2 -target waveshare-rp2040-zero ./examples/ws2812/
deadprogram commented 6 months ago

Thank you for the improvements @sago35 and to @aykevl for review. Now merging.