94390a8d21c7cbdfe4c9c3e416c4701a390370e5 — Vladimír Magyar 2 years ago 0699a64
1 files changed, 47 insertions(+), 21 deletions(-)

M README.md => README.md +47 -21
@@ 36,22 36,40 @@ import (

	ink "git.sr.ht/~ghost08/inkview"

var (
	f *font.Font

func main() {
	ink.RunCLI(func(ctx context.Context, w io.Writer) error {
		fmt.Fprintln(w, "Device:")
		fmt.Fprintln(w, ink.DeviceModel())
		fmt.Fprintln(w, ink.SoftwareVersion())
		fmt.Fprintln(w, ink.HwAddress())

		for _, name := range ink.Connections() {
			fmt.Fprintf(w, "conn: %q", name)
	go eventLoop()

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)
				Font:  f,
				Color: color.Black,
				Text:  'Hello World",
		return nil
	}, nil)

@@ 67,8 85,23 @@ To run an binary, copy it into `applications/myawesomeapp.app` folder on the dev

## Notes on networking

By default, device will try to shutdown network interface to save battery,
thus you will need to call SDK functions to keep device online (see `KeepNetwork`).
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

@@ 78,10 111,3 @@ 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.

## Notes on workdir

Application will have a working directory set to FS root, and not to
a parent directory.
To use relative paths properly change local dir to a binary's parent
directory: `os.Chdir(filepath.Dir(os.Args[0]))`.