finding a bug

This commit is contained in:
Daniel Ledda
2020-10-31 18:32:17 +01:00
parent 33649ff1df
commit 3b0213b965

28
main.go
View File

@@ -54,6 +54,34 @@ func main() {
} }
} }
func readDataFromDHTTest(pin *gpio.Pin) ([5]byte, error) {
sendStartSignal(pin)
edgeChangeTimestamps := make([]int64, 0, 100)
_ = pin.Watch(gpio.EdgeFalling, func(pin *gpio.Pin) {
edgeChangeTimestamps = append(edgeChangeTimestamps, time.Now().UnixNano())
})
_ = pin.Watch(gpio.EdgeRising, func(pin *gpio.Pin) {
edgeChangeTimestamps = append(edgeChangeTimestamps, time.Now().UnixNano())
})
fmt.Println(edgeChangeTimestamps)
return [5]byte{0, 0, 0, 0, 0}, nil
}
func sendStartSignal(pin *gpio.Pin) {
pin.PullUp()
time.Sleep(time.Millisecond)
pin.Output()
pin.Low()
time.Sleep(1100 * time.Microsecond)
pin.High()
time.Sleep(20 * time.Microsecond)
pin.Input()
}
func readDataFromDHT(pin *gpio.Pin) ([5]byte, error) { func readDataFromDHT(pin *gpio.Pin) ([5]byte, error) {
// Setup // Setup
pin.PullUp() pin.PullUp()