Skip to content

Don't modify the input pulses argument. #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions adafruit_irremote.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ def decode_bits(self, pulses):
if len(pulses) < 10:
raise IRDecodeException("10 pulses minimum")

# remove any header
del pulses[0]
if len(pulses) % 2 == 1:
del pulses[0]
# Ignore any header (evens start at 1), and any trailer.
if len(pulses) % 2 == 0:
pulses_end = -1
else:
pulses_end = None

evens = pulses[1:pulses_end:2]
odds = pulses[2:pulses_end:2]

evens = pulses[0::2]
odds = pulses[1::2]
# bin both halves
even_bins = self.bin_data(evens)
odd_bins = self.bin_data(odds)
Expand Down