Checkpoint

This commit is contained in:
maze authored and maze committed 2026-10-29 17:28:51 +01:00
1 parent 7b6db17870
commit 0295eb1ad2
125 files changed
+59376

No files matched your search

+74
View File
@@ -0,0 +1,74 @@
package main
import (
"flag"
"image/color"
"sync"
"git.maze.io/go/bragi/hardware/display/gc9a01"
"periph.io/x/conn/v3/gpio/gpioreg"
"periph.io/x/conn/v3/spi/spireg"
"periph.io/x/host/v3"
)
func main() {
var (
config gc9a01.Config
reset string
dc string
cs string
bl string
)
flag.StringVar(&config.Port, "spi-bus", "", "SPI bus (empty for default)")
flag.StringVar(&reset, "gpio-reset", "GPIO6", "reset pin")
flag.StringVar(&dc, "gpio-dc", "GPIO7", "data/command pin")
flag.StringVar(&cs, "gpio-cs", "GPIO8", "chip select pin")
flag.StringVar(&bl, "gpio-bl", "GPIO9", "backlight pin")
flag.IntVar(&config.Width, "width", 240, "display width")
flag.IntVar(&config.Height, "height", 240, "display height")
flag.IntVar(&config.VSyncLines, "vsync", 2, "number of VSync lines")
flag.IntVar(&config.RowOffset, "row-offset", 0, "row offset")
flag.IntVar(&config.ColumnOffset, "column-offset", 0, "column offset")
flag.Parse()
config.Reset = gpioreg.ByName(reset)
config.DC = gpioreg.ByName(dc)
config.CS = gpioreg.ByName(cs)
config.BL = gpioreg.ByName(bl)
_, err := host.Init()
if err != nil {
panic(err)
}
p, err := spireg.Open(config.Port)
if err != nil {
panic(err)
}
defer p.Close()
d, err := gc9a01.New(p, config)
if err != nil {
panic(err)
}
bounds := d.Bounds()
width, height := bounds.Dx(), bounds.Dy()
white := color.RGBA{255, 255, 255, 255}
red := color.RGBA{255, 0, 0, 255}
blue := color.RGBA{0, 0, 255, 255}
green := color.RGBA{0, 255, 0, 255}
black := color.RGBA{0, 0, 0, 255}
d.FillRectangle(0, 0, width, height, black)
d.FillRectangle(0, 0, width/2, height/2, white)
d.FillRectangle(width/2, 0, width/2, height/2, red)
d.FillRectangle(0, height/2, width/2, height/2, green)
d.FillRectangle(width/2, height/2, width/2, height/2, blue)
d.FillRectangle(width/4, height/4, width/2, height/2, black)
var wait sync.WaitGroup
wait.Add(1)
wait.Wait()
}