opc

package
v0.0.0-...-1d53b04 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package opc helps you send and receive Open Pixel Control messages.

Index

Constants

View Source
const CONNECTION_TRIES = 1 // milliseconds
View Source
const GAMMA = 2.2

Gamma for LPD chipset

View Source
const SPI_CHUNK_SIZE = 2048

How many bytes can be written to the SPI bus at once?

View Source
const WAIT_BETWEEN_RETRIES = 1 // milliseconds
View Source
const WAIT_TO_RETRY = 1000 // milliseconds

Variables

View Source
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

func ReadLocations(fn string) []float64

Read locations from OPC-style JSON layout file into a slice of floats

Types

type ByteThread

type ByteThread func(chan []byte, chan []byte, *midi.MidiState)

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 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 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 MakePatternSpatialStripes

func MakePatternSpatialStripes(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 MyColor

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

type MyImage

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

func (*MyImage) String

func (mi *MyImage) String() string

type OpcMessage

type OpcMessage struct {
	Channel byte
	Command byte
	Bytes   []byte
}

A single OPC message

Jump to

Keyboard shortcuts

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