gobot.io/x/gobot@v1.16.0/examples/chip_grove_lcd.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 package main 6 7 import ( 8 "time" 9 10 "gobot.io/x/gobot" 11 "gobot.io/x/gobot/drivers/i2c" 12 "gobot.io/x/gobot/platforms/chip" 13 ) 14 15 func main() { 16 board := chip.NewAdaptor() 17 screen := i2c.NewGroveLcdDriver(board) 18 19 work := func() { 20 screen.Write("hello") 21 22 screen.SetRGB(255, 0, 0) 23 24 gobot.After(5*time.Second, func() { 25 screen.Clear() 26 screen.Home() 27 screen.SetRGB(0, 255, 0) 28 // set a custom character in the first position 29 screen.SetCustomChar(0, i2c.CustomLCDChars["smiley"]) 30 // add the custom character at the end of the string 31 screen.Write("goodbye\nhave a nice day " + string(byte(0))) 32 gobot.Every(500*time.Millisecond, func() { 33 screen.Scroll(false) 34 }) 35 }) 36 37 screen.Home() 38 time.Sleep(1 * time.Second) 39 screen.SetRGB(0, 0, 255) 40 } 41 42 robot := gobot.NewRobot("screenBot", 43 []gobot.Connection{board}, 44 []gobot.Device{screen}, 45 work, 46 ) 47 48 robot.Start() 49 }