Skip to content

Commit

Permalink
Merge pull request hybridgroup#406 from vlastv/fix-gpio-motor
Browse files Browse the repository at this point in the history
Fix incorrect change state
  • Loading branch information
deadprogram authored Apr 12, 2017
2 parents 6ae2003 + 8c62d8c commit 9430e6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpio/motor_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ func (m *MotorDriver) isDigital() bool {
func (m *MotorDriver) changeState(state byte) (err error) {
m.CurrentState = state
if state == 1 {
m.CurrentSpeed = 0
} else {
m.CurrentSpeed = 255
} else {
m.CurrentSpeed = 0
}
if m.ForwardPin != "" {
if state == 0 {
if state == 1 {
err = m.Direction(m.CurrentDirection)
if err != nil {
return
Expand Down
1 change: 1 addition & 0 deletions drivers/gpio/motor_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func TestMotorDriverDirection(t *testing.T) {

func TestMotorDriverDigital(t *testing.T) {
d := initTestMotorDriver()
d.SpeedPin = "" // Disable speed
d.CurrentMode = "digital"
d.ForwardPin = "2"
d.BackwardPin = "3"
Expand Down

0 comments on commit 9430e6e

Please sign in to comment.