From 7b56e61d52322b1a7d87309d76057e449d27ea08 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 14 Dec 2019 16:59:18 +0100 Subject: [PATCH] ws2812: add support for simulation Call a special __tinygo_ws2812_write_byte function to send a single byte. --- ws2812/ws2812_generic.go | 16 ++++++++++++++++ ws2812/ws2812_m0_48m.go | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ws2812/ws2812_generic.go diff --git a/ws2812/ws2812_generic.go b/ws2812/ws2812_generic.go new file mode 100644 index 0000000..2503057 --- /dev/null +++ b/ws2812/ws2812_generic.go @@ -0,0 +1,16 @@ +// +build !baremetal + +package ws2812 + +// This file implements the WS2812 protocol for simulation. + +import "machine" + +// Send a single byte using the WS2812 protocol. +func (d Device) WriteByte(c byte) error { + writeByte(d.Pin, c) + return nil +} + +//go:export __tinygo_ws2812_write_byte +func writeByte(pin machine.Pin, c byte) diff --git a/ws2812/ws2812_m0_48m.go b/ws2812/ws2812_m0_48m.go index 1f558a0..71d0c7d 100644 --- a/ws2812/ws2812_m0_48m.go +++ b/ws2812/ws2812_m0_48m.go @@ -1,4 +1,4 @@ -// +build circuitplay_express itsybitsy_m0 arduino_nano33 feather_m0 trinket_m0 +// +build atsamd21 package ws2812