tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/pcd8544/setbuffer/main.go (about) 1 package main 2 3 import ( 4 "machine" 5 "time" 6 7 "tinygo.org/x/drivers/examples/pcd8544/setbuffer/data" 8 "tinygo.org/x/drivers/pcd8544" 9 ) 10 11 func main() { 12 dcPin := machine.P3 13 dcPin.Configure(machine.PinConfig{Mode: machine.PinOutput}) 14 rstPin := machine.P4 15 rstPin.Configure(machine.PinConfig{Mode: machine.PinOutput}) 16 scePin := machine.P5 17 scePin.Configure(machine.PinConfig{Mode: machine.PinOutput}) 18 19 machine.SPI0.Configure(machine.SPIConfig{}) 20 21 lcd := pcd8544.New(machine.SPI0, dcPin, rstPin, scePin) 22 lcd.Configure(pcd8544.Config{}) 23 24 i := 0 25 for { 26 err := lcd.SetBuffer(data.Images[i]) 27 if err != nil { 28 println(err.Error()) 29 } 30 lcd.Display() 31 i = (i + 1) % 2 32 33 time.Sleep(800 * time.Millisecond) 34 } 35 }