tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/waveshare-epd/epd2in13x/main.go (about) 1 package main 2 3 import ( 4 "machine" 5 6 "image/color" 7 8 "tinygo.org/x/drivers/waveshare-epd/epd2in13x" 9 ) 10 11 var display epd2in13x.Device 12 13 func main() { 14 machine.SPI0.Configure(machine.SPIConfig{ 15 Frequency: 8000000, 16 Mode: 0, 17 }) 18 19 display = epd2in13x.New(machine.SPI0, machine.P6, machine.P7, machine.P8, machine.P9) 20 display.Configure(epd2in13x.Config{}) 21 22 white := color.RGBA{0, 0, 0, 255} 23 colored := color.RGBA{255, 0, 0, 255} 24 black := color.RGBA{1, 1, 1, 255} 25 26 display.ClearBuffer() 27 display.ClearDisplay() 28 29 // Show a checkered board 30 for i := int16(0); i < 27; i++ { 31 showRect((i%3)*35, i*8, 35, 8, colored) 32 showRect(((i+1)%3)*35, i*8, 35, 8, black) 33 showRect(((i+2)%3)*35, i*8, 35, 8, white) 34 } 35 display.Display() 36 display.WaitUntilIdle() 37 println("You could remove power now") 38 } 39 40 func showRect(x int16, y int16, w int16, h int16, c color.RGBA) { 41 for i := x; i < x+w; i++ { 42 for j := y; j < y+h; j++ { 43 display.SetPixel(i, j, c) 44 } 45 } 46 }