add bomb command to BLE UART

This commit is contained in:
Tomas Krejci 2024-06-06 15:02:54 +02:00
parent e1e1440b29
commit 448ca2dbcf

14
main.py
View File

@ -86,9 +86,17 @@ import time
def ble_rx_handler():
message = uart.read().decode().strip()
logger.debug(f"BLE: {message}")
logger.debug(f"BLE: {message}")
try:
if "bomb" in message:
logger.info("BLE: Bomb Explode send to IR")
asyncio.create_task(
olt_sent_ir(ir_tx, COMMANDS[1][1], COMMANDS[1][2], COMMANDS[1][3])
)
message_int = int(message, 16)
logger.debug(f"BLE: {message_int:08x}")
if message_int == 0x01:
uart.write(f"BLE: uart recive {message_int:08x}\n")
@ -165,7 +173,8 @@ from rgb import RGB
COMMAND_END = 0xE8
COMMANDS = [
["NewGame", 0x83, 0x05, COMMAND_END],
["AdminKill", 0x83, 0x00, COMMAND_END],
# ["AdminKill", 0x83, 0x00, COMMAND_END],
["Explode", 0x83, 0x0B, COMMAND_END],
["TestShot_ID8_RED_25", 0x08, 0x24, 0x00],
["SensorTest", 0x83, 0x15, COMMAND_END],
]
@ -287,6 +296,7 @@ async def main(proto):
### OpenLaserTag IR TX ###
logger.debug("OLT IR TX init")
global ir_tx
ir_tx = LT_24_TX(ir_tx_pin, 56000) # My decoder chip is 56KHz
# Uncomment the following to print transmit timing
ir_tx.timeit = True