all repos — visor @ 31551d6190c2966a1f25e6a12514929297e00ea2

Unnamed repository; edit this file 'description' to name the repository.

add blinking
confusedbread confuseddbread@gmail.com
Fri, 20 Mar 2026 20:30:47 +0100
commit

31551d6190c2966a1f25e6a12514929297e00ea2

parent

4332225c9c1a67916a542fa634ec193e5143ab25

1 files changed, 28 insertions(+), 9 deletions(-)

jump to
M main.gomain.go

@@ -4,6 +4,8 @@ import (

"image/color" "machine" "math" + "math/rand" + "time" "tinygo.org/x/drivers/ws2812" )

@@ -48,22 +50,24 @@ }

return out } -func eyes(canvas []color.RGBA, config visorConfig) []color.RGBA { +func eyes(canvas []color.RGBA, config visorConfig, closed bool) []color.RGBA { for i := range canvas { x := i % 32 y := int(math.Floor(float64(i) / 32)) if y > config.spacingTop && y < config.spacingTop+config.eyeHeight { - if x > config.spacingOuter && x < config.spacingOuter+config.eyeWidth { - canvas[i] = config.eyeColor - } - if x > config.screenWidth-(config.spacingOuter+config.eyeWidth) && x < config.screenWidth-config.spacingOuter { - canvas[i] = config.eyeColor + if !closed || (y > config.spacingTop+(config.eyeHeight/2) && y <= config.spacingTop+(config.eyeHeight/2)+2) { + if x > config.spacingOuter && x < config.spacingOuter+config.eyeWidth { + canvas[i] = config.eyeColor + } + if x > config.screenWidth-(config.spacingOuter+config.eyeWidth) && x < config.screenWidth-config.spacingOuter { + canvas[i] = config.eyeColor + } } } } - if config.borderWidth > 0 { + if config.borderWidth > 0 && !closed { infilConfig := config infilConfig.eyeHeight -= config.borderWidth * 2 infilConfig.eyeWidth -= config.borderWidth * 2

@@ -71,7 +75,7 @@ infilConfig.spacingOuter += config.borderWidth

infilConfig.spacingTop += config.borderWidth infilConfig.borderWidth = 0 infilConfig.eyeColor = color.RGBA{R: 0, G: 0, B: 0} - return eyes(canvas, infilConfig) + return eyes(canvas, infilConfig, false) } return unfuckMatrix(canvas) }

@@ -94,5 +98,20 @@ eyeHeight: 10,

borderWidth: 1, eyeColor: color.RGBA{R: 2, G: 0, B: 2}, } - device.WriteColors(eyes(leds, config)) + + open := eyes(leds, config, false) + closedConfig := config + closedConfig.eyeColor = color.RGBA{R: 0, G: 0, B: 0} + closed := eyes(eyes(leds, closedConfig, false), config, true) + + for { + if rand.Float32() > 0.1 { + device.WriteColors(open) + } else { + device.WriteColors(closed) + } + + time.Sleep(time.Millisecond * 200) + } + }