Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WS2812 colors incorrect on Circuit Play Express #17

Closed
deadprogram opened this issue May 14, 2022 · 2 comments
Closed

WS2812 colors incorrect on Circuit Play Express #17

deadprogram opened this issue May 14, 2022 · 2 comments

Comments

@deadprogram
Copy link
Member

This program works as expected on the actual hardware (red/blue LEDs) but on the simulator is red/green:

Screenshot from 2022-05-14 12-04-29

package main

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

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

var leds [10]color.RGBA
var led = machine.LED
var neo = machine.NEOPIXELS

func main() {
	led.Configure(machine.PinConfig{Mode: machine.PinOutput})
	neo.Configure(machine.PinConfig{Mode: machine.PinOutput})

	ws := ws2812.New(neo)
	rg := false

	for {
		rg = !rg
		for i := range leds {
			rg = !rg
			if rg {
				leds[i] = color.RGBA{R: 0xff, G: 0x00, B: 0x00}
			} else {
				leds[i] = color.RGBA{R: 0x00, G: 0x00, B: 0xff}
			}
		}

		ws.WriteColors(leds[:])
		led.Set(rg)
		time.Sleep(100 * time.Millisecond)
	}
}
@aykevl aykevl closed this as completed in 378c7ca May 14, 2022
@aykevl
Copy link
Member

aykevl commented May 14, 2022

Whoa, I should have caught this sooner! I've now fixed this on play.tinygo.org. The next vscode-tinygo extension update will also get this fix.

@deadprogram
Copy link
Member Author

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants