From 847ce956b08efc24015d871c464288d94efaa7b1 Mon Sep 17 00:00:00 2001 From: Michael Lass Date: Thu, 6 Aug 2020 14:52:37 +0200 Subject: [PATCH] Immediately pause pulse_in after initialization Right now, pulse_in is active until the first reading and only paused after that. Let's immediately pause it to free up the CPU. --- adafruit_dht.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_dht.py b/adafruit_dht.py index fb2b188..137994a 100644 --- a/adafruit_dht.py +++ b/adafruit_dht.py @@ -67,6 +67,7 @@ def __init__(self, dht11, pin, trig_wait): # and we're better off having a running process if _USE_PULSEIO: self.pulse_in = PulseIn(self._pin, 81, True) + self.pulse_in.pause() def _pulses_to_binary(self, pulses, start, stop): """Takes pulses, a list of transition times, and converts @@ -114,7 +115,6 @@ def _get_pulses_pulseio(self): # specific length of time. Then the device sends back a # series HIGH and LOW signals. The length the HIGH signals # represents the device values. - self.pulse_in.pause() self.pulse_in.clear() self.pulse_in.resume(self._trig_wait)