Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type DeviceGPIO ¶
DeviceGPIO satisfies the Device interface and the GPIO Pin interface
func NewDeviceGPIO ¶
func NewDeviceGPIO(name string, idx int, mode Mode, opts ...gpiocdev.LineReqOption) *DeviceGPIO
NewDeviceGPIO creates a GPIO based device associated with GPIO Pin idx with the corresponding gpiocdev.LineReqOptions. If there is an gpiocdev.EventHandler an Event Q channel will be created. Also a publication topic will be associated. For input devices the Pubs will be used to publish output state to the device. For output devices the Pubs will be used to publish the latest data collected
func (*DeviceGPIO) Set ¶
func (d *DeviceGPIO) Set(v int)
Set the output state of the pin to the value of v Off(0) or On != 0
type DeviceManager ¶
type DeviceManager struct {
// contains filtered or unexported fields
}
func GetDeviceManager ¶
func GetDeviceManager() *DeviceManager
func (*DeviceManager) Add ¶
func (dm *DeviceManager) Add(d *Device)
func (*DeviceManager) Get ¶
func (dm *DeviceManager) Get(name string) *Device
type GPIO ¶
type GPIO struct { Chipname string `json:"chipname"` Pins map[int]*Pin `json:"pins"` Mock bool `json:"mock"` }
GPIO is used to initialize the GPIO and pins on a raspberry pi
type Line ¶
type Line interface { Close() error Offset() int SetValue(int) error Reconfigure(...gpiocdev.LineConfigOption) error Value() (int, error) }
Line interface is used to emulate a GPIO pin as implemented by the go-gpiocdev package
type MockLine ¶
type MockLine struct { Val int `json:"val"` gpiocdev.EventHandler `json:"event-handler"` // contains filtered or unexported fields }
MockGPIO fakes the Line interface on computers that don't actually have GPIO pins mostly for mocking tests
func GetMockLine ¶
func (*MockLine) MockHWInput ¶
func (MockLine) Reconfigure ¶
type Pin ¶
type Pin struct { Opts []gpiocdev.LineReqOption Line // contains filtered or unexported fields }
Pin represents a single GPIO Pin
func (Pin) Callback ¶
Callback is the default callback for pins if they are registered with the MQTT.Subscribe() function
func (*Pin) Get ¶
Get returns the value of the pin, an error is returned if the GPIO value fails. Note: you can Get() the value of an input pin so no direction checks are done
func (*Pin) Set ¶
Set the value of the pin. Note: you can NOT set the value of an input pin, so we will check it and return an error. This maybe worthy of making it a panic!