Adafruit Feather nRF52840 Express - onboard neopixel not working
I've got a Feather nRF23840 Express with the built in neopixel that I can not make light with ws2812.
I don't believe I have anything wrong in my code.
package main
import (
"image/color"
"machine"
"time"
"tinygo.org/x/drivers/ws2812"
)
var neo machine.Pin
func main() {
neo = machine.WS2812
neo.Configure(machine.PinConfig{Mode: machine.PinOutput})
ws := ws2812.NewWS2812(neo)
time.Sleep(500 * time.Millisecond)
for {
ws.WriteColors([]color.RGBA{{255, 0, 0, 255}})
time.Sleep(2500 * time.Millisecond)
ws.WriteColors([]color.RGBA{{0, 255, 0, 255}})
time.Sleep(2500 * time.Millisecond)
ws.WriteColors([]color.RGBA{{0, 0, 255, 255}})
time.Sleep(2500 * time.Millisecond)
}
}
I can not find a reference now, but I thought I saw that this board used a WS2812B, and digging around I found that the timings on a B are different than rev A; datasheet adafruit reference code and thought perhaps that was the issue.
I grabbed the driver code and fiddled with the write intervals in an attempt to get it working but did not succeed. I think I understand what is happening in that codegen but I lack a lot of peripheral knowledge here.
It does work when using that Adafruit library and flashing from Arduino IDE.
Thanks!
I tried flashing your code onto the Feather nRF52840. It seems to be working correctly on my board.
Well that's concerning, thank you for checking that @sago35.
I have another version where I also blink the machine.LED pin when I'm changing the neopixel and that works so I know it's flashing on and running OK, tinygo monitor works as well if I drop in println statements.
I will try asking over on the Adafruit support forums for ideas. I would suspect bum hardware but it operates fine from C++ so I'm lost.
Did you manage to figure out the issue? One thing you could try is to disable interrupts while writing. Something like:
import "runtime/interrupt"
// inside the loop
mask := interrupt.Disable()
ws.WriteColors([]color.RGBA{{0, 0, 255, 255}})
interrupt.Restore(mask)
(Closing for now, this doesn't appear to be a bug but feel free to comment if it's still a problem).