From 5122a05715147a266ee6e8bd41ac7c6bf0246a18 Mon Sep 17 00:00:00 2001 From: Tomas Krejci Date: Tue, 28 May 2024 02:30:33 +0200 Subject: [PATCH] up, ir rx add blue led --- lib/olt_lib/ir_rx/__init__.py | 3 ++- main.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/olt_lib/ir_rx/__init__.py b/lib/olt_lib/ir_rx/__init__.py index c4c029c..966be6d 100644 --- a/lib/olt_lib/ir_rx/__init__.py +++ b/lib/olt_lib/ir_rx/__init__.py @@ -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) diff --git a/main.py b/main.py index f7d6bdf..c2e4a3d 100644 --- a/main.py +++ b/main.py @@ -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