Documentation ¶
Overview ¶
Package opc helps you send and receive Open Pixel Control messages.
Index ¶
- Constants
- Variables
- func LaunchOpcServer(ipPort string) chan *OpcMessage
- func OpcServerThread(ipPort string, incomingOpcMessageChan chan *OpcMessage)
- func ReadLocations(fn string) []float64
- func Spiral(x, y, t, SPIRAL_tightness, SPIRAL_speed, SPIRAL_thickness, ... float64, ...) float64
- type ByteThread
- func MakeEffectFader(locations []float64) ByteThread
- func MakeOpcServerThread(ipPort string) ByteThread
- func MakePatternAqua(locations []float64) ByteThread
- func MakePatternAquaB(locations []float64) ByteThread
- func MakePatternArchimedes(locations []float64) ByteThread
- func MakePatternBasicMidi(locations []float64) ByteThread
- func MakePatternDiamond(locations []float64) ByteThread
- func MakePatternEye(locations []float64) ByteThread
- func MakePatternFire(locations []float64) ByteThread
- func MakePatternHousePotty(locations []float64) ByteThread
- func MakePatternJapan(locations []float64) ByteThread
- func MakePatternMidiSwitcher(locations []float64) ByteThread
- func MakePatternMoire(locations []float64) ByteThread
- func MakePatternOff(locations []float64) ByteThread
- func MakePatternRaverPlaid(locations []float64) ByteThread
- func MakePatternSailorMoon(locations []float64) ByteThread
- func MakePatternShield(locations []float64) ByteThread
- func MakePatternSpatialColorBox(locations []float64) ByteThread
- func MakePatternSpatialStripes(locations []float64) ByteThread
- func MakePatternSquare(locations []float64) ByteThread
- func MakePatternSunset(locations []float64) ByteThread
- func MakePatternTest(locations []float64) ByteThread
- func MakePatternTestGamma(locations []float64) ByteThread
- func MakePatternTestRGB(locations []float64) ByteThread
- func MakePatternWhite(locations []float64) ByteThread
- func MakeSendToDevNullThread() ByteThread
- func MakeSendToLPD8806Thread(spiFn string) ByteThread
- func MakeSendToOpcThread(ipPort string) ByteThread
- func MakeSendToScreenThread() ByteThread
- type MyColor
- type MyImage
- type OpcMessage
Constants ¶
const CONNECTION_TRIES = 1 // milliseconds
const GAMMA = 2.2
Gamma for LPD chipset
const SPI_CHUNK_SIZE = 2048
How many bytes can be written to the SPI bus at once?
const WAIT_BETWEEN_RETRIES = 1 // milliseconds
const WAIT_TO_RETRY = 1000 // milliseconds
Variables ¶
var PATTERN_REGISTRY map[string](func(locations []float64) ByteThread)
Functions ¶
func LaunchOpcServer ¶
func LaunchOpcServer(ipPort string) chan *OpcMessage
Launch the OPC server in its own goroutine and return the channel over which it will push incoming OPC messages.
func OpcServerThread ¶
func OpcServerThread(ipPort string, incomingOpcMessageChan chan *OpcMessage)
Start a server at ipPort (or, for example, ":7890") and push received *OpcMessage pointers over the incomingOpcMessageChan. You should launch this in its own goroutine.
func ReadLocations ¶
Read locations from OPC-style JSON layout file into a slice of floats
Types ¶
type ByteThread ¶
Most of this library is built from ByteThread functions which you can string together via channels. These are meant to be run as goroutines. They read in one byte slice at a time through the input channel, do something to it, then return it over the output channel when done. These are used both for sources and destinations of pixel data. They should loop forever until the input channel is closed, then return. The byte slice should hold values from 0 to 255 in [r g b r g b r g b ... ] order so its total length is 3 times the number of pixels in the LED strip. The MidiState object is shared with other threads and should be treated as read-only. It will be updated during the time when the ByteThread is not holding a byte slice.
func MakeEffectFader ¶
func MakeEffectFader(locations []float64) ByteThread
func MakeOpcServerThread ¶
func MakeOpcServerThread(ipPort string) ByteThread
Return a ByteThread function which will start an OPC server and push out pixels from it in the usual way ByteThreads do. The channel field is ignored, so if you're piping OPC In to OPC Out be aware that the channel will be set to zero in the process. Only pays attention to OPC messages with command 0 (set pixels).
func MakePatternAqua ¶
func MakePatternAqua(locations []float64) ByteThread
func MakePatternAquaB ¶
func MakePatternAquaB(locations []float64) ByteThread
func MakePatternArchimedes ¶
func MakePatternArchimedes(locations []float64) ByteThread
func MakePatternBasicMidi ¶
func MakePatternBasicMidi(locations []float64) ByteThread
func MakePatternDiamond ¶
func MakePatternDiamond(locations []float64) ByteThread
func MakePatternEye ¶
func MakePatternEye(locations []float64) ByteThread
func MakePatternFire ¶
func MakePatternFire(locations []float64) ByteThread
func MakePatternHousePotty ¶
func MakePatternHousePotty(locations []float64) ByteThread
This obnoxious function only exists because ByteThread is an opc type and thus cannot be referenced from potty without creating a dependecy cycle.
func MakePatternJapan ¶
func MakePatternJapan(locations []float64) ByteThread
func MakePatternMidiSwitcher ¶
func MakePatternMidiSwitcher(locations []float64) ByteThread
func MakePatternMoire ¶
func MakePatternMoire(locations []float64) ByteThread
func MakePatternOff ¶
func MakePatternOff(locations []float64) ByteThread
func MakePatternRaverPlaid ¶
func MakePatternRaverPlaid(locations []float64) ByteThread
func MakePatternSailorMoon ¶
func MakePatternSailorMoon(locations []float64) ByteThread
func MakePatternShield ¶
func MakePatternShield(locations []float64) ByteThread
func MakePatternSpatialColorBox ¶
func MakePatternSpatialColorBox(locations []float64) ByteThread
func MakePatternSpatialStripes ¶
func MakePatternSpatialStripes(locations []float64) ByteThread
func MakePatternSquare ¶
func MakePatternSquare(locations []float64) ByteThread
func MakePatternSunset ¶
func MakePatternSunset(locations []float64) ByteThread
func MakePatternTest ¶
func MakePatternTest(locations []float64) ByteThread
func MakePatternTestGamma ¶
func MakePatternTestGamma(locations []float64) ByteThread
func MakePatternTestRGB ¶
func MakePatternTestRGB(locations []float64) ByteThread
func MakePatternWhite ¶
func MakePatternWhite(locations []float64) ByteThread
func MakeSendToDevNullThread ¶
func MakeSendToDevNullThread() ByteThread
Return a ByteThread which passes byte slices from the input to the output channels without doing anything.
func MakeSendToLPD8806Thread ¶
func MakeSendToLPD8806Thread(spiFn string) ByteThread
Return a ByteThread which writes bytes to SPI via the given filename (such as "/dev/spidev1.0"). Format the outgoing bytes for LED strips which use the LPD8806 chipset. If the SPI device can't be opened, exit the whole program with exit status 1. This chipset expects colors in G R B order; this function is responsible for swapping from the usual R G B order.
func MakeSendToOpcThread ¶
func MakeSendToOpcThread(ipPort string) ByteThread
Return a ByteThread which sends the bytes out as OPC messages to the given ipPort. Create OPC headers for each byte slice it sends. Initiate and maintains a long-lived connection to ipPort. If the connection is bad at any point (or was never good to begin with), keep trying to reconnect whenever new bytes come in. Can sleep for WAIT_TO_RETRY during reconnection attempts; this blocks the input channel. Silently drop bytes if it's not possible to send them.
func MakeSendToScreenThread ¶
func MakeSendToScreenThread() ByteThread
Return a ByteThread which prints the bytes to the screen.
type OpcMessage ¶
A single OPC message
Source Files ¶
- effect-fader.go
- opc.go
- pattern-aqua.go
- pattern-aquab.go
- pattern-archimedes.go
- pattern-basic-midi.go
- pattern-colorbox.go
- pattern-diamond.go
- pattern-eye.go
- pattern-fire.go
- pattern-japan.go
- pattern-midi-switcher.go
- pattern-moire.go
- pattern-off.go
- pattern-potty.go
- pattern-raver-plaid.go
- pattern-sailor-moon.go
- pattern-shield.go
- pattern-spatial-stripes.go
- pattern-square.go
- pattern-sunset.go
- pattern-test-gamma.go
- pattern-test-rgb.go
- pattern-test.go
- pattern-white.go