pixelclient

package
v0.0.0-...-3890e79 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the default path to the config file.

Types

type AnimationFrame

type AnimationFrame struct {
	Grid  string
	Delay time.Duration
}

AnimationFrame holds a rendered frame and its display duration

type Client

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

Client manages a WebSocket connection to a PixelGateway server.

func NewClient

func NewClient(device *Device) *Client

NewClient creates a new Client for the given device.

func (*Client) Close

func (c *Client) Close() error

Close closes the WebSocket connection.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

Connect establishes a WebSocket connection to the server.

func (*Client) Device

func (c *Client) Device() *Device

Device returns the device associated with this client.

func (*Client) Done

func (c *Client) Done() <-chan struct{}

Done returns a channel that is closed when the connection is closed.

func (*Client) Errors

func (c *Client) Errors() <-chan error

Errors returns a channel that receives connection errors.

func (*Client) Frames

func (c *Client) Frames() <-chan []byte

Frames returns a channel that receives WebP image frames.

func (*Client) Reconnect

func (c *Client) Reconnect(ctx context.Context) error

Reconnect attempts to reconnect to the server with exponential backoff.

type Config

type Config struct {
	Devices []Device `json:"devices"`
	// contains filtered or unexported fields
}

Config holds the list of configured devices and the path it was loaded from.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads the config file from the specified path. If path is empty, uses the default path (~/.pixelclient/config.json). Returns an empty config if the file doesn't exist.

func (*Config) AddDevice

func (c *Config) AddDevice(name, server, deviceID string) (*Device, error)

AddDevice adds a new device to the config. Returns an error if name or ID already exists, or if server is invalid.

func (*Config) FindDeviceByID

func (c *Config) FindDeviceByID(id string) *Device

FindDeviceByID returns the device with the given ID, or nil if not found.

func (*Config) FindDeviceByName

func (c *Config) FindDeviceByName(name string) *Device

FindDeviceByName returns the device with the given name, or nil if not found.

func (*Config) GetDefaultDevice

func (c *Config) GetDefaultDevice() *Device

GetDefaultDevice returns the device named "default", or nil if not found.

func (*Config) Path

func (c *Config) Path() string

Path returns the config file path.

func (*Config) Save

func (c *Config) Save() error

Save writes the config back to the path it was loaded from.

type Device

type Device struct {
	Name   string `json:"name"`
	ID     string `json:"id"`
	Server string `json:"server"`
}

Device represents a configured device entry.

type Model

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

Model is the Bubbletea model for the application

func NewModel

func NewModel(config *Config, initialDevice *Device) Model

NewModel creates a new Model with the given config

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (Model) View

func (m Model) View() string

View renders the UI

type Renderer

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

Renderer converts WebP images to terminal output with colored LED circles.

func NewRenderer

func NewRenderer(termWidth, termHeight int) *Renderer

NewRenderer creates a new Renderer with the given terminal dimensions.

func (*Renderer) CalculateVerticalPadding

func (r *Renderer) CalculateVerticalPadding(contentHeight int) int

CalculateVerticalPadding returns the number of blank lines needed above the image to vertically center it in the terminal.

func (*Renderer) DecodeAnimation

func (r *Renderer) DecodeAnimation(data []byte) ([]AnimationFrame, error)

DecodeAnimation decodes a WebP and returns all animation frames with timing.

func (*Renderer) RenderImage

func (r *Renderer) RenderImage(img image.Image) string

RenderImage converts an image to a string with colored LED circles. Each pixel is rendered as two half-circle characters to approximate a square aspect ratio.

func (*Renderer) RenderPlaceholder

func (r *Renderer) RenderPlaceholder() string

RenderPlaceholder returns a placeholder grid when no image is available.

func (*Renderer) RenderWebP

func (r *Renderer) RenderWebP(data []byte) (string, error)

RenderWebP decodes a WebP image and returns a string with colored LED circles.

func (*Renderer) UpdateSize

func (r *Renderer) UpdateSize(width, height int)

UpdateSize updates the terminal dimensions.

type View

type View int

View represents the current UI state

const (
	ViewSelection View = iota
	ViewConnecting
	ViewDisplay
	ViewCreateDevice
)

Jump to

Keyboard shortcuts

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