1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +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 Adaptor AnalogReader
} }
func NewAnalogSensor(a AnalogReader) *AnalogSensorDriver { func NewAnalogSensor(a AnalogReader, name string, pin string) *AnalogSensorDriver {
return &AnalogSensorDriver{ return &AnalogSensorDriver{
Driver: gobot.Driver{ Driver: gobot.Driver{
Name: name,
Pin: pin,
Commands: []string{ Commands: []string{
"ReadC", "ReadC",
}, },

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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