tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/ssd1351/main.go (about)

     1  package main
     2  
     3  import (
     4  	"machine"
     5  
     6  	"image/color"
     7  
     8  	"tinygo.org/x/drivers/ssd1351"
     9  )
    10  
    11  func main() {
    12  	machine.SPI1.Configure(machine.SPIConfig{
    13  		Frequency: 2000000,
    14  	})
    15  	display := ssd1351.New(machine.SPI1, machine.D18, machine.D17, machine.D16, machine.D4, machine.D19)
    16  
    17  	display.Configure(ssd1351.Config{
    18  		Width:        96,
    19  		Height:       96,
    20  		ColumnOffset: 16,
    21  	})
    22  
    23  	width, height := display.Size()
    24  
    25  	white := color.RGBA{255, 255, 255, 255}
    26  	red := color.RGBA{255, 0, 0, 255}
    27  	blue := color.RGBA{0, 0, 255, 255}
    28  	green := color.RGBA{0, 255, 0, 255}
    29  
    30  	display.FillRectangle(0, 0, width, height/4, white)
    31  	display.FillRectangle(0, height/4, width, height/4, red)
    32  	display.FillRectangle(0, height/2, width, height/4, green)
    33  	display.FillRectangle(0, 3*height/4, width, height/4, blue)
    34  
    35  	display.Display()
    36  }