Skip to content

Commit c29e10b

Browse files
authored
Merge pull request #11 from apatt/master
#6
2 parents 0b04de3 + 49d1582 commit c29e10b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adafruit_irremote.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,20 @@ def decode_bits(self, pulses, debug=False):
189189
output[i // 8] |= 1
190190
return output
191191

192-
def read_pulses(self, input_pulses, max_pulse=10000):
192+
def read_pulses(self, input_pulses, max_pulse=10000, blocking=True):
193193
"""Read out a burst of pulses until a pulse is longer than ``max_pulse``.
194194
195195
:param ~pulseio.PulseIn input_pulses: Object to read pulses from
196196
:param int max_pulse: Pulse duration to end a burst
197+
:param bool blocking: If True, will block until pulses found.
198+
If False, will return None if no pulses.
199+
Defaults to True for backwards compatibility
197200
"""
198201
received = []
199202
while True:
200203
while len(input_pulses) < 8: # not too big (slower) or too small (underruns)!
201-
pass
204+
if not blocking:
205+
return None
202206
while input_pulses:
203207
pulse = input_pulses.popleft()
204208
if pulse > max_pulse:

0 commit comments

Comments
 (0)