smartwatch

package module
v0.0.0-...-e6e9277 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2019 License: BSD-3-Clause Imports: 1 Imported by: 3

README

Go smartwatch toolkit

GoDoc

This is an attempt to build a toolkit for developing smartwatch firmware in Go (using TinyGo).

Supported smartwatches:

  • PineTime (display, battery)
  • X9 Pro (display)
  • Desktop Linux (for simulation)

Supported features:

  • Display.
  • Battery charge indication. Not yet properly calibrated.

This repository contains some example firmwares that run on all devices that have all relevant features implemented:

  • examples/hello draws a yellow rectangle and some text, for quick testing of the smartwatch.
  • examples/battery shows the current battery charge estimation and additionally also draws the voltage on the screen.
  • examples/digitalclock shows a very basic digital clock. It draws the current hour/minute on the screen. The time may be incorrect as TinyGo does not currently support setting the time on bare-metal systems.

Running on a real smartwatch

You can flash one of the examples to a real smartwatch. For example, to run the digital clock example on a PineTime:

tinygo flash -target=pinetime-devkit0 github.com/aykevl/go-smartwatch/examples/digitalclock

Note: as of this time (2019-11-07), you will need the development version of TinyGo (the dev branch). Take a look here for information on how to build it from source.

PineTime running the digital clock example

Linux simulation

All features of this toolkit have been implemented for Linux as well, returning something that at least looks legitimate. This allows for quick edit/test cycles using go run. For example:

go run github.com/aykevl/go-smartwatch/examples/digitalclock

Linux simulation of the digital clock example

License

This toolkit has been licensed under the BSD 2-clause license.

Documentation

Overview

Package smartwatch provides a common interface for multiple smartwatches.

It was originally developed to be used with the PineTime64 smartwatch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChargeStatus

type ChargeStatus uint8

ChargeStatus returns the state of the battery.

const (
	Discharging ChargeStatus = iota + 1
	Charging
	FullyCharged
)

Charge status of the battery: discharging, charging, and fully charged.

type Watch

type Watch struct {
	*sdlscreen.Screen
}

Watch is an emulation for smartwatches on Linux systems.

func Open

func Open() (*Watch, error)

Open returns a Watch instance. It is a singleton: opening it a second time will still return the same object, if opening the first time succeeded.

func (*Watch) BatteryStatus

func (w *Watch) BatteryStatus() (millivolt, percent int, status ChargeStatus)

BatteryStatus reads and returns the current battery status (percent and whether it is charging).

Directories

Path Synopsis
examples
battery
This program displays some simple graphics on the screen, as a "hello world" style program.
This program displays some simple graphics on the screen, as a "hello world" style program.
digitalclock
This program displays the current time on the screen.
This program displays the current time on the screen.
hello
This program displays some simple graphics on the screen, as a "hello world" style program.
This program displays some simple graphics on the screen, as a "hello world" style program.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL