matrix

package
v0.0.0-...-a545287 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MatrixEmulatorENV        = "MATRIX_EMULATOR"
	MatrixClientENV          = "MATRIX_CLIENT"
	MatrixServerENV          = "MATRIX_SERVER"
	MatrixServerIpAddressENV = "MATRIX_ADDRESS"
)
View Source
const DefaultPixelPitch = 12

Variables

View Source
var DefaultConfig = MatrixConfig{
	Rows:                   32,
	Cols:                   32,
	ChainLength:            1,
	Parallel:               1,
	PWMBits:                11,
	PWMLSBNanoseconds:      130,
	Brightness:             100,
	ScanMode:               Progressive,
	DisableHardwarePulsing: false,
	ShowRefreshRate:        false,
	InverseColors:          false,
	HardwareMapping:        "",
	LedPixelMapper:         "",
	Emulator:               false,
	Client:                 false,
	Server:                 false,
}

DefaultConfig default WS281x configuration

Functions

func NewCanvas

func NewCanvas(config *MatrixConfig, m Matrix) Canvas

func NewSimpleCanvas

func NewSimpleCanvas(x, y int, leds *[]color.Color) Canvas

func RpcServe

func RpcServe(matrix Matrix) func(c Canvas, done chan struct{})

func Run

func Run(gameloop func(_ Canvas, _ chan struct{}, _ *controller.KeyboardEventChannel))

func RunMatrices

func RunMatrices(app func())

Types

type CloseArgs

type CloseArgs struct{}

type CloseReply

type CloseReply struct{}

type GeometryArgs

type GeometryArgs struct{}

type GeometryReply

type GeometryReply struct{ Width, Height int }

type Matrix

type Matrix interface {
	Config() *MatrixConfig
	Geometry() (width, height int)
	// Render update the display with the data from the canvas content
	Render(canvas Canvas) error
	RenderMethod(canvas Canvas) error
	Close() error

	MainThread(canvas Canvas, done chan struct{})
	// contains filtered or unexported methods
}

Matrix is an interface that represent any RGB matrix, very useful for testing

func BuildMatrix

func BuildMatrix(config *MatrixConfig) (Matrix, error)

func NewEmulator

func NewEmulator(config *MatrixConfig) (Matrix, error)

func NewRGBLedMatrix

func NewRGBLedMatrix(config *MatrixConfig) (c Matrix, err error)

NewRGBLedMatrix returns a new matrix using the given size and config

func NewRpcClient

func NewRpcClient(config *MatrixConfig) (Matrix, error)

type MatrixConfig

type MatrixConfig struct {
	// Rows the number of rows supported by the display, so 32 or 16.
	Rows int
	// Cols the number of columns supported by the display, so 32 or 64 .
	Cols int
	// ChainLength is the number of displays daisy-chained together
	// (output of one connected to input of next).
	ChainLength int
	// Parallel is the number of parallel chains connected to the Pi; in old Pis
	// with 26 GPIO pins, that is 1, in newer Pis with 40 interfaces pins, that
	// can also be 2 or 3. The effective number of pixels in vertical direction is
	// then thus rows * parallel.
	Parallel int
	// Set PWM bits used for output. Default is 11, but if you only deal with
	// limited comic-colors, 1 might be sufficient. Lower require less CPU and
	// increases refresh-rate.
	PWMBits int
	// Change the base time-unit for the on-time in the lowest significant bit in
	// nanoseconds.  Higher numbers provide better quality (more accurate color,
	// less ghosting), but have a negative impact on the frame rate.
	PWMLSBNanoseconds int // the DMA channel to use
	// Brightness is the initial brightness of the panel in percent. Valid range
	// is 1..100
	Brightness int
	// ScanMode progressive or interlaced
	ScanMode ScanMode // strip color layout
	// Disable the PWM hardware subsystem to create pulses. Typically, you don't
	// want to disable hardware pulsing, this is mostly for debugging and figuring
	// out if there is interference with the sound system.
	// This won't do anything if output enable is not connected to GPIO 18 in
	// non-standard wirings.
	DisableHardwarePulsing bool

	ShowRefreshRate bool
	InverseColors   bool

	// Name of GPIO mapping used
	HardwareMapping string
	// Semicolon-separated list of pixel-mappers to arrange pixels.
	LedPixelMapper string
	// Using OpenGL emulator instead of driving hardware matrix
	Emulator bool
	// Driving remote matrix using GoRPC
	Client bool
	// Serving hardware matrix using GoRPC
	Server bool
	// Remote server address
	IpAddress string
}

