forked from GoogleCloudPlatform/golang-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (34 loc) · 925 Bytes
/
main.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
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Program helloworld is a tiny program that blinks "Hello gopher!" on a
// Grove LCD RGB Backlight display connected to a BeagleBone.
package main
import (
"log"
"time"
"golang.org/x/exp/io/i2c"
"github.com/GoogleCloudPlatform/golang-samples/iotkit/helloworld/display"
)
func main() {
d, err := display.Open(&i2c.Devfs{Dev: "/dev/i2c-2"})
if err != nil {
log.Fatal(err)
}
defer d.Close()
// Set the backlight to Go blue.
if err := d.SetRGB(0, 128, 64); err != nil {
log.Fatal(err)
}
// Blink "Hello gopher!" on the display.
for {
if err := d.SetText("Hello gopher!"); err != nil {
log.Fatal(err)
}
time.Sleep(200 * time.Millisecond)
if err := d.Clear(); err != nil {
log.Fatal(err)
}
time.Sleep(200 * time.Millisecond)
}
}