8000 implement timeout in read_pulses() · Issue #16 · adafruit/Adafruit_CircuitPython_IRRemote · GitHub
[go: up one dir, main page]

Skip to content
implement timeout in read_pulses() #16
Closed
@kevinjwalters

Description

@kevinjwalters

I've been writing some code based on https://learn.adafruit.com/infrared-ir-receive-transmit-circuit-playground-express-circuit-python/ir-test-with-remote to read/decode the NEC codes from a humble little remote control. I wanted to be able to match the codes with the button pressed to partially generate the code.

I hit a problem where decoder.read_pulses(pulsein) sometimes does not return after I have pressed a button on the remote. I'm new to IR so it took me a while to work out what's going on. I am sometimes missing a final pulse, occasionally there's a 40ms long pulse but more often it's missing. The long pulse (> max_pulse, default 10000us) causes read_pulses() to return but most of the time it's absent (not clear if it's not sent xor not received).

I've made this more robust for the remote I'm using by some simple additions to read_pulses to implemented a timeout. Would this be useful for all?

I've tried a LG remote from an older commercial product and it does the same. Sometimes there's an end 45ms pulse, sometimes not. Actually, I may have found out the difference here, on the both remotes short duration depress (stabbing at buttons) appear to yield no final 40ms/45ms pulse.

From my empirical testing it certainly looks like read_pulses would benefit from a timeout after receiving some pulses to allow the data to be returned and decoded.

I'll post my code in a few days and I can do a PR against the library if you like the idea of this feature. Current implementation uses a new named parameter called timeout with default of None. Value is either microsecond value or "max_pulse" to link it to the max_pulse value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0