2015-06-30 09:01:35 +08:00
|
|
|
package gpio
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2015-10-23 07:56:03 +08:00
|
|
|
// GroveRelayDriver represents a Relay with a Grove connector
|
2015-06-30 09:01:35 +08:00
|
|
|
type GroveRelayDriver struct {
|
|
|
|
*RelayDriver
|
|
|
|
}
|
|
|
|
|
2016-09-25 19:36:18 +08:00
|
|
|
// NewGroveRelayDriver return a new GroveRelayDriver given a DigitalWriter and pin.
|
2015-10-23 07:56:03 +08:00
|
|
|
//
|
|
|
|
// Adds the following API Commands:
|
|
|
|
// "Toggle" - See RelayDriver.Toggle
|
|
|
|
// "On" - See RelayDriver.On
|
|
|
|
// "Off" - See RelayDriver.Off
|
2016-09-25 19:36:18 +08:00
|
|
|
func NewGroveRelayDriver(a DigitalWriter, pin string) *GroveRelayDriver {
|
2015-10-23 07:56:03 +08:00
|
|
|
return &GroveRelayDriver{
|
2016-09-25 19:36:18 +08:00
|
|
|
RelayDriver: NewRelayDriver(a, pin),
|
2015-10-23 07:56:03 +08:00
|
|
|
}
|
2015-06-30 09:01:35 +08:00
|
|
|
}
|
|
|
|
|
2015-10-23 07:56:03 +08:00
|
|
|
// GroveLedDriver represents an LED with a Grove connector
|
|
|
|
type GroveLedDriver struct {
|
|
|
|
*LedDriver
|
2015-06-30 09:01:35 +08:00
|
|
|
}
|
|
|
|
|
2016-09-25 19:36:18 +08:00
|
|
|
// NewGroveLedDriver return a new GroveLedDriver given a DigitalWriter and pin.
|
2015-10-23 07:56:03 +08:00
|
|
|
//
|
|
|
|
// Adds the following API Commands:
|
|
|
|
// "Brightness" - See LedDriver.Brightness
|
|
|
|
// "Toggle" - See LedDriver.Toggle
|
|
|
|
// "On" - See LedDriver.On
|
|
|
|
// "Off" - See LedDriver.Off
|
2016-09-25 19:36:18 +08:00
|
|
|
func NewGroveLedDriver(a DigitalWriter, pin string) *GroveLedDriver {
|
2015-06-30 09:01:35 +08:00
|
|
|
return &GroveLedDriver{
|
2016-09-25 19:36:18 +08:00
|
|
|
LedDriver: NewLedDriver(a, pin),
|
2015-06-30 09:01:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-23 07:56:03 +08:00
|
|
|
// GroveBuzzerDriver represents a buzzer
|
|
|
|
// with a Grove connector
|
|
|
|
type GroveBuzzerDriver struct {
|
|
|
|
*BuzzerDriver
|
|
|
|
}
|
|
|
|
|
2016-09-25 19:36:18 +08:00
|
|
|
// NewGroveBuzzerDriver return a new GroveBuzzerDriver given a DigitalWriter and pin.
|
|
|
|
func NewGroveBuzzerDriver(a DigitalWriter, pin string) *GroveBuzzerDriver {
|
2015-10-23 07:56:03 +08:00
|
|
|
return &GroveBuzzerDriver{
|
2016-09-25 19:36:18 +08:00
|
|
|
BuzzerDriver: NewBuzzerDriver(a, pin),
|
2015-10-23 07:56:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GroveButtonDriver represents a button sensor
|
|
|
|
// with a Grove connector
|
|
|
|
type GroveButtonDriver struct {
|
|
|
|
*ButtonDriver
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewGroveButtonDriver returns a new GroveButtonDriver with a polling interval of
|
2016-09-25 19:36:18 +08:00
|
|
|
// 10 Milliseconds given a DigitalReader and pin.
|
2015-10-23 07:56:03 +08:00
|
|
|
//
|
2016-07-14 00:44:47 +08:00
|
|
|
// Optionally accepts:
|
2015-10-23 07:56:03 +08:00
|
|
|
// time.Duration: Interval at which the ButtonDriver is polled for new information
|
2016-09-25 19:36:18 +08:00
|
|
|
func NewGroveButtonDriver(a DigitalReader, pin string, v ...time.Duration) *GroveButtonDriver {
|
2015-10-23 07:56:03 +08:00
|
|
|
return &GroveButtonDriver{
|
2016-09-25 19:36:18 +08:00
|
|
|
ButtonDriver: NewButtonDriver(a, pin, v...),
|
2015-10-23 07:56:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GroveTouchDriver represents a touch button sensor
|
|
|
|
// with a Grove connector
|
|
|
|
type GroveTouchDriver struct {
|
|
|
|
*ButtonDriver
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewGroveTouchDriver returns a new GroveTouchDriver with a polling interval of
|
2016-09-25 19:36:18 +08:00
|
|
|
// 10 Milliseconds given a DigitalReader and pin.
|
2015-10-23 07:56:03 +08:00
|
|
|
//
|
2016-07-14 00:44:47 +08:00
|
|
|
// Optionally accepts:
|
2015-10-23 07:56:03 +08:00
|
|
|
// time.Duration: Interval at which the ButtonDriver is polled for new information
|
2016-09-25 19:36:18 +08:00
|
|
|
func NewGroveTouchDriver(a DigitalReader, pin string, v ...time.Duration) *GroveTouchDriver {
|
2015-10-23 07:56:03 +08:00
|
|
|
return &GroveTouchDriver{
|
2016-09-25 19:36:18 +08:00
|
|
|
ButtonDriver: NewButtonDriver(a, pin, v...),
|
2015-10-23 07:56:03 +08:00
|
|
|
}
|
|
|
|
}
|
2016-10-27 13:20:43 +08:00
|
|
|
|
|
|
|
// GroveMagneticSwitchDriver represent a magnetic
|
|
|
|
// switch sensor with a Grove connector
|
|
|
|
type GroveMagneticSwitchDriver struct {
|
|
|
|
*ButtonDriver
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewGroveMagneticSwitchDriver returns a new GroveMagneticSwitchDriver with a polling interval of
|
|
|
|
// 10 Milliseconds given a DigitalReader, name and pin.
|
|
|
|
//
|
|
|
|
// Optionally accepts:
|
|
|
|
// time.Duration: Interval at which the ButtonDriver is polled for new information
|
|
|
|
func NewGroveMagneticSwitchDriver(a DigitalReader, pin string, v ...time.Duration) *GroveMagneticSwitchDriver {
|
|
|
|
return &GroveMagneticSwitchDriver{
|
|
|
|
ButtonDriver: NewButtonDriver(a, pin, v...),
|
|
|
|
}
|
|
|
|
}
|