~ghost08/ink

Go SDK for Pocketbook
Fix Dockerfile with new include paths

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~ghost08/ink
read/write
git@git.sr.ht:~ghost08/ink

You can also use your local clone with git send-email.

#Go SDK for Pocketbook

Under construction! Don't use now!

Unofficial Go SDK for Pocketbook based on libinkview.

Supports graphical user interfaces and CLI apps.

Forked from github.com/dennwc/inkview

Submit tickets to todo.sr.ht/~ghost08/ink, or via mail ~ghost08/ink@todo.sr.ht.

Submit patches to lists.sr.ht/~ghost08/ink, or via mail ~ghost08/ink@lists.sr.ht.

#Install

For your convenience there is a docker-compose.yaml.

git clone https://git.sr.ht/~ghost08/ink
cd ink
docker-compose build

will create a container (it will take a while), which can be used to compile a go program.

#Build an app with UI

Example code (myawesomeapp.go):

package main

import (
	"context"
	"fmt"
	"io"

	"git.sr.ht/~ghost08/ink"
	"git.sr.ht/~ghost08/ink/font"
	"git.sr.ht/~ghost08/ink/layout"
	"git.sr.ht/~ghost08/ink/layout/widget"
	"git.sr.ht/~ghost08/ink/op"
	"git.sr.ht/~ghost08/ink/op/screen"
)

var (
	f *font.Font
)

func main() {
	go eventLoop()
	ink.Run()
}

func eventLoop() {
	for e := range ink.Events() {
		switch e := e.(type) {
		case ink.InitEvent:
			f = font.OpenFont("LiberationSans", 200, false)
		case ink.ShowEvent:
			gtx := layout.NewContext(e)
			gtx.Ops.Add(screen.Clear{})
			widget.Label{
				Font:  f,
				Color: color.Black,
				Text:  'Hello World",
			}.Layout(gtx)
			gtx.Ops.Add(screen.SoftUpdate{})
			gtx.Do()
		}
	}
}

(also use the go mod init and go mod tidy stuff)

To build your app run (requires Docker):

docker run --rm -v $PWD:/app ghost08/pocketbook-go-sdk build -o myawesomeapp.app

To run an binary, copy it into applications/myawesomeapp.app folder on the device and it should appear in the applications list.

#Notes on networking

By default, device will try to shutdown network interface to save battery. So before making a network call use:

func makeHttpCall(url string) error {
	if err := ink.NetConnect(""); err != nil {
		return err
	}
	defer ink.NetDisconnect()
	res, err := http.Get(url)
	if err != nil {
		return err
	}
	//Do something with response
	return nil
}

Also note that establishing TLS will require Go to read system certificate pool that might take up to 30 sec on some devices and will lead to TLS handshake timeouts. You will need to call InitCerts first to fix the problem.

IPv6 is not enabled on some devices, thus a patch to Go DNS lib is required to skip lookup on IPv6 address (SDK already includes the patch). Similar problems may arise when trying to dial IPv6 directly.

Do not follow this link