Last active
December 9, 2016 00:59
-
-
Save kmtr/bcae076fcdb253e2b286367b2407b160 to your computer and use it in GitHub Desktop.
GoでI2C制御のAQM0802液晶を使う ref: http://qiita.com/kmtr/items/6f61d2e1609ae83ce5c4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ env GOOS=linux GOARCH=arm GOARM=7 go build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo raspi-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 Advanced Options | |
A7 I2C | |
Yes | |
Finish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo rmmod i2c-dev i2c-bcm2708 | |
$ sudo modprobe i2c-bcm2708 baudrate=50000 | |
$ sudo modprobe i2c-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev := i2c.New(0x3e, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev := i2c.New(0x3e, 1) | |
dev.Write([]byte{0x0, 0x38}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ( | |
wait = 26300 * time.Nanosecond | |
) | |
func cmd(dev *i2c.I2C, b byte) { | |
dev.Write([]byte{0x0, b}) | |
time.Sleep(wait) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func write(dev *i2c.I2C, s string) { | |
chars := []byte(s) | |
dev.Write(append([]byte{0x40}, chars...)) | |
time.Sleep(wait) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"time" | |
"github.com/davecheney/i2c" | |
) | |
const ( | |
wait = 26300 * time.Nanosecond | |
) | |
func cmd(dev *i2c.I2C, b byte) { | |
dev.Write([]byte{0x0, b}) | |
time.Sleep(wait) | |
} | |
func write(dev *i2c.I2C, s string) { | |
chars := []byte(s) | |
dev.Write(append([]byte{0x40}, chars...)) | |
time.Sleep(wait) | |
} | |
func main() { | |
dev, _ := i2c.New(0x3e, 1) | |
cmd(dev, 0x38) | |
cmd(dev, 0x39) | |
cmd(dev, 0x14) | |
cmd(dev, 0x70) | |
cmd(dev, 0x56) | |
cmd(dev, 0x6c) | |
time.Sleep(200 * time.Millisecond) | |
cmd(dev, 0x38) | |
cmd(dev, 0x0c) | |
cmd(dev, 0x01) | |
time.Sleep(1080 * time.Microsecond) | |
write(dev, "Origami") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment