Skip to content

Return protocol detected with ir_rx/acquire.py acquire function #45

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mario872
Copy link

I was trying to detect the protocol of an IR command, and found there was no way to properly do it programmatically. So I modified ir_rx/acquire.py. The IR_GET.acquire function now returns a dict with the keys raw and protocol. raw returns the marks and spaces list as before, and protocol returns the protocol detected by decode(), or Unknown. I also modified acquire.py to still try and detect the protocol used, even if display is False. Setting display to True uses print statements and returns the protocol and marks and spaces programmatically, whereas False just doesn't print anything.
I also updated the docs for the receiver and transmitter to reflect the changes.

Here is a small test script:

from ir_rx.acquire import IR_GET
from machine import Pin

IR_GET.Timer_id = 0 # For ESP32-C3, although I need to use this on ESP32-S3 for some reason too.
ir_rx = IR_GET(Pin(10, Pin.IN), display=False) # Run without output in terminal
data = ir_rx.acquire()
print("Raw data bursts: " + str(data["raw"]))
print("Protocol: " + data["protocol"])

This was only tested on an ESP32-S3, although I doubt further testing on other chip families is needed.

Thank you for this wonderful library, and as this is my first pull request, please let me know if I got something wrong.

@peterhinch
Copy link
Owner

This is rather a specialised requirement. I don't think it justifies amending the package (which would involve a lot of re-testing). I suggest we leave the PR open: anyone needing this functionality can access it.

@mario872
Copy link
Author

Ok, sure. That seems like a good solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants