govoom

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 10 Imported by: 0

README

govoom

Go Library to interact with devices from divoom (eg. Pixoo-64) via the HTTP API.

The official documentation for the API is here: https://docin.divoom-gz.com/web/#/5/23

Installation

go get github.com/roemer/govoom

Usage

devices, err := govoom.FindDevices()
if err != nil {
    // Handle error
}
client := devices[0].GetClient()
// Interact with the client now, eg:
client.SetBrightness(100)
Animation and Images

The usual approach to create a custom screen is to create a background image (or animation) and then display text above.

For background images, there are two variants:

  1. Load an image from the disk and use that one
  2. Create an image in-memory with the RgbImage helper type and its methods.

Loading an image from a file is pretty straight forward like:

// Load and decode the image
f, err := os.Open(pathToImage)
if err != nil {
    // Handle error
}
defer f.Close()
loadedImage, _, err := image.Decode(f)
if err != nil {
    // Handle error
}
// Convert the image to a byte array
imageData := govoom.ImageToRGB24Bytes(loadedImage)
// Reset the ID as otherwise the image is not updated
client.ResetSendingAnimationPicId()
// Send the image as a single frame to the display
client.SendAnimation(1, 1, 0, 64, 1000, imageData)

Manually creating an image and using that as background looks like this:

// Create the image in the appropriate size
img := govoom.NewRgbImage(64, 64)
// Use the methods on the image to paint the image or add text directly:
// Drawing pixels
img.DrawPixel(5, 5, govoom.ColorWhite)
// Drawing lines
img.DrawLine(10, 0, 20, 5, govoom.ColorRed)
// Drawing rectangles
img.DrawRectangleFilled(25, 0, 30, 10, govoom.ColorGreen, govoom.ColorAqua)
// Writing text in a PICO8-like font
img.DrawText("Left", 0, 15, govoom.Fonts.Pico8, govoom.ColorWhite, govoom.TextAlignmentLeft)
img.DrawText("Centered", 31, 21, govoom.Fonts.Pico8, govoom.ColorWhite, govoom.TextAlignmentMiddle)
img.DrawText("Right", 63, 27, govoom.Fonts.Pico8, govoom.ColorWhite, govoom.TextAlignmentRight)
// Add an image from the disk
mySmallImage := loadImage(pathToImage) // Same as for the background image
img.DrawImage(30, 30, mySmallImage)
// Reset the id and send the image as background
client.ResetSendingAnimationPicId()
client.SendAnimation(1, 1, 0, 64, 1000, img.Data)
Texts

If you want to write text with the api above a background image, you can use the SendDisplayList method on the client. That way, you can keep a single background image (or animation) and just regularly refresh the texts.

// Send background image first as described before
// Clear the texts
client.ClearAllTextArea()
// Send new texts
client.SendDisplayList(
    govoom.DisplayListElement{
        Id:            1,
        TextType:      govoom.TextTypeText,
        X:             59,
        Y:             0,
        Font:          34,
        Width:         64,
        Height:        5,
        TextAlignment: govoom.TextAlignmentRight,
        Color:         "#FFFFFF",
        Text:          "Hello",
    },
    govoom.DisplayListElement{
        Id:            2,
        TextType:      govoom.TextTypeText,
        X:             63,
        Y:             8,
        Font:          34,
        Width:         64,
        Height:        5,
        TextAlignment: govoom.TextAlignmentRight,
        Color:         "#FFFFFF",
        Text:          "World",
    },
)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Colors colors

A handfull of colors ready to be used.

