Documentation ¶
Overview ¶
Package hal defines the interfaces for implementing a driver in reef-pi
Index ¶
- func ConvertToInt(val interface{}) (int, bool)
- func NewDigitalNoopPin() *noopDigitalPin
- func ToErrorString(failures map[string][]string) string
- type AnalogInputDriver
- type AnalogInputPin
- type Calibrator
- type Capability
- type ConfigParameter
- type ConfigParameterType
- type DigitalInputDriver
- type DigitalInputPin
- type DigitalOutputDriver
- type DigitalOutputPin
- type Driver
- type DriverFactory
- type Measurement
- type Metadata
- type PWMChannel
- type PWMDriver
- type Pin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToInt ¶
ConvertToInt converts an interface to int if possible.
func NewDigitalNoopPin ¶
func NewDigitalNoopPin() *noopDigitalPin
func ToErrorString ¶
ToErrorString converts a map of failures to a single string
Types ¶
type AnalogInputDriver ¶
type AnalogInputDriver interface { Driver AnalogInputPins() []AnalogInputPin AnalogInputPin(int) (AnalogInputPin, error) }
type AnalogInputPin ¶
type Calibrator ¶
func CalibratorFactory ¶
func CalibratorFactory(points []Measurement) (Calibrator, error)
type Capability ¶
type Capability int
Capability represents the capabilities of a driver
const ( None Capability = iota DigitalInput DigitalOutput PWM AnalogInput )
func (Capability) String ¶
func (c Capability) String() string
type ConfigParameter ¶
type ConfigParameter struct { Name string `json:"name"` Type ConfigParameterType `json:"type"` Order int `json:"order"` Default interface{} `json:"default"` }
ConfigParameter represent a configuration parameter required by a driver
type ConfigParameterType ¶
type ConfigParameterType int
ConfigParameterType indicates the type of a configuration parameter
const ( String ConfigParameterType = iota + 1 Integer Decimal Boolean )
type DigitalInputDriver ¶
type DigitalInputDriver interface { Driver DigitalInputPins() []DigitalInputPin DigitalInputPin(int) (DigitalInputPin, error) }
type DigitalInputPin ¶
type DigitalInputPin interface { Pin // Read returns whether this input is logical high (true) or low (false) Read() (bool, error) }
InputPin represents an input pin with a single digital input value.
type DigitalOutputDriver ¶
type DigitalOutputDriver interface { Driver DigitalOutputPins() []DigitalOutputPin DigitalOutputPin(int) (DigitalOutputPin, error) }
type DigitalOutputPin ¶
type DriverFactory ¶
type DriverFactory interface { //GetParameters returns the parameters that the driver expects. GetParameters() []ConfigParameter //ValidateParameters validates the parameters for a driver. //The boolean result is true if the parameters are valid (and the array of failure messages should be nil or empty). //The array of failures should contain all of the validation errors. It should not short circuit after the first failure. ValidateParameters(parameters map[string]interface{}) (bool, map[string][]string) //Metadata returns the Metadata the driver can provide. Metadata() Metadata //CreateDriver validates the parameters and returns the driver if validation succeeds. NewDriver(parameters map[string]interface{}, hardwareResources interface{}) (Driver, error) }
DriverFactory is responsible for creating drivers and providing information about a driver.
func NoopFactory ¶
func NoopFactory() DriverFactory
NoopFactory provides the factory to get NoopDriver parameters and NoopDrivers
type Measurement ¶
type Metadata ¶
type Metadata struct { Name string `json:"name"` Description string `json:"description"` Capabilities []Capability `json:"capabilities"` }
Metadata represents basic information about a driver for the API response.
func (Metadata) HasCapability ¶
func (m Metadata) HasCapability(cap Capability) bool
type PWMChannel ¶
type PWMChannel interface { DigitalOutputPin Set(value float64) error }
type PWMDriver ¶
type PWMDriver interface { DigitalOutputDriver PWMChannels() []PWMChannel PWMChannel(int) (PWMChannel, error) }