finding a bug
This commit is contained in:
21
main.go
21
main.go
@@ -2,11 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"github.com/warthog618/gpio"
|
||||
"math"
|
||||
"time"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const Timeout = math.MaxInt32
|
||||
@@ -62,16 +61,18 @@ func readDataFromDHT(pin *gpio.Pin) ([5]byte, error) {
|
||||
pin.Low()
|
||||
pin.Output()
|
||||
time.Sleep(1100 * time.Microsecond)
|
||||
pin.PullUp()
|
||||
pin.High()
|
||||
time.Sleep(40 * time.Microsecond)
|
||||
pin.Input()
|
||||
time.Sleep(20 * time.Microsecond)
|
||||
time.Sleep(80 * time.Microsecond)
|
||||
time.Sleep(80 * time.Microsecond)
|
||||
// Wait for low high signal
|
||||
if cyclesForReading(pin, gpio.Low) == Timeout {
|
||||
return [5]byte{}, errors.New(fmt.Sprintf(TimeoutErrInitial, "low"))
|
||||
}
|
||||
if cyclesForReading(pin, gpio.High) == Timeout {
|
||||
return [5]byte{}, errors.New(fmt.Sprintf(TimeoutErrInitial, "high"))
|
||||
}
|
||||
//if cyclesForReading(pin, gpio.Low) == Timeout {
|
||||
// return [5]byte{}, errors.New(fmt.Sprintf(TimeoutErrInitial, "low"))
|
||||
//}
|
||||
//if cyclesForReading(pin, gpio.High) == Timeout {
|
||||
// return [5]byte{}, errors.New(fmt.Sprintf(TimeoutErrInitial, "high"))
|
||||
//}
|
||||
pulsesAsCycles := readPulsesAsCycles(pin)
|
||||
receivedInput, err := storeCycleCountsAsBinarySequence(&pulsesAsCycles)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user