up
This commit is contained in:
parent
de67c12628
commit
ae9d603476
@ -1,8 +1,5 @@
|
||||
# rp2_rmt.py A RMT-like class for the RP2.
|
||||
|
||||
# Released under the MIT License (MIT). See LICENSE.
|
||||
|
||||
# Copyright (c) 2021-2024 Peter Hinch
|
||||
# A RMT-like class for the RP2.
|
||||
# Tomas Krejci [Njord]
|
||||
|
||||
# There are two asm_pio programs, pulsetrain and irqtrain. Only the second is used.
|
||||
# Both operate on a FIFO containing times in μs. The first toggles a pin when a
|
||||
|
57
test_olt_ir.py
Normal file
57
test_olt_ir.py
Normal file
@ -0,0 +1,57 @@
|
||||
## Test IR TX/RX for OpenLaserTag
|
||||
## Tomas Krejci [Njord]
|
||||
|
||||
# Run this to characterise a remote.
|
||||
import ustruct
|
||||
from sys import platform
|
||||
import time
|
||||
import gc
|
||||
from machine import Pin, freq
|
||||
from olt_lib.ir_rx.print_error import print_error # Optional print of error codes
|
||||
|
||||
# Import all implemented classes
|
||||
from olt_lib.ir_rx.olt import LT_24, SONY_12, SONY_15, SONY_20
|
||||
|
||||
# Define pin according to platform
|
||||
if platform == "pyboard":
|
||||
p = Pin("X3", Pin.IN)
|
||||
elif platform == "esp8266":
|
||||
freq(160000000)
|
||||
p = Pin(13, Pin.IN)
|
||||
elif platform == "esp32" or platform == "esp32_LoBo":
|
||||
p = Pin(23, Pin.IN)
|
||||
elif platform == "rp2":
|
||||
p = Pin(16, Pin.IN)
|
||||
|
||||
|
||||
|
||||
# User callback
|
||||
def cb(byte1, byte2, byte3, packet):
|
||||
print(f"byte1 0x{byte1:02x} byte2 0x{byte2:02x} byte3 0x{byte3:02x} packet 0x{packet:06x}")
|
||||
|
||||
def test(proto=0):
|
||||
classes = (LT_24, SONY_12, SONY_15, SONY_20)
|
||||
ir = classes[proto](p, cb) # Instantiate receiver
|
||||
ir.error_function(print_error) # Show debug information
|
||||
# ir.verbose = True
|
||||
# A real application would do something here...
|
||||
try:
|
||||
while True:
|
||||
print("running")
|
||||
time.sleep(5)
|
||||
gc.collect()
|
||||
except KeyboardInterrupt:
|
||||
ir.close()
|
||||
|
||||
|
||||
# **** DISPLAY GREETING ****
|
||||
s = """Test for IR receiver. Run:
|
||||
from ir_rx.test import test
|
||||
test() for LT 24 bit protocol,
|
||||
test(1) for Sony SIRC 12 bit,
|
||||
test(2) for Sony SIRC 15 bit,
|
||||
test(3) for Sony SIRC 20 bit,
|
||||
|
||||
Hit ctrl-c to stop, then ctrl-d to soft reset."""
|
||||
|
||||
print(s)
|
Loading…
Reference in New Issue
Block a user