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
import time
from src import morse_code
# Constants (Keep same or tests will break)
THRESHOLD = 75
UNIT_TIME = 0.24
RED = (255, 0, 0)
YELLOW = (220, 160, 0)
GREEN = (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, px):
"""Lights the LEDs on the trinkey depending on length of input.
The LED should be lit red (255, 0, 0) if the input is shorter than UNIT_TIME.
The LED should be lit yellow (220, 160, 0) if the input is between 1 and 3 times UNIT_TIME.
The LED should be lit green (0, 255, 0) if the input is longer than 3 times UNIT_TIME.
"""
pass
def add_mark(elapsed_t):
"""Determines if input is a dot (.) or dash (-) depending on length of input.
Returns an empty string if the input is less than UNIT_TIME.
Returns a dot if the input is between 1 and 3 times UNIT_TIME.
Returns a dash if the input is greater than 3 times UNIT_TIME.
"""
pass
def run_morse_engine(apds, pixels, touch):
"""A Tests Demo on Trinkey"""
down = None # Time when proximity sensor was first triggered
elapsed = 0 # Duration proximity sensor has been triggered
message = "" # Translated part of message
letter = "" # Dots and dashes of current (unfinished) letter
# Main loop
while True:
if touch.value:
print("Touched!")
print(message, letter, "<==")