Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is the primary struct for interacting with the Button SHIM device.
func New ¶
New returns a new Button SHIM hardware driver. The driver encapsulates a set of buttons and a single RGB LED, handling interaction with the actual device. Connects to the device on the given I2C bus at its standard address.
func NewWithConn ¶
NewWithConn returns a new Button SHIM hardware driver, using the given periph.io conn.Conn object. Typically New should be used instead, but this may be useful for testing using mocks, or a custom I2C connection with a different address than the default.
func (*Driver) ButtonPressChan ¶
ButtonPressChan returns a new receive channel that can be used to handle press events for a specific button. The actual message carries no payload - use it as a signalling mechanism only. For example:
pressA := shim.ButtonPressChan(buttonshim.ButtonA) pressB := shim.ButtonPressChan(buttonshim.ButtonB) go func() { for { select { case <-pressA: fmt.Println("Button A pressed!") case <-pressB: fmt.Println("Button B pressed!") } } }()
func (*Driver) ButtonReleaseChan ¶
ButtonReleaseChan returns a new receive channel that can be used to handle release events for a specific button. The actual message indicates the final duration that the button was observed as being pressed for. The accuracy of this value is limited by the poll rate.
func (*Driver) SetBrightness ¶
SetBrightness sets the brightness of the pixel.
type Option ¶
type Option func(*options)
Option allows specifying behavior for the driver.
func WithButtonPollInterval ¶
WithButtonPollInterval allows modifying the button poll interval. A longer interval will use fewer system resources, but risks not registering a fast button press. Default 50ms.