59 lines
1.8 KiB
Plaintext
59 lines
1.8 KiB
Plaintext
Module Morse_code {
|
|
declare Json JsonObject
|
|
json$={{
|
|
"!": "---.", "\"": ".-..-.", "$": "...-..-", "'": ".----.",
|
|
"(": "-.--.", ")": "-.--.-", "+": ".-.-.", ",": "--..--",
|
|
"-": "-....-", ".": ".-.-.-", "/": "-..-.",
|
|
"0": "-----", "1": ".----", "2": "..---", "3": "...--",
|
|
"4": "....-", "5": ".....", "6": "-....", "7": "--...",
|
|
"8": "---..", "9": "----.",
|
|
":": "---...", ";": "-.-.-.", "=": "-...-", "?": "..--..",
|
|
"@": ".--.-.",
|
|
"A": ".-", "B": "-...", "C": "-.-.", "D": "-..",
|
|
"E": ".", "F": "..-.", "G": "--.", "H": "....",
|
|
"I": "..", "J": ".---", "K": "-.-", "L": ".-..",
|
|
"M": "--", "N": "-.", "O": "---", "P": ".--.",
|
|
"Q": "--.-", "R": ".-.", "S": "...", "T": "-",
|
|
"U": "..-", "V": "...-", "W": ".--", "X": "-..-",
|
|
"Y": "-.--", "Z": "--..",
|
|
"[": "-.--.", "]": "-.--.-", "_": "..--.-",
|
|
}}
|
|
e = 50 ' Element time in ms. one dit is on for e then off for e
|
|
f = 1280 ' Tone freq. in hertz
|
|
chargap = 1*e ' Time between characters of a word
|
|
wordgap = 7*e ' Time between words
|
|
|
|
method json, "parser", json$ as json
|
|
with json, "itempath" as json.path$()
|
|
|
|
|
|
Input "Send Message:";a$
|
|
a$=trim$(a$)
|
|
if len(a$)=0 then exit
|
|
a$=ucase$(a$)
|
|
|
|
for i=1 to len(a$)
|
|
L$=mid$(a$, i, 1)
|
|
Print L$;
|
|
Send(json.path$(L$))
|
|
next
|
|
|
|
sub Send(a$)
|
|
if len(a$)=0 then wait wordgap : exit sub
|
|
local i
|
|
for i=1 to len(a$)
|
|
select case mid$(a$, i, 1)
|
|
case "."
|
|
tone e, f
|
|
case "-"
|
|
tone 3*e, f
|
|
case else
|
|
tone 3*e, f mod 2
|
|
end select
|
|
wait chargap
|
|
next
|
|
end sub
|
|
}
|
|
Keyboard "This is Morse_code", 13
|
|
Morse_code
|