2014-11-30 03:02:10 +08:00
|
|
|
package gpio
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2015-01-03 02:42:53 +08:00
|
|
|
// ErrServoWriteUnsupported is the error resulting when a driver attempts to use
|
|
|
|
// hardware capabilities which a connection does not support
|
|
|
|
ErrServoWriteUnsupported = errors.New("ServoWrite is not supported by this platform")
|
|
|
|
// ErrPwmWriteUnsupported is the error resulting when a driver attempts to use
|
|
|
|
// hardware capabilities which a connection does not support
|
|
|
|
ErrPwmWriteUnsupported = errors.New("PwmWrite is not supported by this platform")
|
|
|
|
// ErrAnalogReadUnsupported is error resulting when a driver attempts to use
|
|
|
|
// hardware capabilities which a connection does not support
|
|
|
|
ErrAnalogReadUnsupported = errors.New("AnalogRead is not supported by this platform")
|
|
|
|
// ErrDigitalWriteUnsupported is the error resulting when a driver attempts to use
|
|
|
|
// hardware capabilities which a connection does not support
|
2014-11-30 03:02:10 +08:00
|
|
|
ErrDigitalWriteUnsupported = errors.New("DigitalWrite is not supported by this platform")
|
2015-01-03 02:42:53 +08:00
|
|
|
// ErrDigitalReadUnsupported is the error resulting when a driver attempts to use
|
|
|
|
// hardware capabilities which a connection does not support
|
|
|
|
ErrDigitalReadUnsupported = errors.New("DigitalRead is not supported by this platform")
|
|
|
|
// ErrServoOutOfRange is the error resulting when a driver attempts to use
|
|
|
|
// hardware capabilities which a connection does not support
|
|
|
|
ErrServoOutOfRange = errors.New("servo angle must be between 0-180")
|
2014-11-30 03:02:10 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2015-01-03 02:42:53 +08:00
|
|
|
// Release event
|
2014-11-30 03:02:10 +08:00
|
|
|
Release = "release"
|
2015-01-03 02:42:53 +08:00
|
|
|
// Push event
|
|
|
|
Push = "push"
|
|
|
|
// Error event
|
|
|
|
Error = "error"
|
|
|
|
// Data event
|
|
|
|
Data = "data"
|
2014-11-30 03:02:10 +08:00
|
|
|
)
|
|
|
|
|
2015-01-03 02:42:53 +08:00
|
|
|
// PwmWriter interface represents an Adaptor which has Pwm capabilities
|
2014-11-30 03:02:10 +08:00
|
|
|
type PwmWriter interface {
|
|
|
|
gobot.Adaptor
|
|
|
|
PwmWrite(string, byte) (err error)
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:42:53 +08:00
|
|
|
// ServoWriter interface represents an Adaptor which has Servo capabilities
|
2014-11-30 03:02:10 +08:00
|
|
|
type ServoWriter interface {
|
|
|
|
gobot.Adaptor
|
|
|
|
ServoWrite(string, byte) (err error)
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:42:53 +08:00
|
|
|
// AnalogReader interface represents an Adaptor which has Analog capabilities
|
2014-11-30 03:02:10 +08:00
|
|
|
type AnalogReader interface {
|
|
|
|
gobot.Adaptor
|
|
|
|
AnalogRead(string) (val int, err error)
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:42:53 +08:00
|
|
|
// DigitalWriter interface represents an Adaptor which has DigitalWrite capabilities
|
2014-11-30 03:02:10 +08:00
|
|
|
type DigitalWriter interface {
|
|
|
|
gobot.Adaptor
|
|
|
|
DigitalWrite(string, byte) (err error)
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:42:53 +08:00
|
|
|
// DigitalReader interface represents an Adaptor which has DigitalRead capabilities
|
2014-11-30 03:02:10 +08:00
|
|
|
type DigitalReader interface {
|
|
|
|
gobot.Adaptor
|
|
|
|
DigitalRead(string) (val int, err error)
|
|
|
|
}
|