up, ir rx add blue led

This commit is contained in:
Tomas Krejci 2024-05-28 02:30:33 +02:00
parent a15e7214b7
commit 5122a05715
2 changed files with 7 additions and 2 deletions

View File

@ -4,6 +4,7 @@
from machine import Timer, Pin
from array import array
from utime import ticks_us
import uasyncio as asyncio
class IR_RX:
Timer_id = -1 # Software timer but enable override
@ -46,7 +47,7 @@ class IR_RX:
def do_callback(self, byte1, byte2, byte3, packet, thresh=0):
self.edge = 0
if packet >= thresh:
self.callback(byte1, byte2, byte3, packet, *self.args)
asyncio.create_task(self.callback(byte1, byte2, byte3, packet, *self.args))
else:
self._errf(packet)

View File

@ -154,6 +154,7 @@ async def main(proto):
### RGB ###
logger.debug("RGB init")
global rgb1
rgb1 = RGB()
@ -161,8 +162,11 @@ async def main(proto):
### OLT IR RX ###
logger.debug("OLT IR RX init")
# User callback
def cb(byte1, byte2, byte3, packet):
async def cb(byte1, byte2, byte3, packet):
print(f"byte1 0x{byte1:02x} byte2 0x{byte2:02x} byte3 0x{byte3:02x} packet 0x{packet:06x}")
await rgb1.set_blue()
await asyncio.sleep_ms(200)
await rgb1.set_red()
ir_rx = LT_24_RX(ir_rx_pin, cb) # Instantiate receiver
ir_rx.error_function(print_error) # Show debug information