2014-12-27 09:28:15 +01:00
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/kidoman/embd"
|
|
|
|
"github.com/kidoman/embd/controller/hd44780"
|
|
|
|
|
|
|
|
_ "github.com/kidoman/embd/host/all"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if err := embd.InitI2C(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer embd.CloseI2C()
|
|
|
|
|
|
|
|
bus := embd.NewI2CBus(1)
|
|
|
|
|
2015-02-22 07:50:56 +01:00
|
|
|
hd, err := hd44780.NewI2C(
|
2014-12-27 09:28:15 +01:00
|
|
|
bus,
|
|
|
|
0x20,
|
|
|
|
hd44780.PCF8574PinMap,
|
2015-02-22 07:50:56 +01:00
|
|
|
hd44780.RowAddress20Col,
|
2014-12-27 09:28:15 +01:00
|
|
|
hd44780.TwoLine,
|
|
|
|
hd44780.BlinkOn,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2015-02-22 07:50:56 +01:00
|
|
|
defer hd.Close()
|
2014-12-27 09:28:15 +01:00
|
|
|
|
2015-02-22 07:50:56 +01:00
|
|
|
hd.Clear()
|
|
|
|
message := "Hello, world!"
|
|
|
|
bytes := []byte(message)
|
|
|
|
for _, b := range bytes {
|
|
|
|
hd.WriteChar(b)
|
|
|
|
}
|
|
|
|
hd.SetCursor(0, 1)
|
|
|
|
|
|
|
|
message = "@embd | hd44780"
|
|
|
|
bytes = []byte(message)
|
|
|
|
for _, b := range bytes {
|
|
|
|
hd.WriteChar(b)
|
|
|
|
}
|
2014-12-27 09:28:15 +01:00
|
|
|
time.Sleep(10 * time.Second)
|
2015-02-22 07:50:56 +01:00
|
|
|
hd.BacklightOff()
|
2014-12-27 09:28:15 +01:00
|
|
|
}
|