tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/st7735/main.go (about) 1 package main 2 3 import ( 4 "machine" 5 6 "image/color" 7 8 "tinygo.org/x/drivers/st7735" 9 ) 10 11 func main() { 12 machine.SPI0.Configure(machine.SPIConfig{ 13 Frequency: 8000000, 14 }) 15 display := st7735.New(machine.SPI0, machine.P6, machine.P7, machine.P8, machine.P9) 16 display.Configure(st7735.Config{}) 17 18 width, height := display.Size() 19 20 white := color.RGBA{255, 255, 255, 255} 21 red := color.RGBA{255, 0, 0, 255} 22 blue := color.RGBA{0, 0, 255, 255} 23 green := color.RGBA{0, 255, 0, 255} 24 black := color.RGBA{0, 0, 0, 255} 25 26 display.FillScreen(black) 27 28 display.FillRectangle(0, 0, width/2, height/2, white) 29 display.FillRectangle(width/2, 0, width/2, height/2, red) 30 display.FillRectangle(0, height/2, width/2, height/2, green) 31 display.FillRectangle(width/2, height/2, width/2, height/2, blue) 32 display.FillRectangle(width/4, height/4, width/2, height/2, black) 33 }