pixoo64

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

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 10 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pixoo-64

Go library to control the Divoom Pixoo-64

This library is highly work-in-progress...

Example:

Result of example

package main

import (
	"github.com/jurjevic/pixoo64"
	"golang.org/x/image/draw"
	"image/png"
	"log"
	"net/http"
	"net/netip"
)

const address = "192.168.188.62"

func main() {
	addr, err := netip.ParseAddr(address)
	if err != nil {
		log.Fatal("unsupported address", address)
	}
	device, err := pixoo64.NewDevice(addr)
	if err != nil {
		log.Fatal("failed to create device for", address)
	}
	// test images
	picture, err := device.Display().CreatePicture()
	if err != nil {
		log.Fatal("failed to create picture")
	}
	addFrame(picture, "https://github.com/MariaLetta/free-gophers-pack/raw/master/characters/png/1.png")
	addFrame(picture, "https://github.com/MariaLetta/free-gophers-pack/raw/master/characters/png/2.png")
	addFrame(picture, "https://github.com/MariaLetta/free-gophers-pack/raw/master/characters/png/3.png")
	addFrame(picture, "https://github.com/MariaLetta/free-gophers-pack/raw/master/characters/png/4.png")
	addFrame(picture, "https://github.com/MariaLetta/free-gophers-pack/raw/master/characters/png/5.png")
	addFrame(picture, "https://github.com/MariaLetta/free-gophers-pack/raw/master/characters/png/6.png")
	err = picture.Update()
	if err != nil {
		log.Fatal("failed to update picture")
	}
}

func addFrame(picture *pixoo64.Picture, imageSrc string) {
	frame := picture.CreateFrame()
	frame.SetSpeed(1000)

	// Just a simple GET request to the image URL
	// We get back a *Response, and an error
	res, err := http.Get(imageSrc)
	if err != nil {
		log.Fatal("failed to load png", err)
	}
	defer res.Body.Close()

	img, err := png.Decode(res.Body)
	if err != nil {
		log.Fatal("failed to decode png", err)
	}

	draw.NearestNeighbor.Scale(frame.Rgba(), frame.Rgba().Bounds(), img, img.Bounds(), draw.Over, nil)
}

Notice: Images provided by https://github.com/MariaLetta/free-gophers-pack

Documentation

Index

Constants

View Source
const (
	Width  = 64
	Height = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

func (*Channel) ActivateCloudIndex

func (c *Channel) ActivateCloudIndex(index CloudIndex) error

func (*Channel) ActivateCustomPage

func (c *Channel) ActivateCustomPage(index int) error

func (*Channel) ActivateSetIndex

func (c *Channel) ActivateSetIndex(index Index) error

func (*Channel) ActivateVisualizer

func (c *Channel) ActivateVisualizer(eqPosition int) error

func (*Channel) SetClock

func (c *Channel) SetClock(id int) error

type Client

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

Client is used to send and receive the data to a pixoo64 device.

func (*Client) Post

func (c *Client) Post(data []byte) (string, error)

Post sends data to the pixoo64 device.

type CloudIndex

type CloudIndex int
const (
	RecommendCloudIndex       CloudIndex = 0
	FavouriteCloudIndex       CloudIndex = 1
	SubscribeArtistCloudIndex CloudIndex = 2
	AlbumCloudIndex           CloudIndex = 3
)

type Device

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

func NewDevice

func NewDevice(addr netip.Addr) (*Device, error)

NewDevice creates a new device with the given address.

func (*Device) Alert

func (d *Device) Alert() error

func (*Device) Channel

func (d *Device) Channel() *Channel

func (*Device) Countdown

func (d *Device) Countdown(minute int, second int, status Status) error

func (*Device) Display

func (d *Device) Display() *Display

func (*Device) Noise

func (d *Device) Noise(status Status) error

func (*Device) PlayBuzzer

func (d *Device) PlayBuzzer(activeTimeInCycle int, offTimeInCycle int, playTotalTime int) error

func (*Device) Scoreboard

func (d *Device) Scoreboard(blueScore int, redScore int) error

func (*Device) Stopwatch

func (d *Device) Stopwatch(status Status) error

type Display

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

Display manages the graphics on the pixoo64 device.

func NewDisplay

func NewDisplay(client *Client) (*Display, error)

NewDisplay create a new Display.

func (*Display) CreatePicture

func (d *Display) CreatePicture() (*Picture, error)

func (*Display) GetHttpGifId

func (d *Display) GetHttpGifId() (int, error)

func (*Display) Reset

func (d *Display) Reset() error

func (*Display) ResetText

func (d *Display) ResetText() error

func (*Display) SetBrightness

func (d *Display) SetBrightness(brightness int) error

func (*Display) Switch

func (d *Display) Switch(onoff Switch) error

func (*Display) Update

func (d *Display) Update() error

type Frame

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

func (*Frame) Fill

func (f *Frame) Fill(color color.Color)

func (*Frame) Id

func (f *Frame) Id() int

func (*Frame) Rgba

func (f *Frame) Rgba() *image.RGBA

func (*Frame) SetSpeed

func (f *Frame) SetSpeed(speed int)

func (*Frame) Speed

func (f *Frame) Speed() int

func (*Frame) Update

func (f *Frame) Update(pictureId int, frameCount int) error

type GetHttpGifId

type GetHttpGifId struct {
	ErrorCode int `json:"error_code"`
	PicId     int `json:"PicId"`
}

type Index

type Index int
const (
	FacesIndex        Index = 0
	CloudChannelIndex Index = 1
	VisualizerIndex   Index = 2
	CustomIndex       Index = 3
	BlackScreenIndex  Index = 4
)

type Picture

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

func (*Picture) CreateFrame

func (p *Picture) CreateFrame() *Frame

func (*Picture) Reset

func (p *Picture) Reset() error

func (*Picture) Update

func (p *Picture) Update() error

type Status

type Status int
const (
	Stop  Status = 0
	Start Status = 1
)

type Switch

type Switch int
const (
	Off Switch = 0
	On  Switch = 1
)

Jump to

Keyboard shortcuts

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