ラズパイ・PICO モールス練習機
一番うしろに、mycropythonのソースプログラムをコピーしておきます。
今回は、モールス練習機ができましたので、発表します。 皆さんのお役にたてれば嬉しいです。
以下に、mycropythonのソースプログラムをコピーしておきます。
main_morse_20240224.py
v1.0 2022/8/17 jh1cdv
v1.1 2022/9/1 key reverce
v2.0 2022/12/16
V2.1 2022/12/18 表示を変更
V3.0 2023/5/8 送信_I2C_KBを追加
V3.1 2023/5/22 送信_speed_volを追加
V4.0 2023/10/11 makerfaire用に
V5.0 2024/2/3 yoxo_festibal用に
V5.1 2024/2/24 jh1ymc用 morse練習器に
V5.2 2024/2/24 jh1ymc用 morse会話器に
v6.1 2024/8/17 ハムフェア用 main_morse_traner_20240817.py
L0:モールス信号をサンプリングして、時間測定
L1:モールス符号の短点(.:dot)、長点(ー:bar) 認識
L2:モールス符号の文字認識
L3:モールス符号の単語認識
L4:コマンドの認識
L5:モールス符号をローマ字→漢字変換→リモコンコマンド
rx_tx_morse.pyにモールス練習機機能を追加
#
in
out
'''
サンプリング周期(mSec)と通信速度(字/分)の関係
・短点50個で、PARIS符号 5文字に相当→短点10個/文字
・通信速度60字/分→60*10=600個/分→600/60=10個/秒
→短点が100mSecの時、通信速度60字/分
'''
ライブラリの import
import json
from lcd1602 import LCD1602
from machine import I2C,Pin,ADC,UART,PWM
from utime import sleep
import select
import _thread
import time
rx_codes = {
".-" : "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",
".----" : "1", "..---" : "2","...--" : "3", "....-" : "4", "....." : "5",
"-...." : "6", "--..." : "7","---.." : "8", "----." : "9", "-----" : "0",
"...---..." : "SOS"
}
print(rx_codes.get(".-"))
roomaji_codes = {
"a" : "あ", "i" : "い", "u" : "う","e" : "え", "o" : "お",
"ka" : "か", "ki" : "き", "ku" : "く","ke" : "け", "ko" : "こ",
"sa" : "さ", "si" : "し", "su" : "す","se" : "せ", "so" : "そ",
"ta" : "た", "ti" : "ち", "tu" : "つ","te" : "て", "to" : "と",
"na" : "な", "ni" : "に", "nu" : "ぬ","ne" : "ね", "no" : "の",
"ha" : "は", "hi" : "ひ", "hu" : "ふ","he" : "へ", "ho" : "ほ",
"ma" : "ま", "mi" : "み", "mu" : "む","me" : "め", "mo" : "も",
"ya" : "や", "yi" : "い", "yu" : "ゆ","ye" : "いぇ", "yo" : "よ",
"ra" : "ら", "ri" : "り", "ru" : "る","re" : "れ", "ro" : "ろ",
"wa" : "わ", "wi" : "うぃ", "we" : "うぇ", "wo" : "を", "nn" : "ん"
}
print(roomaji_codes.get("a"))
codes = {
"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" : "--..",
"1" : ".----", "2" : "..---", "3" : "...--", "4" : "....-", "5" : ".....",
"6" : "-....", "7" : "--...", "8" : "---..", "9" : "----.", "0" : "-----"
}
JSON変数の定義、初期化
サンプリング回数100(y)/サンプリング周期1mSec(x)/100*60=60字/分
L0_para = '{"L0_sts0":0, "L0_sts1":0,"L0_1ctr":0,"L0_0ctr":0}'
#L0_para = '{"L0_sts0":0, "L0_sts1":0,"L0_1ctr":0,"L0_0ctr":10000}' # L0_0ctr の初期値を 10000mS→10秒とする
#L0_para = '{"L0_sts0":0, "L0_sts1":0,"L0_1ctr":0,"L0_0ctr":1000}' # L0_0ctr の初期値を 1000mS→1秒とする
#L1_para = '{"L1_avr":10, "L1_dot_bar":"."}' #最初にごみの様に入ってしまうが苦肉の策 l1_avr=4 time.sleep_ms(20) #dot 2
#L1_para = '{"L1_avr":10, "L1_dot_bar":"."}' #最初にごみの様に入ってしまうが苦肉の策 l1_avr=8 time.sleep_ms(10) #dot 6 dash 17
L1_para = '{"L1_avr":8, "L1_dot_bar":"."}' #100ms L1_avr":20 はdot=10
#L2_para = '{"L2_char":"a","L2_3dot":6}'
L2_para = '{"L2_char":"a","L2_3dot":12}' #文字の切れ目 l2_3dotは短くて良いSyntaxError: invalid syntax?
#L3_para = '{"L3_word":"a","L3_7dot":14,"L3_words":"s:","L3_100dot":500}'
L3_para = '{"L3_word":"a","L3_7dot":120,"L3_words":"s:","L3_100dot":30}' #L3_7dot ":70→120
L4_para = '{"L4_cmd":"SOS"}'
L5_para = '{"L5_roomaji":"あ"}'
#in_para = '{"key_centor":4000, "light_centor":25000,"sound_centor": 8700}'
in_para = '{"key_centor":2000, "light_centor":30000,"sound_centor": 8700}'
out_para = '{"speed":0.2, "char_min":30}'
L0_json = json.loads(L0_para)
time.sleep_ms(100)
L1_json = json.loads(L1_para)
time.sleep_ms(100)
L2_json = json.loads(L2_para)
time.sleep_ms(100)
L3_json = json.loads(L3_para)
time.sleep_ms(100)
L4_json = json.loads(L4_para)
time.sleep_ms(100)
L5_json = json.loads(L5_para)
time.sleep_ms(100)
in_json = json.loads(in_para)
time.sleep_ms(100)
out_json = json.loads(out_para)
time.sleep_ms(100)
JSON変数の定義、初期化 モールス練習機用
dot_para = '{"dot_min":10000, "dot_ave":10,"dot_max":1,"dot_sum":1,"dot_num":1,"dot_rasio":1}' #0はdevide byzero
dot_json = json.loads(dot_para)
time.sleep_ms(100)
#dash_para = '{"dash_min":10000, "dash_ave":0,"dash_max":0,"dash_sum":0,"dash_num":1,"dash_rasio":0}'
dash_para = '{"das_min":10000, "das_ave":30,"das_max":1,"das_sum":1,"das_num":1,"das_rasio":1}'
#{"dash_min": 13, "dash_rasio": -19, "dash_max": 44, "dash_sum": 266, "dash_ave": 26, "d ""}\n\rd": 10} dash_numが壊れる???
dash_json = json.loads(dash_para)
time.sleep_ms(100)
traner_para = '{"traner_num":10,"traner_ctr":0,"traner_dot_das_rasio":0,"traner_speed":25}' # 試験用3
traner_json = json.loads(traner_para)
time.sleep_ms(100)
#i2c = I2C(1,scl=Pin(7), sda=Pin(6), freq=400000) #grove starter kit用
i2c = I2C(0,scl=Pin(13), sda=Pin(12), freq=400000) #my基板用
#シリアルの設定
#シリアル0 u = UART(0) # 115200bps
u = UART(0,baudrate=115200,tx=Pin(0),rx=Pin(1)) # 115200bps
#u = UART(0,baudrate=9600,tx=Pin(0),rx=Pin(1)) # 9600bps
#シリアル1
u1 = UART(1,baudrate=9600,tx=Pin(4),rx=Pin(5)) # 9600bps
u1.write("aiueo" + "\n\r")
#u .write("morse_traner_start" + "\n\r")
スレーブアドレス 0x48 のデバイスから 2バイトを読み出す I2C kb用、つながないとエラーになる
#data = i2c.readfrom(0x48, 1)
#data = []
#data = i2c.readfrom(0x5F, 1)
#print (data)
d = LCD1602(i2c, 2, 16)
d.display()
u.write("morse_traner_start" + "\n\r")
time.sleep_ms(100)
d.clear()
d.setCursor(0,0)
d.print("morse_traner_start" )
time.sleep_ms(100)
LED = Pin(20,Pin.OUT)
LED.value(1)
REL = Pin(16,Pin.OUT)
REL.value(1)
sleep(1)
REL.value(0)
#sleep (1)
time.sleep_ms(1000)
LED.value(0)
#key = ADC(0)
#print (key.read_u16())
#sleep (1)
#light = ADC(1)
#print (light.read_u16())
#sleep (1)
#for i in range(30): #試験用に300程度 、
#print (light.read_u16())
#sleep (0.1)
#sound = ADC(2)
#print (sound.read_u16())
#sleep (1)
speed(入力)の設定です。
speed = ADC(1)
print('speed=',speed.read_u16())
sleep(1)
key(出力)の設定です。
key_out = machine.Pin(8, machine.Pin.OUT)
key_out.value(0)
sleep(1)
#key_out .value(1)
key(入力)の設定です。
key_in = machine.Pin(9, machine.Pin.IN)
print('key_in=',key_in.value())
sleep(1)
macro_key(入力)の設定です。
macro_key_in = machine.Pin(17, machine.Pin.IN)
print('macro_key_in=',macro_key_in.value())
sleep(1)
buz = PWM(Pin(18))
#buz = PWM(Pin(8))
buz.freq(1046)
buz.duty_u16(1000)
#sleep (1)
buz.duty_u16(0)
d.clear()
d.setCursor(0,0)
d.print("morse_dec_2" )
time.sleep_ms(100)
dot_duration = 0.2
#dot_duration_ms = 200
dash_duration = dot_duration * 3.0
word_gap = dot_duration * 7.0
durations = {"." : dot_duration, "-" : dash_duration}
def send_pulse(dot_or_dash):
#
#dot_duration = 0.2
#dot_duration = 0.5123456789
#print ('speed=',speed.read_u16())
#print ('speed=',(speed.read_u16()/65000)*1.0+0.01)
print(str(speed.read_u16()))
print("speed=" + str((speed.read_u16()/65000)*10.0+0.05))
dot_duration = (speed.read_u16()/65000)*10.0+0.05
#dot_duration = (speed.read_u16()/65000)*1.0+0.01
print(dot_duration)
out_json["speed"] = str((speed.read_u16()/65000)*10.0+0.01)
print(out_json["speed"])
out_json["char_min"] = str(6/((speed.read_u16()/65000)*10.0+0.01))
#print(out_json["char_min"])
#dot_duration_ms = 200
dash_duration = dot_duration * 3.0
word_gap = dot_duration * 7.0
durations = {"." : dot_duration, "-" : dash_duration}
if dot_or_dash == '.':
delay = dot_duration
else:
delay = dash_duration
#buz.freq(1046)
buz.duty_u16(1000)
key_out.value(1)
REL.value(1)
sleep(delay)
buz.duty_u16(0)
key_out.value(0)
REL.value(0)
sleep(dot_duration)
#sleep(0.05)
#sleep(delay)
def send_morse_for(character):
if character == ' ':
sleep(word_gap)
else:
dots_n_dashes = codes.get(character.lower())
if dots_n_dashes:
print(character + " " + dots_n_dashes)
for pulse in dots_n_dashes:
send_pulse(pulse)
sleep(dash_duration)
else:
print("unknown character: " + character)
#def core1():
#text = "a"
text_byte = "null"
text_moji = "null"
def core1_thread():
u.write("morse_traner_start" + "\n\r")
speed = ADC(1)
print('speed=',speed.read_u16())
out_json["speed"] = str((speed.read_u16()/65000)*100+10)
print(type(out_json["speed"]))
print(out_json["speed"])
text = "end" #この行がないとNameError: local variable referenced before assignment
while True:
#print(type(text))
#print("1:" + text)
#print(light.read_u16())
#if u.any() > 0: #最初に3文字xoo入力されてしまうようだ 未対応
#text = str(u.read())
#text = str(text,'shift_jis')
#text = text[2:-1]
#print(text)
#else:
#text = str("_") #b'\x00 になる
#text = "end"
#print(type(text))
#print("2:" + text)
#text_kb = i2c.readfrom(0x5F, 1)
#text_kb = str(text_kb,'shift_jis')
#print(type(text_kb)) #<class 'bytes'>
#print(text_kb)
#if text_kb is None : #text_kbはbyte型なのでエラー python3から???
# traner text_kb 停止
#if text_kb == bytes(b'\x00') :
# text_kb_0 = ('NULL')
#print('kb_input_none')
#else:
# text = str(text_kb,'shift_jis')
#print("kb_input")
#text = "end"
#print(type(text))
#print("3:" + text)
print('macro_key_in=',macro_key_in.value()) #コピーがおかしいときあり???
if macro_key_in.value() == 0 :
text = "parisparis"
#print('speed=',(speed.read_u16()/65000)+0.1)
#
#dot_duration = 0.2
#dot_duration = 0.5123456789
dot_duration = (speed.read_u16()/65000)+0.1
#print(dot_duration)
#dot_duration_ms = 200
dash_duration = dot_duration * 3.0
word_gap = dot_duration * 7.0
durations = {"." : dot_duration, "-" : dash_duration}
#print(type(text))
#print("4:" + text)
if text == "end":
text__0 = ('NULL')
else:
for character in text:
send_morse_for(character)
print("tx_end: ")
text = "end"
text = str(text,'shift_jis')
print(type(text))
print(text)
sleep(0.1) #
#sleep(1) #I2C_KBの連続打ちができない
_thread.start_new_thread(core1_thread, ())
print("start_main")
while True:
time.sleep_ms(9)
L0_json["L0_sts1"] = L0_json["L0_sts0"]
L0_json["L0_sts0"] = 0
#if key.read_u16() > in_json["key_centor"]:
#if key.read_u16() < in_json["key_centor"]:
#L0_json ["L0_sts0"] = 1
#if light.read_u16() > in_json["light_centor"]:
#L0_json ["L0_sts0"] = 1
#print ('key_in=',key_in.value())
#key = key_in.value()
#print (key)
if key_in.value() == 0:
L0_json["L0_sts0"] = 1
if L0_json["L0_sts0"] == 1:
#LED .value(1)
L0_json["L0_sts0"] = 1
else:
#LED .value(0)
L0_json["L0_sts0"] = 0
#0 →0
if ((L0_json["L0_sts1"] == 0) and (L0_json["L0_sts0"] == 0)):
L0_json["L0_0ctr"] += 1
L0_json["L0_1ctr"] = 0
#1 →1
if ((L0_json["L0_sts1"] == 1) and (L0_json["L0_sts0"] == 1)):
#L0_json ["L0_1ctr"] = L0_json["L0_1ctr"] + 1
L0_json["L0_1ctr"] += 1
L0_json["L0_0ctr"] = 0
#変化を検出 #1→0 立下り検出
if ((L0_json["L0_sts1"] == 1) and (L0_json["L0_sts0"] == 0)):
if (L0_json["L0_1ctr"] > 0): #1 →0 立下り検出
#if ((L0_json["L0_1ctr"]-L1_json["L1_avr"]) == 0):
# L1_json["L1_avr"] = int(L1_json["L1_avr"])
#else :
# L1_json["L1_avr"] = int(L1_json["L1_avr"] + (L0_json["L0_1ctr"]-L1_json["L1_avr"])/10)
#if (L0_json["L0_1ctr"] > 1): #1 →0 立下り検出
#if (L0_json["L0_1ctr"] < L1_json["L1_avr"]):
# L1_json["L1_avr"] = L1_json["L1_avr"] + 1
#else :
# L1_json["L1_avr"] = L1_json["L1_avr"] - 1 #足せるが 、引けない
if (L0_json["L0_1ctr"] < L1_json["L1_avr"]):
L1_json["L1_dot_bar"] = L1_json["L1_dot_bar"] + "."
#traner
dot_json["dot_sum"] = dot_json["dot_sum"] + L0_json["L0_1ctr"]
dot_json["dot_num"] += 1
if (dot_json["dot_min"] > L0_json["L0_1ctr"]):
dot_json["dot_min"] = L0_json["L0_1ctr"]
if (dot_json["dot_max"] < L0_json["L0_1ctr"]):
dot_json["dot_max"] = L0_json["L0_1ctr"]
else:
L1_json["L1_dot_bar"] = L1_json["L1_dot_bar"] + "-"
#L2_json ["L2_3dot"] = L0_json["L0_1ctr"] #3dot1 =3dot
#L3_json ["L3_7dot"] = L0_json["L0_1ctr"] * 3 #3dot3 =9dot 要調整
#traner
dash_json["das_sum"] = dash_json["das_sum"] + L0_json["L0_1ctr"]
#dash_json ["das_num"] = dash_json["das_num"] + 1
dash_json["das_num"] += 1
if (dash_json["das_min"] > L0_json["L0_1ctr"]):
dash_json["das_min"] = L0_json["L0_1ctr"]
if (dash_json["das_max"] < L0_json["L0_1ctr"]):
dash_json["das_max"] = L0_json["L0_1ctr"]
L0_json["L0_0ctr"] = 0
#0 →1 立上がり検出
if ((L0_json["L0_sts1"] == 0) and (L0_json["L0_sts0"] == 1)): #0 →1 立上がり検出 l0_1ctが0にならない???
L0_json["L0_1ctr"] = 0
#文字の切れ目
if (L0_json["L0_0ctr"] == L2_json["L2_3dot"]) : #文字の切れ目 l2_3dotは短くて良い
if (L1_json["L1_dot_bar"] == ""):
u.write("dot_bar_null" + json.dumps(L1_json) + "\n\r") #文字の切れ目でデータなしの時
else:
if rx_codes.get(L1_json["L1_dot_bar"]):
L2_json["L2_char"] = rx_codes.get(L1_json["L1_dot_bar"])
L3_json["L3_word"] = L3_json["L3_word"] + L2_json["L2_char"]
d.clear()
d.setCursor(0,0)
#d .print("RX:" + str(L1_json["L1_dot_bar"]) + ":" + str(L3_json["L3_word"]) + " " + str(out_json["char_min"]))
d.print("RX:" + str(L1_json["L1_dot_bar"]) + ":" + str(L2_json["L2_char"]) )
print("moji_end_L1_dot_bar:" + str(L1_json["L1_dot_bar"]) + " : " + str(L2_json["L2_char"]) + " : "+ str(L3_json["L3_word"]) + " " + str(out_json["char_min"]))
if (str(L2_json["L2_char"]) == "SOS") :
print("SOS_detect=")
LED = Pin(20,Pin.OUT)
LED.value(1)
buz.duty_u16(1000)
time.sleep_ms(3000)
buz.duty_u16(0)
LED.value(0)
L1_json["L1_dot_bar"] = ""
L2_json["L2_char"] = ""
print("L1_dot_bar_clear:" + str(L1_json["L1_dot_bar"]) + " : " + str(L2_json["L2_char"]) + " : "+ str(L3_json["L3_word"]) )
#print("L1_dot_bar_clear:" + str(L1_json["L1_dot_bar"]) + " : " + str(L2_json["L2_char"]) + " : "+ str(L3_json["L3_word"]) + " " + str(out_json["char_min"]))
time.sleep_ms(10)
d.setCursor(0,1)
L3_json["L3_words"] = L3_json["L3_words"] + L3_json["L3_word"]
d.print(str(L3_json["L3_word"])) #ok
d.print(":" + str(L3_json["L3_words"])) #ng 386???
#d.print("-:"+ str(dash_json["das_min"]) +":"+ str(dash_json["das_ave"])+":"+ str(dash_json["das_ave"]) +":"+ str(dash_json["das_rasio"])+":"+ str(traner_json["traner_speed"]))
time.sleep_ms(1)
#L1_json["L1_dot_bar"] = ""
#L2_json["L2_char"] = ""
#traner
#traner_json["traner_ctr"] += 1
if (traner_json["traner_ctr"] == traner_json["traner_num"]):
dot_json["dot_ave"] = int(dot_json["dot_sum"] / dot_json["dot_num"])
dot_json["dot_rasio"] = int(((dot_json["dot_ave"]*2 - (dot_json["dot_max"]-dot_json["dot_min"]))/ (dot_json["dot_ave"] *2)* 100))
dash_json["das_ave"] = int(dash_json["das_sum"] / dash_json["das_num"])
dash_json["das_rasio"] = int(((dash_json["das_ave"]*2 - (dash_json["das_max"]-dash_json["das_min"]))/ (dash_json["das_ave"]*2) * 100))
traner_json["traner_dot_das_rasio"] = int((6.0 - (3.0 - dash_json["das_ave"] / dot_json["dot_ave"]))/ 6.0 *100)
# サンプリング回数10(y)/サンプリング周期10mSec(x)*60=60字/分
#traner_json["traner_speed"] = int( 10/dot_json["dot_ave"] *60)
# サンプリング回数10(y)/サンプリング周期50mSec(x)*60=12字/分
#traner_json["traner_speed"] = int( 10/dot_json["das_ave"] *4)
#traner_json["traner_speed"] = int( 10/dot_json["dot_ave"] *12) ##time.sleep_ms(20)
traner_json["traner_speed"] = int( 10/dot_json["dot_ave"] *6) ##time.sleep_ms(10)
u.write(json.dumps(dot_json) + "\n\r")
u.write(json.dumps(dash_json) + "\n\r")
u.write(json.dumps(traner_json) + "\n\r")
d.clear()
d.setCursor(0,0)
d.print(".:"+ str(dot_json["dot_min"]) +":"+ str(dot_json["dot_ave"]) +":"+ str(dot_json["dot_max"]) +":"+ str(dot_json["dot_rasio"])+":"+ str(L1_json["L1_avr"]))
#d.print(".:"+ str(dot_json["dot_min"]) +":"+ str(dot_json["dot_ave"]) +":"+ str(dot_json["dot_max"]) +":"+ str(dot_json["dot_rasio"]))
#d.print(".:"+ str(dot_json["dot_min"]) +":"+ str(dot_json["dot_ave"]) +":"+ str(dot_json["dot_max"]) +":"+ str(dot_json["dot_rasio"])+":"+ str(traner_json["traner_dot_das_rasio"]))
d.setCursor(0,1)
d.print("-:"+ str(dash_json["das_min"]) +":"+ str(dash_json["das_ave"])+":"+ str(dash_json["das_max"]) +":"+ str(dash_json["das_rasio"])+":"+ str(traner_json["traner_speed"]))
#変数初期化
u.write(json.dumps(dot_json) + "\n\r")
u.write(json.dumps(dash_json) + "\n\r")
dot_json = json.loads(dot_para)
dash_json = json.loads(dash_para)
traner_json = json.loads(traner_para)
traner_json["traner_ctr"] += 1
#単語の切れ目
if (L0_json["L0_0ctr"] == L3_json["L3_7dot"]) :
u.write(json.dumps(L3_json) + "\n\r")
L4_json["L4_cmd"] = L3_json["L3_word"]
#L3_json ["L3_words"] = L3_json["L3_words"] + " " + L3_json["L3_word"]
print("L3_words_end=" + L3_json["L3_words"])
#print (out_json["char_min"]) #TypeError : can't convert 'int' object to str implicitly
#L3_json ["L3_words"] = " "
#print ("L3_words_clear=" + L3_json["L3_words"])
#d .clear()
#d .setCursor(0,0)
#d .print("RX:" + str(L1_json["L1_dot_bar"]) + ":" + str(L3_json["L3_word"]) )
#d .print("RX:" + str(L1_json["L1_dot_bar"]) + ":" + str(L3_json["L3_word"]) + " " + str(out_json["char_min"]))
time.sleep_ms(10)
#d.setCursor(0,1)
#L3_json["L3_words"] = L3_json["L3_words"] + L3_json["L3_word"]
#d.print(str(L3_json["L3_word"])) #ok
#d.print("RX_W:" + str(L3_json["L3_words"])) #ng 386???
L3_json["L3_word"] = ""
L3_json["L3_words"] = ""
print("L3_words_clear=" + L3_json["L3_words"])
u.write(json.dumps(L4_json) + "\n\r")
if roomaji_codes.get(L4_json["L4_cmd"]):
L5_json["L5_roomaji"] = roomaji_codes.get(L4_json["L4_cmd"])
u.write(json.dumps(L5_json) + "\n\r")
# コマンド解析
#if (L4_json["L4_cmd"] == "oto") :
#buz.duty_u16(1000)
#time.sleep_ms(3000)
#buz.duty_u16(0)
#if (L4_json["L4_cmd"] == "sos") :
#print("sos_detect=")
#buz.duty_u16(1000)
#time.sleep_ms(3000)
#buz.duty_u16(0)
#文章の切れ目
if (L0_json["L0_0ctr"] == L3_json["L3_100dot"]) :
u.write(json.dumps(L3_json) + "\n\r")
print("bunsyou_end=" + json.dumps(L3_json) + "\n\r")
L3_json["L3_word"] = ""
L3_json["L3_words"] = ""
L1_json["L1_dot_bar"] = ""
L2_json["L2_char"] = ""
#time.sleep_ms(5)
#time.sleep_ms(8)
time.sleep_ms(10) #dot 0
#time.sleep_ms(20) #dot 2
#time.sleep_ms(50) #20240203
#time.sleep_ms(100)