View Source
var (
	ErrInvalidBrightness = fmt.Errorf("brightness should be in range of 0-100")
)
View Source
var FontPico8 = PixelFont{
	FontName:    "Pico8",
	Description: "Slim (3x5) font with upper- and lowercase letters, numbers and symbols",
	FixedWidth:  true,
	FontSpacing: 1,
	LineHeight:  5,
	Glyphs: map[rune]PixelGlyph{

		'0': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}}},
		'1': {Pixels: [][]byte{{1, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'2': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {1, 1, 1}, {1, 0, 0}, {1, 1, 1}}},
		'3': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 1}, {0, 0, 1}, {1, 1, 1}}},
		'4': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {0, 0, 1}}},
		'5': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 1}, {0, 0, 1}, {1, 1, 1}}},
		'6': {Pixels: [][]byte{{1, 0, 0}, {1, 0, 0}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}}},
		'7': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}}},
		'8': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}}},
		'9': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {0, 0, 1}}},

		'a': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}}},
		'b': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 1, 0}, {1, 0, 1}, {1, 1, 1}}},
		'c': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 0}, {0, 1, 1}}},
		'd': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}}},
		'e': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {1, 1, 0}, {1, 0, 0}, {0, 1, 1}}},
		'f': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {1, 1, 0}, {1, 0, 0}, {1, 0, 0}}},
		'g': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 1}}},
		'h': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}}},
		'i': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'j': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {1, 1, 0}}},
		'k': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'l': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {0, 1, 1}}},
		'm': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'n': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'o': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}}},
		'p': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 0}}},
		'q': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 0}, {1, 0, 1}, {1, 1, 0}, {0, 1, 1}}},
		'r': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}}},
		's': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 0}, {0, 0, 1}, {1, 1, 0}}},
		't': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'u': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {0, 1, 1}}},
		'v': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 0}}},
		'w': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 1, 1}}},
		'x': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {0, 1, 0}, {0, 1, 0}, {1, 0, 1}}},
		'y': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {1, 1, 0}}},
		'z': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 0, 1}, {1, 0, 0}, {1, 1, 1}}},

		'A': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'B': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 1, 1}}},
		'C': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {0, 1, 1}}},
		'D': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}}},
		'E': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 1, 1}}},
		'F': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 0, 0}}},
		'G': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 0, 0}, {1, 0, 1}, {1, 1, 1}}},
		'H': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'I': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'J': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 0}}},
		'K': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'L': {Pixels: [][]byte{{1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 1, 1}}},
		'M': {Pixels: [][]byte{{1, 1, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'N': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'O': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}}},
		'P': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 0}, {1, 0, 0}}},
		'Q': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}, {0, 1, 1}}},
		'R': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'S': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 1, 1}, {0, 0, 1}, {1, 1, 0}}},
		'T': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'U': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {0, 1, 1}}},
		'V': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 0}}},
		'W': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 1, 1}}},
		'X': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {0, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'Y': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {1, 1, 1}}},
		'Z': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 1, 1}}},

		' ':  {Pixels: [][]byte{{0, 0, 0}}},
		'!':  {Pixels: [][]byte{{0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 0, 0}, {0, 1, 0}}},
		'"':  {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
		'#':  {Pixels: [][]byte{{1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}}},
		'$':  {Pixels: [][]byte{{1, 1, 1}, {1, 1, 0}, {0, 1, 1}, {1, 1, 1}, {0, 1, 0}}},
		'%':  {Pixels: [][]byte{{1, 0, 1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 0, 1}}},
		'&':  {Pixels: [][]byte{{1, 1, 0}, {1, 1, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}}},
		'\'': {Pixels: [][]byte{{0, 1, 0}, {0, 1, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
		'(':  {Pixels: [][]byte{{0, 1, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {0, 1, 0}}},
		')':  {Pixels: [][]byte{{0, 1, 0}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}}},
		'*':  {Pixels: [][]byte{{1, 0, 1}, {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, {1, 0, 1}}},
		'+':  {Pixels: [][]byte{{0, 0, 0}, {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, {0, 0, 0}}},
		',':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 1, 0}, {1, 0, 0}}},
		'-':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}}},
		'.':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 1, 0}}},
		'/':  {Pixels: [][]byte{{0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 0, 0}}},
		':':  {Pixels: [][]byte{{0, 0, 0}, {0, 1, 0}, {0, 0, 0}, {0, 1, 0}, {0, 0, 0}}},
		';':  {Pixels: [][]byte{{0, 0, 0}, {0, 1, 0}, {0, 0, 0}, {0, 1, 0}, {1, 0, 0}}},
		'<':  {Pixels: [][]byte{{0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}},
		'=':  {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 0, 0}, {1, 1, 1}, {0, 0, 0}}},
		'>':  {Pixels: [][]byte{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}},
		'?':  {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 1}, {0, 0, 0}, {0, 1, 0}}},
		'@':  {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 0}, {0, 1, 1}}},
		'[':  {Pixels: [][]byte{{1, 1, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 1, 0}}},
		'\\': {Pixels: [][]byte{{1, 0, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 0, 1}}},
		']':  {Pixels: [][]byte{{0, 1, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 1, 1}}},
		'^':  {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
		'_':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {1, 1, 1}}},
		'`':  {Pixels: [][]byte{{0, 1, 0}, {0, 0, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
		'{':  {Pixels: [][]byte{{0, 1, 1}, {0, 1, 0}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}}},
		'|':  {Pixels: [][]byte{{0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'}':  {Pixels: [][]byte{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {0, 1, 0}, {1, 1, 0}}},
		'~':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 1}, {1, 1, 1}, {1, 0, 0}, {0, 0, 0}}},

		'×': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {0, 1, 0}, {1, 0, 1}, {0, 0, 0}}},
		'¿': {Pixels: [][]byte{{0, 1, 0}, {0, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 1, 1}}},
		'«': {Pixels: [][]byte{{0, 0, 1}, {0, 1, 1}, {1, 1, 1}, {0, 1, 1}, {0, 0, 1}}},
		'»': {Pixels: [][]byte{{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 1, 0}, {1, 0, 0}}},
		'°': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {0, 1, 0}, {0, 0, 0}, {0, 0, 0}}},
		'·': {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {0, 1, 0}, {0, 0, 0}, {0, 0, 0}}},
		'€': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {0, 1, 1}}},
		'¦': {Pixels: [][]byte{{0, 1, 0}, {0, 1, 0}, {0, 0, 0}, {0, 1, 0}, {0, 1, 0}}},
		'¢': {Pixels: [][]byte{{0, 1, 0}, {1, 1, 1}, {1, 0, 0}, {1, 1, 1}, {0, 1, 0}}},
		'£': {Pixels: [][]byte{{0, 1, 1}, {0, 1, 0}, {1, 1, 1}, {0, 0, 0}, {1, 1, 1}}},
	},
}
View Source
var FontPico8Narrow = PixelFont{
	FontName:    "Pico8Narrow",
	Description: "Same as Pico8 but not monospace and therefore more dense",
	FixedWidth:  false,
	FontSpacing: 1,
	LineHeight:  5,
	Glyphs: map[rune]PixelGlyph{

		'0': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}}},
		'1': {Pixels: [][]byte{{1, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'2': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {1, 1, 1}, {1, 0, 0}, {1, 1, 1}}},
		'3': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 1}, {0, 0, 1}, {1, 1, 1}}},
		'4': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {0, 0, 1}}},
		'5': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 1}, {0, 0, 1}, {1, 1, 1}}},
		'6': {Pixels: [][]byte{{1, 0, 0}, {1, 0, 0}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}}},
		'7': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}}},
		'8': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}}},
		'9': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {0, 0, 1}}},

		'a': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}}},
		'b': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 1, 0}, {1, 0, 1}, {1, 1, 1}}},
		'c': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 0}, {0, 1, 1}}},
		'd': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}}},
		'e': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {1, 1, 0}, {1, 0, 0}, {0, 1, 1}}},
		'f': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {1, 1, 0}, {1, 0, 0}, {1, 0, 0}}},
		'g': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 1}}},
		'h': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}}},
		'i': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'j': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {1, 1, 0}}},
		'k': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'l': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {0, 1, 1}}},
		'm': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'n': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'o': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}}},
		'p': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 0}}},
		'q': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 0}, {1, 0, 1}, {1, 1, 0}, {0, 1, 1}}},
		'r': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 0}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}}},
		's': {Pixels: [][]byte{{0, 0, 0}, {0, 1, 1}, {1, 0, 0}, {0, 0, 1}, {1, 1, 0}}},
		't': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'u': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {0, 1, 1}}},
		'v': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 0}}},
		'w': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 1, 1}}},
		'x': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {0, 1, 0}, {0, 1, 0}, {1, 0, 1}}},
		'y': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {1, 1, 0}}},
		'z': {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 0, 1}, {1, 0, 0}, {1, 1, 1}}},

		'A': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'B': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 1, 1}}},
		'C': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {0, 1, 1}}},
		'D': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}}},
		'E': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 1, 1}}},
		'F': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 0, 0}}},
		'G': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 0, 0}, {1, 0, 1}, {1, 1, 1}}},
		'H': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'I': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'J': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 0}}},
		'K': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'L': {Pixels: [][]byte{{1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 1, 1}}},
		'M': {Pixels: [][]byte{{1, 1, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'N': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'O': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}}},
		'P': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 0}, {1, 0, 0}}},
		'Q': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}, {0, 1, 1}}},
		'R': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'S': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 1, 1}, {0, 0, 1}, {1, 1, 0}}},
		'T': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'U': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {0, 1, 1}}},
		'V': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 0}}},
		'W': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 1, 1}}},
		'X': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {0, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'Y': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {1, 1, 1}}},
		'Z': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 1, 1}}},

		' ':  {Pixels: [][]byte{{0, 0, 0}}},
		'!':  {Pixels: [][]byte{{1}, {1}, {1}, {0}, {1}}},
		'"':  {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
		'#':  {Pixels: [][]byte{{1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}}},
		'$':  {Pixels: [][]byte{{1, 1, 1}, {1, 1, 0}, {0, 1, 1}, {1, 1, 1}, {0, 1, 0}}},
		'%':  {Pixels: [][]byte{{1, 0, 1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 0, 1}}},
		'&':  {Pixels: [][]byte{{1, 1, 0}, {1, 1, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}}},
		'\'': {Pixels: [][]byte{{1}, {1}, {0}, {0}, {0}}},
		'(':  {Pixels: [][]byte{{0, 1, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {0, 1, 0}}},
		')':  {Pixels: [][]byte{{0, 1, 0}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}}},
		'*':  {Pixels: [][]byte{{1, 0, 1}, {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, {1, 0, 1}}},
		'+':  {Pixels: [][]byte{{0, 0, 0}, {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, {0, 0, 0}}},
		',':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 1, 0}, {1, 0, 0}}},
		'-':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}}},
		'.':  {Pixels: [][]byte{{0}, {0}, {0}, {0}, {1}}},
		'/':  {Pixels: [][]byte{{0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 0, 0}}},
		':':  {Pixels: [][]byte{{0}, {1}, {0}, {1}, {0}}},
		';':  {Pixels: [][]byte{{0, 0, 0}, {0, 1, 0}, {0, 0, 0}, {0, 1, 0}, {1, 0, 0}}},
		'<':  {Pixels: [][]byte{{0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}},
		'=':  {Pixels: [][]byte{{0, 0, 0}, {1, 1, 1}, {0, 0, 0}, {1, 1, 1}, {0, 0, 0}}},
		'>':  {Pixels: [][]byte{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}},
		'?':  {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 1}, {0, 0, 0}, {0, 1, 0}}},
		'@':  {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 0}, {0, 1, 1}}},
		'[':  {Pixels: [][]byte{{1, 1, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 1, 0}}},
		'\\': {Pixels: [][]byte{{1, 0, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 0, 1}}},
		']':  {Pixels: [][]byte{{0, 1, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 1, 1}}},
		'^':  {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
		'_':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {1, 1, 1}}},
		'`':  {Pixels: [][]byte{{0, 1, 0}, {0, 0, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
		'{':  {Pixels: [][]byte{{0, 1, 1}, {0, 1, 0}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}}},
		'|':  {Pixels: [][]byte{{1}, {1}, {1}, {1}, {1}}},
		'}':  {Pixels: [][]byte{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {0, 1, 0}, {1, 1, 0}}},
		'~':  {Pixels: [][]byte{{0, 0, 0}, {0, 0, 1}, {1, 1, 1}, {1, 0, 0}, {0, 0, 0}}},

		'×': {Pixels: [][]byte{{0, 0, 0}, {1, 0, 1}, {0, 1, 0}, {1, 0, 1}, {0, 0, 0}}},
		'¿': {Pixels: [][]byte{{0, 1, 0}, {0, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 1, 1}}},
		'«': {Pixels: [][]byte{{0, 0, 1}, {0, 1, 1}, {1, 1, 1}, {0, 1, 1}, {0, 0, 1}}},
		'»': {Pixels: [][]byte{{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 1, 0}, {1, 0, 0}}},
		'°': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {0, 1, 0}, {0, 0, 0}, {0, 0, 0}}},
		'·': {Pixels: [][]byte{{0}, {0}, {1}, {0}, {0}}},
		'€': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {0, 1, 1}}},
		'¦': {Pixels: [][]byte{{1}, {1}, {0}, {1}, {1}}},
		'¢': {Pixels: [][]byte{{0, 1, 0}, {1, 1, 1}, {1, 0, 0}, {1, 1, 1}, {0, 1, 0}}},
		'£': {Pixels: [][]byte{{0, 1, 1}, {0, 1, 0}, {1, 1, 1}, {0, 0, 0}, {1, 1, 1}}},
	},
}
View Source
var FontSlumbers = PixelFont{
	FontName:    "Slumbers",
	Description: "Slim (3x5) font with mathematical symbols and uppercase letters",
	FixedWidth:  true,
	FontSpacing: 1,
	LineHeight:  5,
	Glyphs: map[rune]PixelGlyph{

		'0': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {0, 1, 0}}},
		'1': {Pixels: [][]byte{{0, 1, 0}, {1, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'2': {Pixels: [][]byte{{1, 1, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 1, 1}}},
		'3': {Pixels: [][]byte{{1, 1, 0}, {0, 0, 1}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}}},
		'4': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}, {0, 0, 1}}},
		'5': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 0}, {0, 0, 1}, {1, 1, 0}}},
		'6': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 1}, {0, 1, 0}}},
		'7': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'8': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {0, 1, 0}, {1, 0, 1}, {0, 1, 0}}},
		'9': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {0, 1, 1}, {0, 0, 1}, {1, 1, 0}}},

		'A': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'B': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 1, 0}}},
		'C': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {0, 1, 1}}},
		'D': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 0}}},
		'E': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 1, 1}}},
		'F': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 0, 0}}},
		'G': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 0, 1}, {0, 1, 1}}},
		'H': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}}},
		'I': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 1}}},
		'J': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 1, 0}}},
		'K': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'L': {Pixels: [][]byte{{1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 1, 1}}},
		'M': {Pixels: [][]byte{{1, 0, 1}, {1, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'N': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}},
		'O': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}}},
		'P': {Pixels: [][]byte{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 0}, {1, 0, 0}}},
		'Q': {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {0, 1, 1}}},
		'R': {Pixels: [][]byte{{1, 1, 0}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'S': {Pixels: [][]byte{{0, 1, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}}},
		'T': {Pixels: [][]byte{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'U': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}}},
		'V': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {0, 1, 0}}},
		'W': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0, 1}}},
		'X': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {0, 1, 0}, {1, 0, 1}, {1, 0, 1}}},
		'Y': {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
		'Z': {Pixels: [][]byte{{1, 1, 1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 1, 1}}},

		' ':  {Pixels: [][]byte{{0, 0}}},
		'!':  {Pixels: [][]byte{{1}, {1}, {1}, {0}, {1}}},
		'"':  {Pixels: [][]byte{{1, 0, 1}, {1, 0, 1}}},
		'%':  {Pixels: [][]byte{{1, 0, 1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 0, 1}}},
		'\'': {Pixels: [][]byte{{1}, {1}}},
		'(':  {Pixels: [][]byte{{0, 1}, {1, 0}, {1, 0}, {1, 0}, {0, 1}}},
		')':  {Pixels: [][]byte{{1, 0}, {0, 1}, {0, 1}, {0, 1}, {1, 0}}},
		'*':  {Pixels: [][]byte{{1, 0, 1}, {0, 1, 0}, {1, 0, 1}}},
		'+':  {Pixels: [][]byte{{0, 1, 0}, {1, 1, 1}, {0, 1, 0}}, Offset: 1},
		',':  {Pixels: [][]byte{{1}, {1}}, Offset: 4},
		'-':  {Pixels: [][]byte{{1, 1, 1}}, Offset: 2},
		'.':  {Pixels: [][]byte{{1}}, Offset: 4},
		'/':  {Pixels: [][]byte{{0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Offset: 1},
		':':  {Pixels: [][]byte{{1}, {0}, {1}}, Offset: 2},
		';':  {Pixels: [][]byte{{1}, {0}, {1}, {1}}, Offset: 2},
		'<':  {Pixels: [][]byte{{0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}},
		'=':  {Pixels: [][]byte{{1, 1, 1}, {0, 0, 0}, {1, 1, 1}}, Offset: 1},
		'>':  {Pixels: [][]byte{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}},
		'?':  {Pixels: [][]byte{{1, 1, 0}, {0, 0, 1}, {0, 1, 0}, {0, 0, 0}, {0, 1, 0}}},
		'[':  {Pixels: [][]byte{{1, 1}, {1, 0}, {1, 0}, {1, 0}, {1, 1}}},
		'\\': {Pixels: [][]byte{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, Offset: 1},
		']':  {Pixels: [][]byte{{1, 1}, {0, 1}, {0, 1}, {0, 1}, {1, 1}}},
		'^':  {Pixels: [][]byte{{0, 1, 0}, {1, 0, 1}}},
		'_':  {Pixels: [][]byte{{1, 1, 1}}, Offset: 4},
		'`':  {Pixels: [][]byte{{1, 0}, {0, 1}}},
		'{':  {Pixels: [][]byte{{0, 0, 1}, {0, 1, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}}},
		'|':  {Pixels: [][]byte{{1}, {1}, {1}, {1}, {1}}},
		'}':  {Pixels: [][]byte{{1, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 1, 0}, {1, 0, 0}}},

		'k': {Pixels: [][]byte{{1, 0, 0}, {1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 0, 1}}},
	},
}
View Source
var Fonts fonts

Functions

func ImageToRGB24Bytes

func ImageToRGB24Bytes(img image.Image) []byte

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(deviceIp string) *Client

func NewClientFromDevice

func NewClientFromDevice(d *Device) *Client

func (*Client) ClearAllTextArea

func (c *Client) ClearAllTextArea() error

func (*Client) GetSendingAnimationPicID

func (c *Client) GetSendingAnimationPicID() (int, error)

func (*Client) ResetSendingAnimationPicId

func (c *Client) ResetSendingAnimationPicId() error

func (*Client) SendAnimation

func (c *Client) SendAnimation(animationId int, numPictures int, pictureIndex int, width int, speed int, picData []byte) error

func (*Client) SendDisplayList

func (c *Client) SendDisplayList(elements ...DisplayListElement) error

func (*Client) SendText

func (c *Client) SendText(id, x, y int, dir TextScrollDirection, font TextFont, width int, str string, speed int, color string, align TextAlignment) error

func (*Client) SetBrightness

func (c *Client) SetBrightness(brightness int) error

func (*Client) SetMirrorMode

func (c *Client) SetMirrorMode(mirrorMode MirrorMode) error

func (*Client) SetRotation

func (c *Client) SetRotation(deviceIp string, rotation RotationAngle) error

type Color added in v0.2.0

type Color struct {
	R byte
	G byte
	B byte
}

A type to represent a color.

func NewColor added in v0.2.0

func NewColor(r, g, b byte) Color

Constructor method for a color.

func (Color) ToHex added in v0.4.2

func (c Color) ToHex() string

type Device

type Device struct {
	DeviceName      string `json:"DeviceName"`
	DeviceID        int    `json:"DeviceId"`
	DevicePrivateIP string `json:"DevicePrivateIP"`
	DeviceMAC       string `json:"DeviceMac"`
}

func FindDeviceByMac added in v0.4.0

func FindDeviceByMac(mac string) (*Device, error)

func FindDevices

func FindDevices() ([]*Device, error)

func (*Device) GetClient

func (d *Device) GetClient() *Client

type DisplayListElement

type DisplayListElement struct {
	Id              int                 `json:"TextId"`
	TextType        TextType            `json:"type"`
	X               int                 `json:"x"`
	Y               int                 `json:"y"`
	ScrollDirection TextScrollDirection `json:"dir"`
	Font            int                 `json:"font"`
	Width           int                 `json:"TextWidth"`
	Height          int                 `json:"Textheight"`
	Text            string              `json:"TextString"`
	Speed           int                 `json:"speed"`
	Color           string              `json:"color"`
	UpdateTime      int                 `json:"update_time"`
	TextAlignment   TextAlignment       `json:"align"`
}

type MirrorMode

type MirrorMode int
const (
	MirrorModeDisable MirrorMode = 0
	MirrorModeEnable  MirrorMode = 1
)

type PixelFont added in v0.3.0

type PixelFont struct {
	// The name of ththe font.
	FontName string
	// A short description of the font.
	Description string
	// This flag is true if the font has a fixed width, false otherwise.
	FixedWidth bool
	// The number of pixels added between each character.
	FontSpacing int
	// The height of the font.
	LineHeight int
	// A map which contains the pixel information for each rune.
	Glyphs map[rune]PixelGlyph
}

This type represents a font.

type PixelGlyph added in v0.3.0

type PixelGlyph struct {
	// An offset of pixels that are empty from the top.
	Offset int
	// The array with rows/columns of pixels.
	Pixels [][]byte
}

This type represents a glyph inside a font.

func (PixelGlyph) GetWidth added in v0.3.0

func (p PixelGlyph) GetWidth() int

func (PixelGlyph) Touches added in v0.3.0

func (rightGlyph PixelGlyph) Touches(leftGlyph PixelGlyph) bool

Checks if the glyph touches the other glyph on the left side. Touch means either a direct or a diagonal connection.

type RgbImage added in v0.2.0

type RgbImage struct {
	Data   []byte
	Width  int
	Height int
}

func NewRgbImage added in v0.2.0

func NewRgbImage(width, height int) *RgbImage

func (*RgbImage) Clear added in v0.2.0

func (img *RgbImage) Clear()

func (*RgbImage) DrawCharacter added in v0.2.0

func (img *RgbImage) DrawCharacter(character rune, x, y int, font PixelFont, color Color) int

func (*RgbImage) DrawCircle added in v0.4.1

func (img *RgbImage) DrawCircle(centerX, centerY int, radius int, borderColor Color)

func (*RgbImage) DrawCircleFilled added in v0.4.1

func (img *RgbImage) DrawCircleFilled(centerX, centerY int, radius int, borderColor Color, fillColor Color)

func (*RgbImage) DrawGlyph added in v0.3.0

func (img *RgbImage) DrawGlyph(glyph PixelGlyph, x, y int, color Color) int

func (*RgbImage) DrawImage added in v0.2.0

func (img *RgbImage) DrawImage(x, y int, goImg image.Image)

func (*RgbImage) DrawLine added in v0.2.0

func (img *RgbImage) DrawLine(startX, startY int, endX, endY int, color Color)

func (*RgbImage) DrawPixel added in v0.2.0

func (img *RgbImage) DrawPixel(x, y int, color Color)

func (*RgbImage) DrawPixelAtIndex added in v0.2.0

func (img *RgbImage) DrawPixelAtIndex(index int, color Color)

func (*RgbImage) DrawRectangle added in v0.2.0

func (img *RgbImage) DrawRectangle(left, top int, width, height int, borderColor Color)

func (*RgbImage) DrawRectangleFilled added in v0.2.0

func (img *RgbImage) DrawRectangleFilled(left, top int, width, height int, borderColor Color, fillColor Color)

func (*RgbImage) DrawText added in v0.2.0

func (img *RgbImage) DrawText(text string, x, y int, font PixelFont, color Color, alignment TextAlignment) int

func (*RgbImage) Fill added in v0.2.0

func (img *RgbImage) Fill(color Color)

func (*RgbImage) SaveToPng added in v0.3.0

func (img *RgbImage) SaveToPng(path string, scale int) error

type RotationAngle

type RotationAngle int
const (
	RotationNormal RotationAngle = 0
	Rotation90     RotationAngle = 1
	Rotation180    RotationAngle = 2
	Rotation270    RotationAngle = 3
)

type TextAlignment

type TextAlignment int
const (
	TextAlignmentLeft   TextAlignment = 1
	TextAlignmentMiddle TextAlignment = 2
	TextAlignmentRight  TextAlignment = 3
)

type TextFont

type TextFont int
const (
	TextFont0 TextFont = iota
	TextFont1
	TextFont2
	TextFont3
	TextFont4
	TextFont5
	TextFont6
	TextFont7
)

type TextScrollDirection

type TextScrollDirection int
const (
	TextScrollDirectionLeft  TextScrollDirection = 0
	TextScrollDirectionRight TextScrollDirection = 1
)

type TextType

type TextType int
const (
	TextTypeTimeSecond           TextType = 1
	TextTypeTimeMinute           TextType = 2
	TextTypeTimeHour             TextType = 3
	TextTypeTimeAmPm             TextType = 4
	TextTypeTimeHourMinute       TextType = 5 // hour:min
	TextTypeTimeHourMinuteSecond TextType = 6 // hour:min:sec
	TextTypeDateYear             TextType = 7
	TextTypeDateDay              TextType = 8
	TextTypeDateMonth            TextType = 9
	TextTypeDateMonthYear        TextType = 10 // month-year
	TextTypeDateMonthNameDotDay  TextType = 11 // month-name.day
	TextTypeDateWeekYear         TextType = 12 // day:month:year ???
	TextTypeDateDayName2Char     TextType = 13 // weekday-"SU","MO","TU","WE","TH","FR","SA"
	TextTypeDateDayName3Char     TextType = 14 // weekday-"SUN","MON","TUE","WED","THU","FRI","SAT"
	TextTypeDateDayNameFull      TextType = 15 // weekday-"SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"
	TextTypeDateMonthName3Char   TextType = 16 // month-"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"
	TextTypeWeatherTemp          TextType = 17 // temperature + c/f
	TextTypeWeatherTodayMaxTemp  TextType = 18
	TextTypeWeatherTodayMinTemp  TextType = 19
	TextTypeWeatherName          TextType = 20 // the weather
	TextTypeNoise                TextType = 21 // the noise value
	TextTypeText                 TextType = 22 // a defined text
	TextTypeNetText              TextType = 23 // an url that responds with a json including the "DispData" string element, eg:http://appin.divoom-gz.com/Device/ReturnCurrentDate?test=0 reponse {"DispData": "2022-01-22 13:51:56"}
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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