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

     1  package main
     2  
     3  import (
     4  	"image/color"
     5  	"time"
     6  
     7  	"tinygo.org/x/drivers/examples/ili9341/initdisplay"
     8  	"tinygo.org/x/drivers/ili9341"
     9  )
    10  
    11  var (
    12  	black = color.RGBA{0, 0, 0, 255}
    13  	white = color.RGBA{255, 255, 255, 255}
    14  	red   = color.RGBA{255, 0, 0, 255}
    15  	blue  = color.RGBA{0, 0, 255, 255}
    16  	green = color.RGBA{0, 255, 0, 255}
    17  )
    18  
    19  var (
    20  	display *ili9341.Device
    21  )
    22  
    23  func main() {
    24  	display = initdisplay.InitDisplay()
    25  
    26  	width, height := display.Size()
    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  	for {
    34  		time.Sleep(time.Hour)
    35  	}
    36  
    37  }