# mpy - Send and receive morse code on kit FKS0001
# Copyright by Anthony Vogelaar, Perth Scotland
# rev 0.10  2025-09-29  initial release

import	time
from	machine				import	Pin, ADC
from	morse_writer_rmt	import	MorseWriter
from	morse_reader		import	MorseReader

# ======================= hardware ==========================

pin_mic = Pin(33, Pin.IN, Pin.PULL_UP)
adc_mic = ADC(pin_mic, atten=ADC.ATTN_0DB)				# 0..950 mV

# ========================= main ============================

def main(line):
    writer = MorseWriter()
    reader = MorseReader(adc_mic)
    while True:
        t0 = time.time()
        writer.outLine(line)
#        reader.printTiming()
        while time.time() - t0 < 20:
            if w := reader.getWord(): print(w, end=' ')
        
        
main('sos sos')
#main('Het is mooi weer vandaag')
        
# =========================== end ================================
