2015-07-10 02:50:39 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
2016-10-03 22:58:43 +08:00
|
|
|
"github.com/hybridgroup/gobot/drivers/i2c"
|
2015-07-10 02:50:39 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-03 22:58:43 +08:00
|
|
|
board := edison.NewAdaptor()
|
|
|
|
screen := i2c.NewGroveLcdDriver(board)
|
2015-07-10 02:50:39 +08:00
|
|
|
|
|
|
|
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)
|
2015-10-11 15:49:57 +08:00
|
|
|
// 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)))
|
2015-07-16 08:57:22 +08:00
|
|
|
gobot.Every(500*time.Millisecond, func() {
|
|
|
|
screen.Scroll(false)
|
|
|
|
})
|
2015-07-10 02:50:39 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
screen.Home()
|
2016-11-05 20:05:49 +08:00
|
|
|
time.Sleep(1 * time.Second)
|
2015-07-10 02:50:39 +08:00
|
|
|
screen.SetRGB(0, 0, 255)
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("screenBot",
|
|
|
|
[]gobot.Connection{board},
|
|
|
|
[]gobot.Device{screen},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:08:25 +08:00
|
|
|
robot.Start()
|
2015-07-10 02:50:39 +08:00
|
|
|
}
|