tinkerboard: add examples for ASUS Tinker Board

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-04-26 15:54:59 +02:00
parent d0385e4ccb
commit 8ca2e59271
2 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,32 @@
// +build example
//
// Do not build by default.
package main
import (
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/tinkerboard"
)
func main() {
r := tinkerboard.NewAdaptor()
led := gpio.NewLedDriver(r, "7")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
robot.Start()
}

View File

@ -0,0 +1,49 @@
// +build example
//
// Do not build by default.
package main
import (
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/i2c"
"gobot.io/x/gobot/platforms/tinkerboard"
)
func main() {
board := tinkerboard.NewAdaptor()
screen := i2c.NewGroveLcdDriver(board)
work := func() {
screen.Write("Hello from")
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("\nTinker Board " + string(byte(0)))
gobot.Every(500*time.Millisecond, func() {
screen.Scroll(false)
})
})
screen.Home()
time.Sleep(1 * time.Second)
screen.SetRGB(0, 0, 255)
}
robot := gobot.NewRobot("screenBot",
[]gobot.Connection{board},
[]gobot.Device{screen},
work,
)
robot.Start()
}