Documentation ¶
Overview ¶
Package gpiostream defines digital streams.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitStream ¶
BitStream is a stream of bits to be written or read.
This struct is useful for dense binary data, like controlling ws2812b LED strip or using the GPIO pin as an digital oscilloscope.
func (*BitStream) Resolution ¶
Resolution implement Stream.
type Bits ¶
type Bits []byte
Bits is a densely packed bitstream. The format is LSB, bit 0 is sent first, up to bit 7.
The stream is required to be a multiple of 8 samples.
type EdgeStream ¶
type EdgeStream struct { // Edges is the list of Level change. It is assumed that the signal starts // with gpio.High. Use a duration of 0 to start with a Low. Edges []time.Duration // Res is the minimum resolution at which the edges should be // rasterized. // // The lower the value, the more memory shall be used when rasterized. Res time.Duration }
EdgeStream is a stream of edges to be written.
This struct is more efficient than BitStream for repetitive pulses, like controlling a servo. A PWM can be created by specifying a slice of twice the same resolution and make it looping.
func (*EdgeStream) Duration ¶
func (e *EdgeStream) Duration() time.Duration
Duration implement Stream.
func (*EdgeStream) Resolution ¶
func (e *EdgeStream) Resolution() time.Duration
Resolution implement Stream.
type Program ¶
type Program struct { Parts []Stream // Each part must be a BitStream, EdgeStream or Program Loops int // Set to -1 to create an infinite loop }
Program is a loop of streams.
This is itself a stream, it can be used to reduce memory usage when repeated patterns are used.
func (*Program) Resolution ¶
Resolution implement Stream.
type Stream ¶
type Stream interface { // Resolution is the minimum resolution of the binary stream at which it is // usable. Resolution() time.Duration // Duration of the binary stream. For infinitely looping streams, it is the // duration of the non-looping part. Duration() time.Duration }
Stream is the interface to define a generic stream