version 1.0 relase

This commit is contained in:
Tomas Krejci 2024-06-22 01:13:41 +02:00
parent ba310c309a
commit 0b02f5e12c
3 changed files with 2000 additions and 20 deletions

View File

@ -73,12 +73,21 @@ datasheet: https://www.vishay.com/docs/82459/tsop48.pdf
- pin 16 - IR RX
- pin 17 - IR TX - 22R - IR LED OSRAM SFH4544
- pin 18 - button
- pin 19 - button
- pin 20 - button
- pin 22 - Red LED, resistor 75R
- pin 28 - 2xAA 1,5V BAT - Schottky diode - VSYS Pi Pico
- pin 15 - PN2222A NPN transistor - Piezo
# BLE UART Serial Terminal
Show IR RX recived commands
### Send IR Commands from terminal
'led_off' LED OFF
'led_on' LED ON
'bomb' Send Explode command over IR TX
Any Lasertag command in hex `FFFFFF` or `0xFFFFFF` send this command over IR TX

1969
lib/picozero.py Normal file

File diff suppressed because it is too large Load Diff

36
main.py
View File

@ -1,7 +1,13 @@
# OpenLaserTag device
# OLT protocol.
# Tomas Krejci [Njord]
###########################################################
# #
# OpenLaserTag remote control #
# OLT protocol #
# Tomas Krejci [Njord] tk@tomaskrejci.com #
# #
# version 1.0 #
# 2024-06-22 #
# #
###########################################################
import machine, time, re
from sys import platform
@ -34,24 +40,19 @@ 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
### Piezo ###
piezo_pin = machine.Pin(15, machine.Pin.OUT, value=1)
piezo_pin2 = machine.Pin(14, machine.Pin.OUT, value=1)
piezo_pin = machine.Pin(15, machine.Pin.OUT, value=0)
async def piezo_beep(sec=0.3):
piezo_pin.value(0)
piezo_pin2.value(0)
await asyncio.sleep(sec)
piezo_pin.value(1)
piezo_pin2.value(1)
await asyncio.sleep(sec)
piezo_pin.value(0)
async def piezo_short_beep():
piezo_pin.value(0)
piezo_pin2.value(0)
await asyncio.sleep(0.1)
piezo_pin.value(1)
piezo_pin2.value(1)
await asyncio.sleep(0.1)
piezo_pin.value(0)
#### Voltage monitor ###
@ -83,8 +84,8 @@ async def battery_monitor(aadc):
) # reference voltage (3.3V) divided by the maximum ADC value (65535)
voltage = round(voltage, 2)
capacity = voltage_to_capacity(voltage / 2)
logger.info(f"Battery Voltage: {voltage}V, Capacity: {capacity}%")
uart.write(f"BATTERY: Voltage: {voltage}V, Capacity: {capacity}%\n")
logger.info(f"Battery Voltage: {voltage:.2f}V, Capacity: {capacity:.0f}%")
uart.write(f"BATTERY: Voltage: {voltage:.2f}V, Capacity: {capacity:.0f}%\n")
await asyncio.sleep_ms(10000)
@ -239,7 +240,8 @@ import logging
global logger
init_ticks = time.ticks_ms()
# change logging level here, logging.ERROR is default, logging.DEBUG for more info, and reset device
log_level = logging.DEBUG
# log_level = logging.DEBUG
log_level = logging.INFO
# log_level = logging.ERROR
logging.basicConfig(level=log_level, format="%(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger(__name__)