Created
January 25, 2026 14:38
-
-
Save elvis-epx/176fae3f9e3b95a158f0a6360eb69399 to your computer and use it in GitHub Desktop.
Test RMT RX soft filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import esp32 | |
| from machine import Pin | |
| import time | |
| import select | |
| # rx = esp32.RMTRX(pin=Pin(14), num_symbols=64, min_ns=3100, max_ns=5000*1000, resolution_hz=1000000, \ | |
| # soft_min_ns=150*1000, soft_max_ns=1500*1000, soft_min_len=49, soft_max_len=57) | |
| rx = esp32.RMTRX(pin=Pin(14), num_symbols=64, min_ns=3100, max_ns=5000*1000, resolution_hz=1000000) | |
| rx.active(1) | |
| while True: | |
| data = None | |
| while not data: | |
| t0 = time.ticks_us() | |
| data = rx.get_data() | |
| # Following three tests necessary w/o the soft_* filters | |
| if len(data) != 49 and len(data) != 57: | |
| continue | |
| elif any(abs(sample) < 150 for sample in data): | |
| continue | |
| elif any(abs(sample) > 1500 for sample in data): | |
| continue | |
| t1 = time.ticks_us() | |
| binary = map(lambda hi, lo: abs(hi) > abs(lo) and "1" or "0", data[0::2], data[1::2]) | |
| binary = "".join(binary) | |
| print("Code is", int(binary, 2)) | |
| dt = time.ticks_diff(t1, t0) | |
| tt = sum([ abs(x) for x in data ]) | |
| print(dt, tt) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment