Merge remote-tracking branch 'origin/HEAD'

This commit is contained in:
Tomas Krejci 2024-05-29 08:37:26 +02:00
commit d8083b84f5
2 changed files with 11 additions and 7 deletions

View File

@ -31,7 +31,7 @@ class SONY_ABC(IR_RX): # Abstract base class
if nedges > 50:
raise RuntimeError(self.OVERRUN)
bits = (nedges - 2) // 2
if nedges not in (26, 32, 42, 50) or bits > self._bits:
if nedges not in (58, 30, 50) or bits > self._bits:
raise RuntimeError(self.BADBLOCK)
self.verbose and print("SIRC {}bit".format(bits))
width = ticks_diff(self._times[1], self._times[0])

16
main.py
View File

@ -2,7 +2,7 @@
# OLT protocol.
# Tomas Krejci [Njord]
import machine, time
import machine, time, re
from sys import platform
ESP32 = platform == "esp32"
@ -14,10 +14,14 @@ else:
from pyb import Pin, LED
import uasyncio as asyncio
device_id = ""
#### Device ID ###
device_id_str = ""
for b in machine.unique_id():
device_id += "{:02X}".format(b)
# device_id_hex = int(device_id)
device_id_str += "{:02X}".format(b)
device_id_str = device_id_str[-4:] # Keep last 8 char
device_id = int(device_id_str, 16) # Convert to int from hex in string
# device_id_str = str(device_id, 16) # Convert back to hex print(f"{device_id:0x}")
#### BLE UART ###
import ble_uart
@ -30,7 +34,7 @@ def print_handler():
ble = bluetooth.BLE()
uart = ble_uart.Ble_uart(ble, on_rx=print_handler, name=print("LaserTag"))
uart = ble_uart.Ble_uart(ble, on_rx=print_handler, name="OpenLaserTag " + device_id_str)
#### OLT IR RX imports ###
import ustruct
@ -155,7 +159,7 @@ async def cb(byte1, byte2, byte3, packet):
async def main(proto):
logger.debug("main start")
print(f"Device ID: {device_id}")
print(f"Device ID: {device_id_str}")
### alive check ###
asyncio.create_task(alive_check())