1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 12:50:19 +01:00

style updates, removing error checking from defer, and closing timer channel

This commit is contained in:
Ben Schwartz 2015-03-31 18:16:02 -05:00
parent 2e3e23a155
commit 38897e416b

View File

@ -49,11 +49,7 @@ func main() {
if err := pin.Write(embd.Low); err != nil {
panic(err)
}
defer func() {
if err := pin.SetDirection(embd.In); err != nil {
panic(err)
}
}()
defer pin.SetDirection(embd.In)
stepPins[i] = pin
}
@ -69,7 +65,6 @@ func main() {
[]int{0, 0, 0, 1},
[]int{1, 0, 0, 1},
}
stepCount := len(seq) - 1
stepDir := 2 // Set to 1 or 2 for clockwise, -1 or -2 for counter-clockwise
@ -79,6 +74,7 @@ func main() {
// Start main loop
ticker := time.NewTicker(time.Duration(*stepDelay) * time.Millisecond)
defer timer.Close()
var stepCounter int
for {
@ -96,7 +92,6 @@ func main() {
if err := pin.Write(embd.Low); err != nil {
panic(err)
}
}
}
stepCounter += stepDir