Documentation ¶
Overview ¶
Package monome implements an OSC interfaces to monome devices from monome.org
Example ¶
keyEvents := make(chan KeyEvent) device, err := Connect("/hello", keyEvents) if err != nil { log.Fatal(err) } defer device.Close() fmt.Printf("Connected to monome id: %s, prefix: %s, width: %d, height: %d, rotation: %d\n", device.Id(), device.Prefix(), device.Width(), device.Height(), device.Rotation()) for e := range keyEvents { fmt.Printf("%+v\n", e) device.LEDSet(e.X, e.Y, e.State) }
Output:
Index ¶
- Variables
- type DeviceEvent
- type Grid
- func (c Grid) Close() error
- func (g *Grid) Height() int
- func (c Grid) HostPort() (string, int)
- func (g *Grid) Id() string
- func (g *Grid) LEDAll(state int) error
- func (g *Grid) LEDCol(x, yOffset int, states ...byte) error
- func (g *Grid) LEDIntensity(i int) error
- func (g *Grid) LEDLevelAll(level int) error
- func (g *Grid) LEDLevelCol(x, yOffset int, levels []int) error
- func (g *Grid) LEDLevelMap(xOffset, yOffset int, levels [64]int) error
- func (g *Grid) LEDLevelRow(xOffset, y int, levels []int) error
- func (g *Grid) LEDLevelSet(x, y, level int) error
- func (g *Grid) LEDMap(xOffset, yOffset int, states [8]byte) error
- func (g *Grid) LEDRow(xOffset, y int, states ...byte) error
- func (g *Grid) LEDSet(x, y, state int) error
- func (g *Grid) Prefix() string
- func (g *Grid) Rotation() int
- func (g *Grid) Width() int
- type KeyEvent
- type LEDBuffer
- func (b *LEDBuffer) GetIndexFromXY(x, y int) int
- func (b *LEDBuffer) GetXYFromIndex(i int) []int
- func (b *LEDBuffer) LEDAll(state int) error
- func (b *LEDBuffer) LEDCol(x, yOffset int, states ...byte) error
- func (b *LEDBuffer) LEDLevelAll(level int) error
- func (b *LEDBuffer) LEDLevelCol(x, yOffset int, levels []int) error
- func (b *LEDBuffer) LEDLevelMap(xOffset, yOffset int, levels [64]int) error
- func (b *LEDBuffer) LEDLevelMapAll(levels []int) error
- func (b *LEDBuffer) LEDLevelRow(xOffset, y int, levels []int) error
- func (b *LEDBuffer) LEDLevelSet(x, y, level int) error
- func (b *LEDBuffer) LEDMap(xOffset, yOffset int, states [8]byte) error
- func (b *LEDBuffer) LEDRow(xOffset, y int, states ...byte) error
- func (b *LEDBuffer) LEDSet(x, y, state int) error
- func (b *LEDBuffer) Render(g *Grid) error
- type SerialOsc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ConnectTimeout sets the timeout used by the Connect function. // It should not need to be changed in most cases. ConnectTimeout = 5 * time.Second // ErrTimeout is returned when the connection to a device cannot be established. ErrTimeout = errors.New("connection timed out") )
Functions ¶
This section is empty.
Types ¶
type DeviceEvent ¶
type DeviceEvent struct { Id string Type string Port int Removed bool // True if the device is being disconnected, otherwise false. }
A DeviceEvent is a Monome device connection or disconnection event.
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid represents a connection to a Monome device via SerialOsc.
func Connect ¶
Connect is a utility method that establishes a connection to the first monome device it finds. The device sends key events to the given channel. It returns ErrTimeout if it can't connec to a device.
func DialGrid ¶
DialGrid connects to a Monome device using the given address. The address is obtained from SerialOsc running on the local machine. prefix is the OSC address prefix to be used by the local OSC server. If an empty prefix is given, it defaults to /gopher. KeyEvents which are received will be sent in to the given events channel.
func (*Grid) LEDCol ¶
LEDCol sets a 1x8 col based on a y offset, an x row and an 8 bit bitmask. (0-255) The states bitmask represents the on/off states of the items in the column
func (*Grid) LEDIntensity ¶
LEDIntensity sets the intensity of the grid LEDs.
func (*Grid) LEDLevelAll ¶
LEDLevelAll sets the level of all LEDs.
func (*Grid) LEDLevelCol ¶
LEDLevelRow is like LEDCol but with control over the level.
func (*Grid) LEDLevelMap ¶
LEDLevelMap is like LEDMap but with control over the level.
func (*Grid) LEDLevelRow ¶
LEDLevelRow is like LEDRow but with control over the level.
func (*Grid) LEDLevelSet ¶
LEDLevel sets the level of the LED at coordinates x, y. The value of level must be in the range [0, 15].
func (*Grid) LEDMap ¶
LEDMap sets an 8x8 grid of LEDs on the monome to the given states. The states are a bitmask with each byte representing one row and each bit representing the state of an LED in that row. xOffset and yOffset must be multiples of 8.
func (*Grid) LEDRow ¶
LEDRow sets a 8x1 row based on an x offset, a y row and a bitmask. (0-255) The states bitmask represents the on/off states of the items in the row
func (*Grid) LEDSet ¶
LEDSet sets the LED at (x, y) to the given state. State must be 1 for on or 0 for off.
func (*Grid) Prefix ¶
Prefix returns the OSC prefinx being used in communication with the connected Monome device.
type LEDBuffer ¶
type LEDBuffer struct { Buf []int // contains filtered or unexported fields }
LEDBuffer can be used to buffer LED changes to a grid. It supports all the same LED operations as a Grid, but doesn't send anything until buffer.Render() is called.
func NewLEDBuffer ¶
Creates a new LEDBuffer with exposed .Buf value for direct manipulation. Requires width and height to calculate size.
func (*LEDBuffer) GetIndexFromXY ¶
Returns the index of the LEDBuffer given x and y coordinates
func (*LEDBuffer) GetXYFromIndex ¶
Returns the x and y coortinate values given an LEDBuffer index
func (*LEDBuffer) LEDLevelAll ¶
Writes a single varibright level values 0-15 to an LEDBuffer
func (*LEDBuffer) LEDLevelCol ¶
Writes a column of data to a LEDBuffer, uses varibright levels 0-15
func (*LEDBuffer) LEDLevelMap ¶
Writes an 8x8 quadrant of varibright values to an LEDBuffer, values 0-15
func (*LEDBuffer) LEDLevelMapAll ¶
Similar to LEDLevelMap but can map LEDBuffer to arbitrary size of device, sice should contain enough values for target grid takes varibright level values 0-15
func (*LEDBuffer) LEDLevelRow ¶
Writes a row of data to a LEDBuffer, uses varibright levels 0-15
func (*LEDBuffer) LEDLevelSet ¶
Writes a single led value at x,y with varibright level values 0-15 to an LEDBuffer
func (*LEDBuffer) LEDMap ¶
Writes an 8x8 quadrant of grid values to an LEDBuffer states accepts a bitmask for each row of the quadrant
type SerialOsc ¶
type SerialOsc struct {
// contains filtered or unexported fields
}
SerialOsc represents an OSC connection to the monome "serialosc" application.
func DialSerialOsc ¶
func DialSerialOsc(address string, events chan DeviceEvent) (*SerialOsc, error)
DialSerialOsc creates a connection to a serialosc instance at the given address. If an empty address is given it defaults to localhost:12002 Device add and remove events are sent to the given channel.