works now!
needs space (i.e. long pauses should create a space) also the first character seems to disappear.
This commit is contained in:
parent
91b8982554
commit
0f5c3423b3
141
main.py
141
main.py
@ -10,16 +10,16 @@ import time
|
|||||||
logFileName = "atmosphere_log.txt"
|
logFileName = "atmosphere_log.txt"
|
||||||
mindex=0
|
mindex=0
|
||||||
morse = []
|
morse = []
|
||||||
bme688 = KitronikBME688()
|
#bme688 = KitronikBME688()
|
||||||
oled = KitronikOLED()
|
oled = KitronikOLED()
|
||||||
rtc = KitronikRTC()
|
rtc = KitronikRTC()
|
||||||
zipleds = KitronikZIPLEDs(3)
|
zipleds = KitronikZIPLEDs(3)
|
||||||
# Python u arse hole sec = Integer()
|
# Python u arse hole sec = Integer()
|
||||||
rtc.setDate(16, 7, 2022)
|
rtc.setDate(16, 7, 2022)
|
||||||
rtc.setTime(12, 10, 0)
|
rtc.setTime(12, 10, 0)
|
||||||
|
rate = 100
|
||||||
bme688.setupGasSensor()
|
#bme688.setupGasSensor()
|
||||||
bme688.calcBaselines()
|
#bme688.calcBaselines()
|
||||||
sec = 0
|
sec = 0
|
||||||
#f = open(logFileName, 'a')
|
#f = open(logFileName, 'a')
|
||||||
#f.write("# Data Logging: Date, Time, Temperature, Pressure, Humidity, AirQuality, CO2\n")
|
#f.write("# Data Logging: Date, Time, Temperature, Pressure, Humidity, AirQuality, CO2\n")
|
||||||
@ -63,7 +63,7 @@ def ButtonB_f_IRQHandler(pin):
|
|||||||
d = tt - last_tt
|
d = tt - last_tt
|
||||||
if pv:
|
if pv:
|
||||||
#print(" duration of inter-m space ", d)
|
#print(" duration of inter-m space ", d)
|
||||||
if d < 600:
|
if d < rate*6:
|
||||||
print (" ")
|
print (" ")
|
||||||
else:
|
else:
|
||||||
print (" interval ")
|
print (" interval ")
|
||||||
@ -71,7 +71,7 @@ def ButtonB_f_IRQHandler(pin):
|
|||||||
beeper.playTone(600)
|
beeper.playTone(600)
|
||||||
else:
|
else:
|
||||||
#print(" duration of press ", d)
|
#print(" duration of press ", d)
|
||||||
if d > 300:
|
if d > rate*3:
|
||||||
morse.append("-");
|
morse.append("-");
|
||||||
print ("DAH")
|
print ("DAH")
|
||||||
else:
|
else:
|
||||||
@ -86,6 +86,27 @@ def ButtonB_f_IRQHandler(pin):
|
|||||||
buttons.buttonB.irq(trigger=machine.Pin.IRQ_FALLING|machine.Pin.IRQ_RISING, handler=ButtonB_f_IRQHandler)
|
buttons.buttonB.irq(trigger=machine.Pin.IRQ_FALLING|machine.Pin.IRQ_RISING, handler=ButtonB_f_IRQHandler)
|
||||||
#buttons.buttonB.irq(trigger=machine.Pin.IRQ_RISING, handler=ButtonB_r_IRQHandler)
|
#buttons.buttonB.irq(trigger=machine.Pin.IRQ_RISING, handler=ButtonB_r_IRQHandler)
|
||||||
|
|
||||||
|
charbuf = []
|
||||||
|
hpm=10
|
||||||
|
vpm=2
|
||||||
|
def printm(mchar):
|
||||||
|
global hpm, oled, vpm, charbuf
|
||||||
|
charbuf.append(mchar)
|
||||||
|
chcnt = 0
|
||||||
|
oled.clear()
|
||||||
|
oled.displayText("Morse rxd",1,2)
|
||||||
|
while len(charbuf) > (4*20):
|
||||||
|
charbuf.pop(0) # get rid of old morse
|
||||||
|
for i in range(2,6):
|
||||||
|
for j in range (0,20):
|
||||||
|
chcnt += 1
|
||||||
|
if len(charbuf) > chcnt:
|
||||||
|
oled.displayText(charbuf[chcnt], i, j*6)
|
||||||
|
else:
|
||||||
|
oled.displayText(' ', i, j*6)
|
||||||
|
oled.show()
|
||||||
|
print(mchar);
|
||||||
|
|
||||||
def decode_morse():
|
def decode_morse():
|
||||||
global morse
|
global morse
|
||||||
dm_a = [".","-"]
|
dm_a = [".","-"]
|
||||||
@ -98,33 +119,107 @@ def decode_morse():
|
|||||||
dm_h = [".",".",".","."]
|
dm_h = [".",".",".","."]
|
||||||
dm_i = [".","."]
|
dm_i = [".","."]
|
||||||
dm_j = [".","-","-","-"]
|
dm_j = [".","-","-","-"]
|
||||||
|
dm_k = ["-",".","-"]
|
||||||
|
dm_l = [".","-",".","."]
|
||||||
|
dm_m = ["-","-"]
|
||||||
|
dm_n = ["-","."]
|
||||||
|
dm_o = ["-","-","-"]
|
||||||
|
dm_p = [".","-","-","."]
|
||||||
|
dm_q = ["-","-",".","-"]
|
||||||
|
dm_r = [".","-","."]
|
||||||
dm_s = [".",".","."]
|
dm_s = [".",".","."]
|
||||||
dm_o = ["-","-","-"]
|
dm_t = ["-"]
|
||||||
|
dm_u = [".",".","-"]
|
||||||
|
dm_v = [".",".",".","-"]
|
||||||
|
dm_w = [".","-","-"]
|
||||||
|
dm_x = ["-",".",".","-"]
|
||||||
|
dm_y = ["-",".","-","-"]
|
||||||
|
dm_z = ["-","-",".","."]
|
||||||
|
#
|
||||||
|
dm_0 = ["-","-","-","-","-"]
|
||||||
|
dm_1 = [".","-","-","-","-"]
|
||||||
|
dm_2 = [".",".","-","-","-"]
|
||||||
|
dm_3 = [".",".",".","-","-"]
|
||||||
|
dm_4 = [".",".",".",".","-"]
|
||||||
|
dm_5 = [".",".",".",".","."]
|
||||||
|
dm_6 = ["-",".",".",".","."]
|
||||||
|
dm_7 = ["-","-",".",".","."]
|
||||||
|
dm_8 = ["-","-","-",".","."]
|
||||||
|
dm_9 = ["-","-","-","-","."]
|
||||||
#
|
#
|
||||||
if morse == dm_a:
|
if morse == dm_a:
|
||||||
print ("A")
|
return ("A")
|
||||||
if morse == dm_b:
|
if morse == dm_b:
|
||||||
print ("B")
|
return ("B")
|
||||||
if morse == dm_c:
|
if morse == dm_c:
|
||||||
print ("C")
|
return ("C")
|
||||||
if morse == dm_d:
|
if morse == dm_d:
|
||||||
print ("D")
|
return ("D")
|
||||||
if morse == dm_e:
|
if morse == dm_e:
|
||||||
print ("E")
|
return ("E")
|
||||||
if morse == dm_f:
|
if morse == dm_f:
|
||||||
print ("F")
|
return ("F")
|
||||||
if morse == dm_g:
|
if morse == dm_g:
|
||||||
print ("G")
|
print ("G")
|
||||||
if morse == dm_h:
|
if morse == dm_h:
|
||||||
print ("H")
|
return ("H")
|
||||||
if morse == dm_i:
|
if morse == dm_i:
|
||||||
print ("I")
|
return ("I")
|
||||||
if morse == dm_j:
|
if morse == dm_j:
|
||||||
print ("J")
|
return ("J")
|
||||||
if morse == dm_s:
|
if morse == dm_k:
|
||||||
print ("S")
|
print ("K")
|
||||||
|
if morse == dm_l:
|
||||||
|
return ("L")
|
||||||
|
if morse == dm_m:
|
||||||
|
return ("M")
|
||||||
|
if morse == dm_n:
|
||||||
|
return ("N")
|
||||||
if morse == dm_o:
|
if morse == dm_o:
|
||||||
print ("O")
|
return ("O")
|
||||||
|
if morse == dm_p:
|
||||||
|
return ("P")
|
||||||
|
if morse == dm_q:
|
||||||
|
return ("Q")
|
||||||
|
if morse == dm_r:
|
||||||
|
return ("R")
|
||||||
|
if morse == dm_s:
|
||||||
|
return ("S")
|
||||||
|
if morse == dm_t:
|
||||||
|
return ("T")
|
||||||
|
if morse == dm_u:
|
||||||
|
return ("U")
|
||||||
|
if morse == dm_v:
|
||||||
|
return ("V")
|
||||||
|
if morse == dm_w:
|
||||||
|
return ("W")
|
||||||
|
if morse == dm_x:
|
||||||
|
return ("X")
|
||||||
|
if morse == dm_y:
|
||||||
|
return ("Y")
|
||||||
|
if morse == dm_z:
|
||||||
|
return ("Z")
|
||||||
|
if morse == dm_0:
|
||||||
|
return ("0")
|
||||||
|
if morse == dm_1:
|
||||||
|
return ("1")
|
||||||
|
if morse == dm_2:
|
||||||
|
return ("2")
|
||||||
|
if morse == dm_3:
|
||||||
|
return ("3")
|
||||||
|
if morse == dm_4:
|
||||||
|
return ("4")
|
||||||
|
if morse == dm_5:
|
||||||
|
return ("5")
|
||||||
|
if morse == dm_6:
|
||||||
|
return ("6")
|
||||||
|
if morse == dm_7:
|
||||||
|
return ("7")
|
||||||
|
if morse == dm_8:
|
||||||
|
return ("8")
|
||||||
|
if morse == dm_9:
|
||||||
|
return ("9")
|
||||||
|
return("?")
|
||||||
|
|
||||||
|
|
||||||
def process_morse():
|
def process_morse():
|
||||||
@ -134,11 +229,11 @@ def process_morse():
|
|||||||
# morse chacter complete
|
# morse chacter complete
|
||||||
if (len(morse) > 0):
|
if (len(morse) > 0):
|
||||||
print(morse)
|
print(morse)
|
||||||
decode_morse()
|
printm(decode_morse())
|
||||||
morse = []
|
morse = []
|
||||||
oled.clear()
|
#oled.clear()
|
||||||
oled.displayText(rtc.readDateString(), 1, 25)
|
#oled.displayText(rtc.readDateString(), 1, 25)
|
||||||
oled.displayText(rtc.readTimeString(), 2, 33)
|
#oled.displayText(rtc.readTimeString(), 2, 33)
|
||||||
#oled.displayText(str(mcount), 4, 33)
|
#oled.displayText(str(mcount), 4, 33)
|
||||||
oled.show()
|
oled.show()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user