package main

import (
	"image/color"
	"machine"
	"time"

	"tinygo.org/x/drivers/ws2812"
)

const (
	NumberOfLEDs = 2
)

var (
	red   = color.RGBA{255, 0, 0, 255}
	green = color.RGBA{0, 255, 0, 255}
)

func main() {
	// WS2812 LEDs are on pin P1_11
	neo := machine.P1_11
	neo.Configure(machine.PinConfig{Mode: machine.PinOutput})

	leds := ws2812.New(neo)
	ledColors := make([]color.RGBA, NumberOfLEDs)

	rg := false
	for {
		for i := 0; i < NumberOfLEDs; i++ {
			if rg {
				ledColors[i] = red
			} else {
				ledColors[i] = green
			}
			rg = !rg
		}
		leds.WriteColors(ledColors)
		rg = !rg
		time.Sleep(time.Millisecond * 300)
	}
}
