tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/uc8151/main.go (about) 1 package main 2 3 import ( 4 "image/color" 5 "machine" 6 7 "tinygo.org/x/drivers" 8 "tinygo.org/x/drivers/uc8151" 9 ) 10 11 var display uc8151.Device 12 var led machine.Pin 13 14 func main() { 15 led = machine.LED 16 led.Configure(machine.PinConfig{Mode: machine.PinOutput}) 17 machine.SPI0.Configure(machine.SPIConfig{ 18 Frequency: 12000000, 19 SCK: machine.EPD_SCK_PIN, 20 SDO: machine.EPD_SDO_PIN, 21 }) 22 23 display = uc8151.New(machine.SPI0, machine.EPD_CS_PIN, machine.EPD_DC_PIN, machine.EPD_RESET_PIN, machine.EPD_BUSY_PIN) 24 display.Configure(uc8151.Config{ 25 Rotation: drivers.Rotation270, 26 Speed: uc8151.MEDIUM, 27 Blocking: true, 28 }) 29 black := color.RGBA{1, 1, 1, 255} 30 31 display.ClearBuffer() 32 display.Display() 33 for i := int16(0); i < 37; i++ { 34 for j := int16(0); j < 16; j++ { 35 if (i+j)%2 == 0 { 36 showRect(i*8, j*8, 8, 8, black) 37 } 38 } 39 } 40 41 display.Display() 42 } 43 44 func showRect(x int16, y int16, w int16, h int16, c color.RGBA) { 45 for i := x; i < x+w; i++ { 46 for j := y; j < y+h; j++ { 47 display.SetPixel(i, j, c) 48 } 49 } 50 }