1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00

Update gpio package

This commit is contained in:
Adrian Zankich 2014-05-22 21:29:37 -07:00
parent d877ffd251
commit 20395a016e
11 changed files with 21 additions and 16 deletions

View File

@ -9,9 +9,11 @@ type AnalogSensorDriver struct {
Adaptor AnalogReader
}
func NewAnalogSensor(a AnalogReader) *AnalogSensorDriver {
func NewAnalogSensor(a AnalogReader, name string, pin string) *AnalogSensorDriver {
return &AnalogSensorDriver{
Driver: gobot.Driver{
Name: name,
Pin: pin,
Commands: []string{
"ReadC",
},

View File

@ -12,8 +12,7 @@ var _ = Describe("Analog-Sensor", func() {
)
BeforeEach(func() {
a = NewAnalogSensor(t)
a.Pin = "1"
a = NewAnalogSensor(t, "bot", "1")
})
It("Must be able to Read", func() {

View File

@ -10,9 +10,11 @@ type ButtonDriver struct {
Active bool
}
func NewButtonDriver(a DigitalReader) *ButtonDriver {
func NewButtonDriver(a DigitalReader, name string, pin string) *ButtonDriver {
return &ButtonDriver{
Driver: gobot.Driver{
Name: name,
Pin: pin,
Events: map[string]chan interface{}{
"push": make(chan interface{}),
"release": make(chan interface{}),

View File

@ -12,8 +12,7 @@ var _ = Describe("Button", func() {
)
BeforeEach(func() {
b = NewButtonDriver(t)
b.Pin = "1"
b = NewButtonDriver(t, "bot", "1")
})
It("Must be able to readState", func() {

View File

@ -9,9 +9,11 @@ type DirectPinDriver struct {
Adaptor DirectPin
}
func NewDirectPinDriver(a DirectPin) *DirectPinDriver {
func NewDirectPinDriver(a DirectPin, name string, pin string) *DirectPinDriver {
return &DirectPinDriver{
Driver: gobot.Driver{
Name: name,
Pin: pin,
Commands: []string{
"DigitalReadC",
"DigitalWriteC",

View File

@ -12,8 +12,7 @@ var _ = Describe("DirectPin", func() {
)
BeforeEach(func() {
d = NewDirectPinDriver(t)
d.Pin = "1"
d = NewDirectPinDriver(t, "bot", "1")
})
It("Should be able to DigitalRead", func() {

View File

@ -10,7 +10,7 @@ type LedDriver struct {
High bool
}
func NewLedDriver(a PwmDigitalWriter, name, pin string) *LedDriver {
func NewLedDriver(a PwmDigitalWriter, name string, pin string) *LedDriver {
return &LedDriver{
Driver: gobot.Driver{
Name: name,

View File

@ -18,9 +18,11 @@ type MotorDriver struct {
CurrentDirection string
}
func NewMotorDriver(a PwmDigitalWriter) *MotorDriver {
func NewMotorDriver(a PwmDigitalWriter, name string, pin string) *MotorDriver {
return &MotorDriver{
Driver: gobot.Driver{
Name: name,
Pin: pin,
Commands: []string{
"OffC",
"OnC",

View File

@ -12,8 +12,7 @@ var _ = Describe("Motor", func() {
)
BeforeEach(func() {
m = NewMotorDriver(t)
m.Pin = "1"
m = NewMotorDriver(t, "bot", "1")
})
It("Must be able to Start", func() {

View File

@ -10,9 +10,11 @@ type ServoDriver struct {
CurrentAngle byte
}
func NewServoDriver(a Servo) *ServoDriver {
func NewServoDriver(a Servo, name string, pin string) *ServoDriver {
return &ServoDriver{
Driver: gobot.Driver{
Name: name,
Pin: pin,
Commands: []string{
"MoveC",
"MinC",

View File

@ -12,8 +12,7 @@ var _ = Describe("Servo", func() {
)
BeforeEach(func() {
s = NewServoDriver(t)
s.Pin = "1"
s = NewServoDriver(t, "bot", "1")
})
It("Should be able to Move", func() {