MatrixConfig rgb-led-matrix configuration

func ReadConfigFlags

func ReadConfigFlags() (*MatrixConfig, error)

func (*MatrixConfig) Geometry

func (mc *MatrixConfig) Geometry() (width, height int)

type MatrixEmulator

type MatrixEmulator struct {
	PixelPitch              int
	Gutter                  int
	Width                   int
	Height                  int
	GutterColor             color.Color
	PixelPitchToGutterRatio int
	Margin                  int
	// contains filtered or unexported fields
}

func (*MatrixEmulator) Close

func (m *MatrixEmulator) Close() error

func (*MatrixEmulator) Config

func (m *MatrixEmulator) Config() *MatrixConfig

func (*MatrixEmulator) Geometry

func (m *MatrixEmulator) Geometry() (width, height int)

Geometry returns the width and the height of the matrix

func (*MatrixEmulator) MainThread

func (m *MatrixEmulator) MainThread(canvas Canvas, done chan struct{})

func (*MatrixEmulator) Render

func (m *MatrixEmulator) Render(canvas Canvas) error

Render update the display with the data from the canvas content

func (*MatrixEmulator) RenderMethod

func (m *MatrixEmulator) RenderMethod(c Canvas) error

type MatrixHardware

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

MatrixHardware matrix representation for ws281x

func (*MatrixHardware) Close

func (m *MatrixHardware) Close() error

Close finalizes the ws281x interface

func (*MatrixHardware) Config

func (m *MatrixHardware) Config() *MatrixConfig

Geometry returns the width and the height of the matrix

func (*MatrixHardware) Geometry

func (m *MatrixHardware) Geometry() (width, height int)

Geometry returns the width and the height of the matrix

func (*MatrixHardware) MainThread

func (m *MatrixHardware) MainThread(_ Canvas, done chan struct{})

func (*MatrixHardware) Render

func (m *MatrixHardware) Render(canvas Canvas) error

Render update the display with the data from the LED buffer

func (*MatrixHardware) RenderMethod

func (m *MatrixHardware) RenderMethod(canvas Canvas) error

func (*MatrixHardware) Send

func (m *MatrixHardware) Send(_ interface{})

type MatrixRPCServer

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

func (*MatrixRPCServer) Close

func (m *MatrixRPCServer) Close(_ *CloseArgs, _ *CloseReply) error

func (*MatrixRPCServer) Geometry

func (m *MatrixRPCServer) Geometry(_ *GeometryArgs, reply *GeometryReply) error

func (*MatrixRPCServer) Render

func (m *MatrixRPCServer) Render(args *RenderArgs, _ *RenderReply) error

type MatrixRpcClient

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

func (*MatrixRpcClient) Close

func (m *MatrixRpcClient) Close() error

func (*MatrixRpcClient) Config

func (m *MatrixRpcClient) Config() *MatrixConfig

func (*MatrixRpcClient) Geometry

func (m *MatrixRpcClient) Geometry() (width, height int)

func (*MatrixRpcClient) MainThread

func (m *MatrixRpcClient) MainThread(_ Canvas, done chan struct{})

func (*MatrixRpcClient) Render

func (m *MatrixRpcClient) Render(canvas Canvas) error

func (*MatrixRpcClient) RenderMethod

func (m *MatrixRpcClient) RenderMethod(canvas Canvas) error

type RenderArgs

type RenderArgs struct {
	Pixels []RpcPixel
	//Colors []color.Color
	Timestamp int64
}

type RenderReply

type RenderReply struct{}

type RpcPixel

type RpcPixel struct {
	X, Y int
	C    color.Color
}

type ScanMode

type ScanMode int8
const (
	Progressive ScanMode = 0
	Interlaced  ScanMode = 1
)

type StopEvent

type StopEvent struct{}

type UploadEvent

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

UploadEvent signals that the shared pix slice should be uploaded to the screen.Texture via the screen.Buffer.

Jump to

Keyboard shortcuts

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