1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import time
from typing import Final
from src import morse_code
from .abstract import LEDController, TouchSensor, ProximitySensor
# Constants (Keep same or tests will break)
THRESHOLD: Final[int] = 75
UNIT_TIME: Final[float] = 0.24
RED : Final[tuple[int, int, int]] = (255, 0, 0)
YELLOW: Final[tuple[int, int, int]] = (220, 160, 0)
GREEN : Final[tuple[int, int, int]] = (0, 255, 0)
# Legacy ham radio license requirement
# - 0.24 sec unit time (5 words per minute)
# Fastest recorded transcription on a straight key
# - 0.034 sec unit time (35 words per minute)
def set_color(elapsed_t: float, px: LEDController):
"""
Lights the LEDs on the trinkey depending on the length of input.
Args:
elapsed_t (float): duration of proximity detection.
px : LED controller object.
"""
pass
def add_mark(elapsed_t: float) -> str:
"""
Determines if input is a dot (.), dash (-), or nothing ("") based
on the length of input.
Args:
elapsed_t (float): duration of proximity detection.
Returns:
str: dot (.), dash (-), or empty ("").
"""
pass
def run_morse_engine(apds: ProximitySensor, pixels: LEDController, touch: TouchSensor):
"""
Runs Morse code translation based on proximity input.
Args:
apds: proximity sensor.
pixels: LED controller object.
touch: touch sensor for confirming input.
"""
morse = "" # Dots, dashs, and slashes so far
start = time.monotonic() # Time when proximity sensor was first triggered
# Main loop
while True:
if touch.value:
print("Touched!")
print("the message should be here", "<==")