tinydisplay

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 11 Imported by: 5

README

tinydisplay

tinydisplay is a tiny display for TinyGo development.
It is possible to simulate the input of buttons and touch input.
tinydisplay works on windows, macOS and linux.

examples/buttons is an example that handles button input.

examples/touch_paint is an example of handling touch input.

Usage

First, run ./cmd/tinydisplay.
Next, control the display created by NewClient().
Some examples can be found in ./examples.

package main

import (
	"image/color"
	"time"

	"github.com/sago35/tinydisplay"
)

var (
	black = color.RGBA{0, 0, 0, 255}
	white = color.RGBA{255, 255, 255, 255}
)

func main() {
	display, _ := tinydisplay.NewClient("127.0.0.1", 9812, 320, 240)
	display.FillScreen(black)

	for x := int16(0); x < 100; x++ {
		display.SetPixel(x, x, white)
		display.SetPixel(x, 100-x-1, white)
	}
	for {
		time.Sleep(time.Hour)
	}
}
Server

CGO is required to build server (./cmd/tinydisplay).

$ go build ./cmd/tinydisplay

$ ./tinydisplay.exe
tcp:127.0.0.1:9812
320x240

or

$ ./tinydisplay.exe --address localhost --port 3000 --size 640x480
tcp:localhost:3000
640x480
Client
$ go run ./examples/basic

$ go run ./examples/displays

$ go run ./examples/pyportal_boing

$ go run ./examples/tinydraw

$ go run ./examples/unicode_font
Examples

./examples will work with both tinydisplay and wioterminal.
To make it work with tinydisplay, run go-build.

$ go run ./examples/basic

If you want to run it using a target such as wioterminal, please run tinygo flash.

$ tinygo flash --target wioterminal --size short ./examples/basic

install

$ go install github.com/sago35/tinydisplay/cmd/tinydisplay@latest
$ GOPROXY=direct go install github.com/sago35/tinydisplay/cmd/tinydisplay@latest

or

Author

sago35 - sago35@gmail.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RGB565ToRGBA

func RGB565ToRGBA(c uint16) color.RGBA

func RGBATo565

func RGBATo565(c color.RGBA) uint16

RGBATo565 converts a color.RGBA to uint16 used in the display

Types

type Client

type Client struct {
	Client *rpc.Client
	draw.Image

	Width  int
	Height int
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string, port, w, h int) (*Client, error)

func (*Client) ClearBuffer

func (c *Client) ClearBuffer()

func (*Client) ClearDisplay

func (c *Client) ClearDisplay()

func (*Client) Display

func (c *Client) Display() error

func (*Client) DrawRGBBitmap

func (c *Client) DrawRGBBitmap(x, y int16, data []uint16, w, h int16) error

func (*Client) DrawRGBBitmap8

func (c *Client) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error

func (*Client) DrawRectangle

func (c *Client) DrawRectangle(x, y, width, height int16, clr color.Color) error

func (*Client) FillRectangle

func (c *Client) FillRectangle(x, y, width, height int16, clr color.Color) error

func (*Client) FillScreen

func (c *Client) FillScreen(clr color.Color)

func (*Client) GetPressedKey

func (c *Client) GetPressedKey() uint16

func (*Client) ReadTouchPoint

func (c *Client) ReadTouchPoint() touch.Point

func (*Client) Set

func (c *Client) Set(x, y int, clr color.Color)

func (*Client) SetImage

func (c *Client) SetImage(img draw.Image)

func (*Client) SetPixel

func (c *Client) SetPixel(x, y int16, clr color.RGBA)

func (*Client) Size

func (c *Client) Size() (x, y int16)

func (*Client) Tick

func (c *Client) Tick()

func (*Client) WaitUntilIdle

func (c *Client) WaitUntilIdle()

Directories

Path Synopsis
cmd
examples
pyportal_boing
Port of Adafruit's "pyportal_boing" demo found here: https://github.com/adafruit/Adafruit_ILI9341/blob/master/examples/pyportal_boing
Port of Adafruit's "pyportal_boing" demo found here: https://github.com/adafruit/Adafruit_ILI9341/blob/master/examples/pyportal_boing

Jump to

Keyboard shortcuts

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