Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalogDevice ¶ added in v0.0.7
func NewAnalogDevice ¶ added in v0.0.7
func NewAnalogDevice(name string, pin int) *AnalogDevice
type AnalogPin ¶ added in v0.0.7
type AnalogPin struct {
// contains filtered or unexported fields
}
func NewAnalogPin ¶ added in v0.0.7
type Device ¶
type Device struct { Name string Pub string Subs []string Mode Period time.Duration EvtQ chan gpiocdev.LineEvent }
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
func GetMockGPIO ¶ added in v0.0.7
func GetMockGPIO() *GPIO
type GPIODevice ¶ added in v0.0.7
GPIODevice satisfies the Device interface and the GPIO Pin interface
func NewGPIODevice ¶ added in v0.0.7
func NewGPIODevice(name string, idx int, mode Mode, opts ...gpiocdev.LineReqOption) *GPIODevice
NewGPIODevice 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 (*GPIODevice) Off ¶ added in v0.0.7
func (d *GPIODevice) Off()
Off sets the output state of the Pin to OFF (0)
func (*GPIODevice) On ¶ added in v0.0.7
func (d *GPIODevice) On()
On sets the output state of the Pin to ON (1)
func (*GPIODevice) Set ¶ added in v0.0.7
func (d *GPIODevice) Set(v int)
Set the output state of the pin to the value of v Off(0) or On != 0
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!
type SerialDevice ¶ added in v0.0.6
func NewSerialDevice ¶ added in v0.0.6
func NewSerialDevice(name, port string, baud int) *SerialDevice
func (*SerialDevice) Open ¶ added in v0.0.6
func (s *SerialDevice) Open() (err error)