tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/ft6336/touchpaint/m5stack_core2.go (about) 1 //go:build m5stack_core2 2 3 package main 4 5 import ( 6 "image/color" 7 "machine" 8 9 axp192 "tinygo.org/x/drivers/axp192/m5stack-core2-axp192" 10 "tinygo.org/x/drivers/ft6336" 11 "tinygo.org/x/drivers/i2csoft" 12 "tinygo.org/x/drivers/ili9341" 13 "tinygo.org/x/drivers/touch" 14 ) 15 16 // InitDisplay initializes the display of each board. 17 func initDevices() (touchPaintDisplay, touch.Pointer, error) { 18 machine.SPI2.Configure(machine.SPIConfig{ 19 SCK: machine.LCD_SCK_PIN, 20 SDO: machine.LCD_SDO_PIN, 21 SDI: machine.LCD_SDI_PIN, 22 Frequency: 40e6, 23 }) 24 25 i2c := i2csoft.New(machine.SCL0_PIN, machine.SDA0_PIN) 26 i2c.Configure(i2csoft.I2CConfig{Frequency: 100e3}) 27 28 axp := axp192.New(i2c) 29 led := axp.LED 30 led.Low() 31 32 display := ili9341.NewSPI( 33 machine.SPI2, 34 machine.LCD_DC_PIN, 35 machine.LCD_SS_PIN, 36 machine.NoPin, 37 ) 38 39 // configure display 40 display.Configure(ili9341.Config{ 41 Width: 320, 42 Height: 240, 43 DisplayInversion: true, 44 }) 45 display.FillScreen(color.RGBA{255, 255, 255, 255}) 46 47 display.SetRotation(ili9341.Rotation0Mirror) 48 49 resistiveTouch := ft6336.New(i2c, machine.Pin(39)) 50 resistiveTouch.Configure(ft6336.Config{}) 51 resistiveTouch.SetPeriodActive(0x00) 52 53 return display, resistiveTouch, nil 54 }