From 5645eb3f9178bdde1bb98aea7e43bafda1febe83 Mon Sep 17 00:00:00 2001 From: sago35 Date: Sun, 30 May 2021 11:49:53 +0900 Subject: [PATCH] ws2812: add support for qtpy and atsame5x --- examples/ws2812/arduino.go | 3 ++- examples/ws2812/digispark.go | 3 ++- examples/ws2812/main.go | 1 - examples/ws2812/others.go | 5 +++-- examples/ws2812/qtpy.go | 16 ++++++++++++++++ ws2812/ws2812_m4_120m.go | 2 +- 6 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 examples/ws2812/qtpy.go diff --git a/examples/ws2812/arduino.go b/examples/ws2812/arduino.go index bcb26da..d59580f 100644 --- a/examples/ws2812/arduino.go +++ b/examples/ws2812/arduino.go @@ -4,6 +4,7 @@ package main import "machine" -// Replace neo in the code below to match the pin +// Replace neo and led in the code below to match the pin // that you are using if different. var neo = machine.D2 +var led = machine.LED diff --git a/examples/ws2812/digispark.go b/examples/ws2812/digispark.go index a4a58a5..d81d163 100644 --- a/examples/ws2812/digispark.go +++ b/examples/ws2812/digispark.go @@ -5,6 +5,7 @@ package main import "machine" // This is the pin assignment for the Digispark only. -// Replace neo in the code below to match the pin +// Replace neo and led in the code below to match the pin // that you are using if different. var neo machine.Pin = 0 +var led = machine.LED diff --git a/examples/ws2812/main.go b/examples/ws2812/main.go index 32f52fc..99e9956 100644 --- a/examples/ws2812/main.go +++ b/examples/ws2812/main.go @@ -15,7 +15,6 @@ import ( var leds [10]color.RGBA func main() { - led := machine.LED led.Configure(machine.PinConfig{Mode: machine.PinOutput}) neo.Configure(machine.PinConfig{Mode: machine.PinOutput}) diff --git a/examples/ws2812/others.go b/examples/ws2812/others.go index 1db6b4c..d26c1d6 100644 --- a/examples/ws2812/others.go +++ b/examples/ws2812/others.go @@ -1,9 +1,10 @@ -// +build !digispark,!arduino +// +build !digispark,!arduino,!qtpy package main import "machine" -// Replace neo in the code below to match the pin +// Replace neo and led in the code below to match the pin // that you are using if different. var neo machine.Pin = machine.NEOPIXELS +var led = machine.LED diff --git a/examples/ws2812/qtpy.go b/examples/ws2812/qtpy.go new file mode 100644 index 0000000..abbbe1d --- /dev/null +++ b/examples/ws2812/qtpy.go @@ -0,0 +1,16 @@ +// +build qtpy + +package main + +import "machine" + +// Replace neo and led in the code below to match the pin +// that you are using if different. +var neo machine.Pin = machine.NEOPIXELS +var led = machine.NoPin + +func init() { + pwr := machine.NEOPIXELS_POWER + pwr.Configure(machine.PinConfig{Mode: machine.PinOutput}) + pwr.High() +} diff --git a/ws2812/ws2812_m4_120m.go b/ws2812/ws2812_m4_120m.go index 17256c7..6001289 100644 --- a/ws2812/ws2812_m4_120m.go +++ b/ws2812/ws2812_m4_120m.go @@ -1,4 +1,4 @@ -// +build atsamd51 +// +build atsamd51 atsame5x package ws2812