Documentation
¶
Index ¶
- Constants
- Variables
- func DrawFillRect(r MatrixRenderer, x0, y0, x1, y1 int)
- func DrawLine(r MatrixRenderer, x0, y0, x1, y1 int)
- func DrawRect(r MatrixRenderer, x0, y0, x1, y1 int)
- func GetAnimateState(p *serial.Port) (bool, error)
- func GetSleepState(p *serial.Port) (bool, error)
- func Panic(p *serial.Port) error
- func SetAnimationEnabled(p *serial.Port, enable bool) error
- func SetBrightness(p *serial.Port, brightness uint8) error
- func SetSleepState(p *serial.Port, sleep bool) error
- func ShowPattern(p *serial.Port, pat Pattern, per uint8) error
- func StartAnimation(render RenderFrameFunc, m MatrixRenderer, frameTime int64) error
- func WriteCommand(p *serial.Port, c Command, params []byte) error
- type BWMatrix
- type Command
- type GSMatrix
- type MatrixRenderer
- type Pattern
- type RenderFrameFunc
Constants ¶
const ( // FrameTime60FPS frame time for 60 fps animation FrameTime60FPS int64 = 17 // FrameTime30FPS frame time for 30 fps animation FrameTime30FPS int64 = 33 // FrameTime24FPS frame time for 24 fps animation FrameTime24FPS int64 = 42 )
const ( // MatrixWidth the width (in pixels) of the LED Matrix module MatrixWidth int = 9 // MatrixHeight the height (in pixels) of the LED Matrix module MatrixHeight int = 34 )
Variables ¶
var ErrorStopAnimation error = errors.New("fwmatrix - stop animation")
ErrorStopAnimation error used to signal to the
Functions ¶
func DrawFillRect ¶
func DrawFillRect(r MatrixRenderer, x0, y0, x1, y1 int)
DrawFillRect draws a filled rectangle with the provided matrix with opposite corners at x0,y0 and x1,y1
func DrawLine ¶
func DrawLine(r MatrixRenderer, x0, y0, x1, y1 int)
DrawLine draws a line with the provided matrix renderer from a point to another
func DrawRect ¶
func DrawRect(r MatrixRenderer, x0, y0, x1, y1 int)
DrawRect draws an empty rectangle with the provided matrix with opposite corners at x0,y0 and x1,y1
func GetAnimateState ¶
GetAnimateState returns whether or not the LED matrix module is in the middle of an animation Returns true if in an animation, false otherwise. Returns any errors encountered during serial communications
func GetSleepState ¶
GetSleepState returns whether or not the LED matrix module is in sleep mode. Returns true if in sleep mode, false otherwise. Returns any errors encountered during serial communications
func SetAnimationEnabled ¶
SetAnimation if enabled, scrolls through various pre-programmed animations until disabled. Returns any errors encountered during serial communications
func SetBrightness ¶
SetBrightness sets the global brightness for all pixels on the LED Matrix module. Brightness values range from 0 - 255. Returns any errors encountered during serial communications
func SetSleepState ¶
SetSleepState if sleep is true, sets the LED Matrix module to sleep until turned off (set to false) Returns any errors encountered during serial communications
func ShowPattern ¶
ShowPattern displays a pre-programmed pattern on a LED matrix module via the provided serial port. The PatPercentage pattern requires the per parameter to set the percentage to display. Returns any errors encountered during serial communications
func StartAnimation ¶
func StartAnimation(render RenderFrameFunc, m MatrixRenderer, frameTime int64) error
StartAnimation begins an animation on the provided MatrixRenderer using the provided rendering function. Frame time defines how many milliseconds should pass between rendering each frame. Stops whenever the returned error of the render function is not null. If the returned error is ErrorStopAnimation, this function will return nil. Otherwise, the error is returned
Types ¶
type BWMatrix ¶
type BWMatrix struct {
// contains filtered or unexported fields
}
BWMatrix a tool for drawing basic 1bit black & white pixel data on a LED Matrix module
func NewBW ¶
NewBW opens a serial port with the provided name and baud rate and initializes a new BWMatrix with it. Returns any errors that occurred when opening the serial port
func NewBWWithPort ¶
NewBWWithPort create and initialize a new BWMatrix using the provided serial port
type Command ¶
type Command uint8
const ( // CmdBrightness command to set LED brightness CmdBrightness Command = 0x00 // CmdPattern command to display a pre-programmed pattern CmdPattern Command = 0x01 // CmdBootloader command to jump to the bootloader CmdBootloader Command = 0x02 // CmdBootloader command to get or set the sleep state CmdSleep Command = 0x03 // CmdAnimate command to get or set an animation CmdAnimate Command = 0x04 // CmdPanic command to cause a FW panic CmdPanic Command = 0x05 // CmdDrawBW command to draw a 1bit B&W image CmdDrawBW Command = 0x06 // CmdStageCol command to set a greyscale column of pixels CmdStageCol Command = 0x07 // CmdFlushCols command to display greyscale columns CmdFlushCols Command = 0x08 )
type GSMatrix ¶
type GSMatrix struct {
// contains filtered or unexported fields
}
GSMatrix a tool for drawing basic 8bit greyscale pixel data on a LED Matrix module
func NewGS ¶
NewGS opens a serial port with the provided name and baud rate and initializes a new GSMatrix with it. Returns any errors that occurred when opening the serial port
func NewGSWithPort ¶
NewGSWithPort create and initialize a new GSMatrix using the provided serial port
func (*GSMatrix) Flush ¶
Flush writes the current stored pixel buffer to the LED Matrix module to display. Returns any errors encountered during serial communications
func (*GSMatrix) GetBrightness ¶
GetBrightness get the current pixel rendering brightness
func (*GSMatrix) SetBrightness ¶
SetBrightness set the current pixel rendering brightness
type MatrixRenderer ¶
MatrixRenderer renders pixels on the Framework 16 LED Matrix Module
type Pattern ¶
type Pattern uint8
const ( // PatPercentage displays a progress indicator using a provided percetange PatPercentage Pattern = 0x00 // PatGradient displays a brightness gradient from top to bottom PatGradient Pattern = 0x01 // PatDoubleGradient displays a brightness gradient from the middle to both top and bottom PatDoubleGradient Pattern = 0x02 // PatLotusHor displays the text "LOTUS" horizontally across the matrix PatLotusHor Pattern = 0x03 // PatZigZag displays a zigzag pattern PatZigZag Pattern = 0x04 // PatFullBrightness displays all LEDs at 100% brightness PatFullBrightness Pattern = 0x05 // PatPanic displays the text "PANIC" across the matrix PatPanic Pattern = 0x06 // PatLotusVert displays the text "LOTUS" vertically across the matrix PatLotusVert Pattern = 0x07 )
type RenderFrameFunc ¶
type RenderFrameFunc func(m MatrixRenderer, delta int64) error
RenderFrameFunc function for rendering a single frame of an animation. Delta is the time (in milliseconds) since the last frame render call was made Should return any errors encountered during rendering. Do not call r.Flush() inside the this function. Return ErrorStopAnimation to halt animation without throwing an error