はじめに
e-Paperを購入したけど使っていなかったので、とりあえず試してみた。
あと、Pythonのプログラムがあるけど、go言語でやりたいので調べたらライブラリがあるのでとりあえずテストしてみた。
ソースコード
main.go
package main
import (
"time"
"github.com/otaviokr/go-epaper-lib"
)
func main() {
// New EPaperDisplay handler for model 2.7 inches, black-and-white..
epd, err := epaper.New(epaper.Model2in7bw)
if err != nil {
panic(err)
}
// Run mandatory initialization.
epd.Init()
// Clear screen to avoid undesired meshes.
epd.ClearScreen()
// Parse the string and process it with TTF font.
text := "test"
fontSize := 10.0
fontFile := "/usr/share/fonts/truetype/dejavu/DejaVuSans-BoldOblique.ttf"
m := epd.Write(text, fontSize, fontFile)
// Add the resulting image into the buffer.
epd.AddLayer(m, 0, 0, false)
epd.AddLayer(m, 0, 30, true)
// Print the buffer onto the display..
epd.PrintDisplay()
// epd.Display()
// Just a timeout before clearing the screen.
time.Sleep(10000 * time.Millisecond)
epd.ClearScreen()
// Always put the screen to sleep when it will not be refreshed shortly.
epd.Sleep()
}
結果
go mod init epaper
go mod tity
go run ./
以下図のように表示されることが分かった。
これから、改造次第でいろいろと違うこともできそう