forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chip_grove_lcd.go
49 lines (38 loc) · 995 Bytes
/
chip_grove_lcd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/i2c"
"github.com/hybridgroup/gobot/platforms/chip"
)
func main() {
gbot := gobot.NewGobot()
board := chip.NewChipAdaptor("chip")
screen := i2c.NewGroveLcdDriver(board, "screen")
work := func() {
screen.Write("hello")
screen.SetRGB(255, 0, 0)
gobot.After(5*time.Second, func() {
screen.Clear()
screen.Home()
screen.SetRGB(0, 255, 0)
// set a custom character in the first position
screen.SetCustomChar(0, i2c.CustomLCDChars["smiley"])
// add the custom character at the end of the string
screen.Write("goodbye\nhave a nice day " + string(byte(0)))
gobot.Every(500*time.Millisecond, func() {
screen.Scroll(false)
})
})
screen.Home()
<-time.After(1 * time.Second)
screen.SetRGB(0, 0, 255)
}
robot := gobot.NewRobot("screenBot",
[]gobot.Connection{board},
[]gobot.Device{screen},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}