Documentation
¶
Index ¶
- Constants
- Variables
- func Connect(dev *usb.Device, options ...Option) (d *connection, err error)
- func Greeter(dev Device)
- func Marquee(m Device, s string, dur time.Duration) error
- func NumButtons(dev Device) uint8
- func Print(m Device, s string, dur time.Duration) error
- func PrintUSBDevice(dev *usb.Device)
- func SwitchAll(m Device, on bool) error
- func USBDevices(vendor_id, product_id string) ([]*usb.Device, error)
- type CloseError
- type ConnectError
- type Connection
- type ConnectionClosedError
- type Device
- type Error
- type Errors
- type Handler
- type HandlerFunc
- type Option
- type ReadError
- type Tester
- type UnknownMonomeError
Constants ¶
const ( VENDOR_ID = "0403" PRODUCT_ID = "6001" )
Variables ¶
var LetterWidth = map[rune]int{}
var Letters = map[rune]map[[2]uint8]bool{}
add your own letters as you like
var USBAccessError = fmt.Errorf("USB stack could not be opened. Probably missing rights. Try to run as admin.")
Functions ¶
func Connect ¶ added in v0.0.7
Connect returns a new Connection to the given usb.Device. Normally New should not be called directly, but Devices instead (which make use of New).
func Greeter ¶ added in v0.0.7
func Greeter(dev Device)
Greeter prints the name of the device on the device, followed by a flash
func Marquee ¶ added in v0.0.7
Marquee shows the given string in a marquee-like manner (from left to right)
func NumButtons ¶ added in v0.0.7
NumButtons returns the available number of buttons
func PrintUSBDevice ¶ added in v0.0.2
Types ¶
type CloseError ¶ added in v0.0.2
func (CloseError) Error ¶ added in v0.0.2
func (e CloseError) Error() string
type ConnectError ¶ added in v0.0.2
type ConnectError struct {
USBDevice *usb.Device
USBEndPoint struct {
Purpose string
Number int
Config uint8
Interface uint8
Setup uint8
Info usb.EndpointInfo
}
WrappedError error
}
func (*ConnectError) Error ¶ added in v0.0.2
func (m *ConnectError) Error() string
type Connection ¶ added in v0.0.7
type Connection interface {
// Close closes the connection to the monome
Close() error
// IsClosed returns wether the connection is closed
IsClosed() bool
// SetHandler set the active handler for the device
SetHandler(Handler)
// StartListering starts listening for button events. For errors the given errHandler is called
StartListening(errHandler func(error))
// StopListening stops listening for button events
StopListening()
Device
}
Connection is a connection to a monome device
func Connections ¶ added in v0.0.7
func Connections(options ...Option) ([]Connection, error)
Connections returns all connections that could be made to attached monome devices.
func RowConnection ¶ added in v0.0.7
func RowConnection(name string, connections ...Connection) Connection
RowConnection creates a unified connection out of a row of connections. The order is from left to right. The number of columns is the sum of the columns of the devices. The number of rows is the smallest number of rows of any device.
func TestDevice ¶ added in v0.0.2
func TestDevice(tester Tester, options ...Option) Connection
TestDevice returns a new (fake) monome device, based on the given tester
type ConnectionClosedError ¶ added in v0.0.3
type ConnectionClosedError string
func (ConnectionClosedError) Error ¶ added in v0.0.3
func (c ConnectionClosedError) Error() string
type Device ¶
type Device interface {
// Rows returns the number of rows
Rows() uint8
// Cols returns the number of cols
Cols() uint8
// Set sets the button at position x,y to the given brightness
// If the connection has been closed, nothing is sent
// From the monome docs about brightness levels:
// [0, 3] - off
// [4, 7] - low intensity
// [8, 11] - medium intensity
// [12, 15] - high intensity
// June 2012 devices allow the full 16 intensity levels.
Set(x, y, brightness uint8) error
// Switches the light at x,y on or off
// Switches the light at x,y on or off
// If on is true, it is a shortcut for Set(x,y,15).
// If on is false it is a shortcut for Set(x,y,0)
Switch(x, y uint8, on bool) error
// String returns an identifier as a string (name)
String() string
// ReadMessage reads a message from the device and calls the handler if necessary
// It should normally not be called and is just there to allow external implementations of Device
ReadMessage() error
}
type Handler ¶
type Handler interface {
// Handle is the callback that is called if a button is pressed (down=true)
// or released (down=false)
Handle(d Connection, x, y uint8, down bool)
}
Handler responds to a pressing or releasing action on a button
type HandlerFunc ¶
type HandlerFunc func(d Connection, x, y uint8, down bool)
HandlerFunc is a function that acts as a Handler
func (HandlerFunc) Handle ¶
func (h HandlerFunc) Handle(d Connection, x, y uint8, down bool)
type Tester ¶ added in v0.0.2
type Tester interface {
Get() (x, y uint8, down bool, err error)
Set(x, y, brightness uint8) error
Name() string
Cols() uint8
Rows() uint8
io.Closer
}
func CloseTester ¶ added in v0.0.2
CloseTester returns a Tester tailored for testing the closing of the device
type UnknownMonomeError ¶ added in v0.0.2
type UnknownMonomeError struct {
Response []byte
USBDevice *usb.Device
USBWriterEndPoint usb.EndpointInfo
USBReaderEndPoint usb.EndpointInfo
}
func (*UnknownMonomeError) Error ¶ added in v0.0.2
func (e *UnknownMonomeError) Error() string
