Skip to content

Commit 8f7a4f7

Browse files
committed
add example and short build instructions
1 parent e717967 commit 8f7a4f7

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
Go SDK for Pocketbook based on libinkview.
1+
Go SDK for Pocketbook based on libinkview.
2+
3+
To build your app or examples, run:
4+
5+
```bash
6+
cd ./go_app_path/
7+
docker run --rm -v $PWD:/app dennwc/pocketbook-go-sdk main.go
8+
```

examples/devinfo/main.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package main
2+
3+
import (
4+
"github.com/dennwc/inkview"
5+
)
6+
7+
func main() {
8+
var (
9+
log *ink.Log
10+
)
11+
ink.Run(func(e ink.Event) {
12+
switch e := e.(type) {
13+
case ink.InitEvent:
14+
ink.ClearScreen()
15+
log = ink.NewLog(ink.Pad(ink.Screen(), 10), 14)
16+
17+
log.Println("Device:")
18+
log.Println(ink.DeviceModel())
19+
log.Println(ink.SoftwareVersion())
20+
log.Println(ink.HwAddress())
21+
log.Println()
22+
23+
for _, name := range ink.Connections() {
24+
log.Printf("conn: %q", name)
25+
}
26+
log.Draw()
27+
28+
ink.FullUpdate()
29+
case ink.ExitEvent:
30+
log.Close()
31+
case ink.PointerEvent:
32+
if e.State == ink.PointerDown {
33+
log.Printf("click: %v", e.Point)
34+
log.Draw()
35+
ink.SoftUpdate()
36+
}
37+
case ink.KeyEvent:
38+
if e.Key == ink.KeyPrev && e.State == ink.KeyStateDown {
39+
ink.Close()
40+
}
41+
}
42+
})
43+
}

0 commit comments

Comments
 (0)