Documentation ¶
Index ¶
- Variables
- type Canvas
- func (c *Canvas) At(x, y int) color.Color
- func (c *Canvas) Bounds() image.Rectangle
- func (c *Canvas) Clear() error
- func (c *Canvas) Close() error
- func (c *Canvas) ColorModel() color.Model
- func (c *Canvas) Initialize() error
- func (c *Canvas) Render() error
- func (c *Canvas) Set(x, y int, color color.Color)
- type HardwareConfig
- type Matrix
- type StripType
- type WS281x
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = HardwareConfig{ Pin: 18, Frequency: 800000, DMA: 10, Brightness: 30, StripType: StripGRB, }
DefaultConfig default WS281x configuration
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas is a image.Image representation of a WS281x matrix, it implements image.Image interface and can be used with draw.Draw for example
func NewCanvas ¶
func NewCanvas(w, h int, config *HardwareConfig) (*Canvas, error)
NewCanvas returns a new Canvas using the given width and height and creates a new WS281x matrix using the given config
func (*Canvas) ColorModel ¶
ColorModel returns the canvas' color model, always color.RGBAModel
func (*Canvas) Initialize ¶
Initialize initialize the matrix and the canvas
type HardwareConfig ¶
type HardwareConfig struct { Pin int // GPIO Pin with PWM alternate function, 0 if unused Frequency int // the frequency of the display signal in hertz, can go as low as 400000 DMA int // the DMA channel to use Invert bool // specifying if the signal line should be inverted Channel int // PWM channel to us Brightness int // brightness value between 0 and 255 StripType StripType // strip color layout }
HardwareConfig WS281x configuration
type Matrix ¶
type StripType ¶
type StripType int
StripType layout
const ( // 4 color R, G, B and W ordering StripRGBW StripType = 0x18100800 StripRBGW StripType = 0x18100008 StripGRBW StripType = 0x18081000 StripGBRW StripType = 0x18080010 StripBRGW StripType = 0x18001008 StripBGRW StripType = 0x18000810 // 3 color R, G and B ordering StripRGB StripType = 0x00100800 StripRBG StripType = 0x00100008 StripGRB StripType = 0x00081000 StripGBR StripType = 0x00080010 StripBRG StripType = 0x00001008 StripBGR StripType = 0x00000810 )
type WS281x ¶
type WS281x struct { Config *HardwareConfig // contains filtered or unexported fields }
WS281x matrix representation for ws281x
func (*WS281x) At ¶
At return an Color which allows access to the LED display data as if it were a sequence of 24-bit RGB values.
func (*WS281x) Initialize ¶
Initialize initialize library, must be called once before other functions are called.