From 7563718fa46e774ffd44eb9cfffd81cd0e6b99db Mon Sep 17 00:00:00 2001 From: Sharkbia <79235521+Sharkbia@users.noreply.github.com> Date: Sat, 24 Feb 2024 01:33:51 +0800 Subject: [PATCH 1/8] feat(#16): add backup and restore eeprom function fix(#16): fix pinyin table problem Actually, I did not know why this fix works. --- functions.py | 136 +++++++++++++++++++++++++++++++++++++++++++++++---- main.py | 31 +++++++----- 2 files changed, 147 insertions(+), 20 deletions(-) diff --git a/functions.py b/functions.py index 32aa376..23f33d9 100644 --- a/functions.py +++ b/functions.py @@ -387,24 +387,31 @@ def auto_write_font(serial_port_text: str, window: tk.Tk, progress: ttk.Progress messagebox.showinfo('提示', f'{version_number}{version_code}版本字库\n写入成功') else: n = 4 if version_code == 'H' else 3 - log(f'正在进行 1/{n}: 写入{version_number}{version_code}版字库') - write_font(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, font_type, True) - log(f'正在进行 2/{n}: 写入字库配置') - write_font_conf(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) - log(f'正在进行 3/{n}: 写入亚音参数') - write_tone_options(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) + m = 1 if n == 4: - log(f'正在进行 4/{n}: 写入拼音检索表') + log(f'正在进行 {m}/{n}: 写入拼音检索表') if version_number == 123: write_pinyin_index(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) + m += 1 elif version_number > 123: write_pinyin_index(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True, True) - reset_radio(serial_port_text, status_label) + m += 1 + else: + return + log(f'正在进行 {m}/{n}: 写入{version_number}{version_code}版字库') + write_font(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, font_type, True) + m += 1 + log(f'正在进行 {m}/{n}: 写入字库配置') + write_font_conf(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) + m += 1 + log(f'正在进行 {m}/{n}: 写入亚音参数') + write_tone_options(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) + reset_radio(serial_port_text, status_label) + if n == 4: messagebox.showinfo('提示', f'{version_number}{version_code}版本字库\n字库配置\n亚音参数\n拼音检索表\n写入成功!') else: - reset_radio(serial_port_text, status_label) messagebox.showinfo('提示', f'{version_number}{version_code}版本字库\n字库配置\n亚音参数\n写入成功!') else: messagebox.showinfo('提示', f'非LOSEHU扩容固件,无法写入') @@ -636,3 +643,114 @@ def write_pinyin_index(serial_port_text: str, window: tk.Tk, progress: ttk.Progr serial_utils.reset_radio(serial_port) messagebox.showinfo('提示', '写入拼音检索表成功!') status_label['text'] = '当前操作: 无' + +def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressbar, + status_label: tk.Label, eeprom_size: int): + log('开始备份') + log('选择的串口: ' + serial_port_text) + status_label['text'] = f'当前操作: 备份eeprom' + if len(serial_port_text) == 0: + log('没有选择串口!') + messagebox.showerror('错误', '没有选择串口!') + status_label['text'] = '当前操作: 无' + return + + target_eeprom_offset = 0x2000 + if eeprom_size > 0: + target_eeprom_offset = 0x20000 * eeprom_size + else: + target_eeprom_offset = 0x2000 + + with serial.Serial(serial_port_text, 38400, timeout=2) as serial_port: + serial_check = check_serial_port(serial_port, False) + if not serial_check.status: + messagebox.showerror('错误', serial_check.message) + status_label['text'] = '当前操作: 无' + return + + start_addr = 0x0 # 起始地址为0x0 + total_steps = (target_eeprom_offset - start_addr) // 128 # 计算总步数 + current_step = 0 + addr = start_addr + offset = 0 + + backup_data = b'' + + while addr < target_eeprom_offset: # 限制地址范围为start_addr到target_eeprom_offset + if target_eeprom_offset < 0x10000: + read_data = serial_utils.read_eeprom(serial_port, addr, 128) + else: + if addr - offset * 0x10000 >= 0x10000: + offset += 1 + read_data = serial_utils.read_extra_eeprom(serial_port, offset, addr - offset * 0x10000, 128) + backup_data += read_data + addr += 128 + current_step += 1 + percent_float = (current_step / total_steps) * 100 + log(f'进度: {percent_float:.1f}%, addr={hex(addr)}', '') + progress['value'] = percent_float + window.update() + + # 弹出文件保存对话框 + file_path = filedialog.asksaveasfilename(defaultextension=".bin", + filetypes=[("Binary files", "*.bin"), ("All files", "*.*")]) + + if not file_path: + log('用户取消保存') + messagebox.showinfo('提示', '用户取消保存') + return # 用户取消保存,直接返回 + + with open(file_path, 'wb') as fp: + fp.write(backup_data) + + log('EEPROM 备份完成') + status_label['text'] = '当前操作: 无' + messagebox.showinfo('提示', '保存成功!') + +def restore_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressbar, + status_label: tk.Label, eeprom_size: int): + log('开始恢复eeprom') + log('选择的串口: ' + serial_port_text) + status_label['text'] = f'当前操作: 恢复eeprom' + if len(serial_port_text) == 0: + log('没有选择串口!') + messagebox.showerror('错误', '没有选择串口!') + status_label['text'] = '当前操作: 无' + return + + start_addr = 0x0 + target_eeprom_offset = 0x2000 + if eeprom_size > 0: + target_eeprom_offset = 0x20000 * eeprom_size + else: + target_eeprom_offset = 0x2000 + + file_path = filedialog.askopenfilename(filetypes=[("Binary files", "*.bin"), ("All files", "*.*")]) + + if not file_path: + log('用户取消选择') + messagebox.showinfo('提示', '用户取消选择') + return # 用户取消选择,直接返回 + + with open(file_path, 'rb') as fp: + restore_data = fp.read() + + if len(restore_data) != target_eeprom_offset: + if messagebox.askquestion('提示', f'选择的文件大小为{len(restore_data)},但目标eeprom大小为{target_eeprom_offset},是否继续?') == 'no': + log('用户取消恢复') + messagebox.showinfo('提示', '用户取消恢复') + return # 用户取消恢复,直接返回 + + with serial.Serial(serial_port_text, 38400, timeout=2) as serial_port: + serial_check = check_serial_port(serial_port, False) + if not serial_check.status: + messagebox.showerror('错误', serial_check.message) + status_label['text'] = '当前操作: 无' + return + + write_data(serial_port, start_addr, restore_data, progress, window) + + log('EEPROM恢复完成') + status_label['text'] = '当前操作: 无' + serial_utils.reset_radio(serial_port) + messagebox.showinfo('提示', '写入成功!') \ No newline at end of file diff --git a/main.py b/main.py index 18d100b..16b58d9 100644 --- a/main.py +++ b/main.py @@ -18,7 +18,9 @@ read_config, write_config, write_pinyin_index, - todo_function + todo_function, + backup_eeprom, + restore_eeprom ) window = ttk.Window() @@ -333,26 +335,30 @@ def main(): width=14, command=lambda: write_pinyin_index( serial_port_combo.get(), window, progress, label2, - EEPROM_SIZE.index(eeprom_size_combo.get()), FIRMWARE_VERSION_LIST.index(firmware_combo.get()), True + EEPROM_SIZE.index(eeprom_size_combo.get()), FIRMWARE_VERSION_LIST.index(firmware_combo.get()), False, True ) ) write_pinyin_new_index_button.pack(side='left', padx=3, pady=(2, 15)) - todo_button = tk.Button( + backup_eeprom_button = tk.Button( frame7, - text='敬请期待', + text='备份EEPROM', width=14, - command=todo_function + command=lambda:backup_eeprom( + serial_port_combo.get(), window, progress, label2,EEPROM_SIZE.index(eeprom_size_combo.get()) + ) ) - todo_button.pack(side='left', padx=3, pady=(2, 15)) + backup_eeprom_button.pack(side='left', padx=3, pady=(2, 15)) - todo_button = tk.Button( + restore_eeprom_button = tk.Button( frame7, - text='敬请期待', + text='恢复EEPROM', width=14, - command=todo_function + command=lambda:restore_eeprom( + serial_port_combo.get(), window, progress, label2,EEPROM_SIZE.index(eeprom_size_combo.get()) + ) ) - todo_button.pack(side='left', padx=3, pady=(2, 15)) + restore_eeprom_button.pack(side='left', padx=3, pady=(2, 15)) todo_button = tk.Button( frame7, @@ -382,7 +388,7 @@ def main(): # 在此统一设置tooltip Tooltip(serial_port_combo, "点击选择K5/K6所在串口") - Tooltip(eeprom_size_combo, "EEPROM芯片容量,若自动检测正确则无需修改") + Tooltip(eeprom_size_combo, "EEPROM芯片容量,若自动检测正确则无需修改,可以使用该下拉框修改所需备份或恢复的容量") Tooltip(firmware_combo, "固件版本,若自动检测正确则无需修改") Tooltip(clean_eeprom_button, "清除EEPROM中的所有数据") Tooltip(auto_write_font_button, "自动写入机器固件所需字库等文件,如不清楚点那个按钮的情况下,点这个总没错") @@ -397,6 +403,9 @@ def main(): Tooltip(write_font_old_button, "萝狮虎117版本及之前版本使用,旧字库") Tooltip(write_pinyin_old_index_button, "123版本拼音索引,如果不使用自动写入,请在执行完字库写入后点击") Tooltip(write_pinyin_new_index_button, "124及以上版本拼音索引,如果不使用自动写入,请在执行完字库写入后点击") + Tooltip(backup_eeprom_button, "备份EEPROM中的数据,使用EEPROM下拉框可以选择所要备份的大小") + Tooltip(restore_eeprom_button, "恢复EEPROM中的数据,使用EEPROM下拉框可以选择所要恢复的大小") + Tooltip(todo_button, "敬请期待") window.mainloop() From 09ecfe096f49ea97828342ae0d1edf8c5afde071 Mon Sep 17 00:00:00 2001 From: hank9999 Date: Sat, 24 Feb 2024 02:05:39 +0800 Subject: [PATCH 2/8] refactor: remove redundant definition --- functions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions.py b/functions.py index 23f33d9..afe16a4 100644 --- a/functions.py +++ b/functions.py @@ -644,6 +644,7 @@ def write_pinyin_index(serial_port_text: str, window: tk.Tk, progress: ttk.Progr messagebox.showinfo('提示', '写入拼音检索表成功!') status_label['text'] = '当前操作: 无' + def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressbar, status_label: tk.Label, eeprom_size: int): log('开始备份') @@ -654,8 +655,7 @@ def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressba messagebox.showerror('错误', '没有选择串口!') status_label['text'] = '当前操作: 无' return - - target_eeprom_offset = 0x2000 + if eeprom_size > 0: target_eeprom_offset = 0x20000 * eeprom_size else: @@ -707,6 +707,7 @@ def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressba status_label['text'] = '当前操作: 无' messagebox.showinfo('提示', '保存成功!') + def restore_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressbar, status_label: tk.Label, eeprom_size: int): log('开始恢复eeprom') @@ -719,7 +720,6 @@ def restore_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressb return start_addr = 0x0 - target_eeprom_offset = 0x2000 if eeprom_size > 0: target_eeprom_offset = 0x20000 * eeprom_size else: From 989263813015b7764508b0abd9583dfa6c20972f Mon Sep 17 00:00:00 2001 From: hank9999 Date: Sat, 24 Feb 2024 02:06:44 +0800 Subject: [PATCH 3/8] style: format --- functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions.py b/functions.py index afe16a4..c87b9a8 100644 --- a/functions.py +++ b/functions.py @@ -646,7 +646,7 @@ def write_pinyin_index(serial_port_text: str, window: tk.Tk, progress: ttk.Progr def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressbar, - status_label: tk.Label, eeprom_size: int): + status_label: tk.Label, eeprom_size: int): log('开始备份') log('选择的串口: ' + serial_port_text) status_label['text'] = f'当前操作: 备份eeprom' @@ -709,7 +709,7 @@ def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressba def restore_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressbar, - status_label: tk.Label, eeprom_size: int): + status_label: tk.Label, eeprom_size: int): log('开始恢复eeprom') log('选择的串口: ' + serial_port_text) status_label['text'] = f'当前操作: 恢复eeprom' From 27f69b294ad50e47599b6469349e6dab17305064 Mon Sep 17 00:00:00 2001 From: hank9999 Date: Sat, 24 Feb 2024 02:21:21 +0800 Subject: [PATCH 4/8] refactor: remove useless library --- poetry.lock | 35 +---------------------------------- pyproject.toml | 1 - requirements.txt | 3 +-- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/poetry.lock b/poetry.lock index b31109b..0b6fb9d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,23 +1,5 @@ # This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. -[[package]] -name = "importlib-resources" -version = "6.1.1" -description = "Read resources from Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "importlib_resources-6.1.1-py3-none-any.whl", hash = "sha256:e8bf90d8213b486f428c9c39714b920041cb02c184686a3dee24905aaa8105d6"}, - {file = "importlib_resources-6.1.1.tar.gz", hash = "sha256:3893a00122eafde6894c59914446a512f728a0c1a45f9bb9b63721b6bacf0b4a"}, -] - -[package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff", "zipp (>=3.17)"] - [[package]] name = "pillow" version = "10.2.0" @@ -131,22 +113,7 @@ files = [ [package.dependencies] pillow = ">=8.2.0" -[[package]] -name = "zipp" -version = "3.17.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.8" -files = [ - {file = "zipp-3.17.0-py3-none-any.whl", hash = "sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31"}, - {file = "zipp-3.17.0.tar.gz", hash = "sha256:84e64a1c28cf7e91ed2078bb8cc8c259cb19b76942096c8d7b84947690cabaf0"}, -] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] - [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "23ca9cff2b2dfe38da366682dee8c7ef088bd7e2b3f7176bfc45a0b79c0bd0f8" +content-hash = "96dd4c3ccedba514555842eb84d6456644585dab2e0a24c1e8ff53099ca156af" diff --git a/pyproject.toml b/pyproject.toml index c1bed7a..bc5d911 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,6 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.8" pyserial = "^3.5" -importlib-resources = "^6.1.1" ttkbootstrap = "^1.10.1" [build-system] diff --git a/requirements.txt b/requirements.txt index bbbdafd..cf29944 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ pyserial>=3.5 -ttkbootstrap>=1.10.1 -importlib-resources>=6.1.1 \ No newline at end of file +ttkbootstrap>=1.10.1 \ No newline at end of file From 46604b09979cfe9377c96c7001c94ae2a1324b30 Mon Sep 17 00:00:00 2001 From: hank9999 Date: Sat, 24 Feb 2024 03:02:14 +0800 Subject: [PATCH 5/8] refactor: better way to implement `offset` `extra` calculation --- functions.py | 20 +++++++------------- serial_utils.py | 15 +++++++-------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/functions.py b/functions.py index c87b9a8..d7a46e0 100644 --- a/functions.py +++ b/functions.py @@ -40,16 +40,16 @@ def todo_function(): return -def check_eeprom_writeable(serial_port: serial.Serial, offset: int, extra: int) -> bool: +def check_eeprom_writeable(serial_port: serial.Serial, addr: int) -> bool: # 读取原始数据 - read_data = serial_utils.read_extra_eeprom(serial_port, offset, extra, 8) + read_data = serial_utils.read_extra_eeprom(serial_port, addr, 8) # 写入随机数据 random_bytes = bytes([random.randint(0, 255) for _ in range(8)]) - serial_utils.write_extra_eeprom(serial_port, offset, extra, random_bytes) + serial_utils.write_extra_eeprom(serial_port, addr, random_bytes) # 读取写入的数据 - read_write_data = serial_utils.read_extra_eeprom(serial_port, offset, extra, 8) + read_write_data = serial_utils.read_extra_eeprom(serial_port, addr, 8) # 恢复原始数据 - serial_utils.write_extra_eeprom(serial_port, offset, extra, read_data) + serial_utils.write_extra_eeprom(serial_port, addr, read_data) return read_write_data == random_bytes @@ -114,7 +114,6 @@ def write_data(serial_port: Serial, start_addr: int, data: Union[bytes, List[int total_page = data_len // 128 addr = start_addr current_step = 0 - offset = 0 while addr < start_addr + data_len: percent_float = (current_step / total_page) * 100 percent = int(percent_float) @@ -127,9 +126,7 @@ def write_data(serial_port: Serial, start_addr: int, data: Union[bytes, List[int if start_addr + data_len < 0x10000: serial_utils.write_eeprom(serial_port, addr, writing_data) else: - if addr - offset * 0x10000 >= 0x10000: - offset += 1 - serial_utils.write_extra_eeprom(serial_port, offset, addr - offset * 0x10000, writing_data) + serial_utils.write_extra_eeprom(serial_port, addr, writing_data) addr += step current_step += 1 progress['value'] = 0 @@ -672,7 +669,6 @@ def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressba total_steps = (target_eeprom_offset - start_addr) // 128 # 计算总步数 current_step = 0 addr = start_addr - offset = 0 backup_data = b'' @@ -680,9 +676,7 @@ def backup_eeprom(serial_port_text: str, window: tk.Tk, progress: ttk.Progressba if target_eeprom_offset < 0x10000: read_data = serial_utils.read_eeprom(serial_port, addr, 128) else: - if addr - offset * 0x10000 >= 0x10000: - offset += 1 - read_data = serial_utils.read_extra_eeprom(serial_port, offset, addr - offset * 0x10000, 128) + read_data = serial_utils.read_extra_eeprom(serial_port, addr, 128) backup_data += read_data addr += 128 current_step += 1 diff --git a/serial_utils.py b/serial_utils.py index 13ee5eb..31550a4 100644 --- a/serial_utils.py +++ b/serial_utils.py @@ -102,10 +102,10 @@ def read_eeprom(serial_port: serial.Serial, offset: int, length: int): return o[8:] -def read_extra_eeprom(serial_port: serial.Serial, offset: int, extra: int, length: int): - if extra > 0xFFFF: - offset = extra >> 16 - extra = extra & 0xFFFF +def read_extra_eeprom(serial_port: serial.Serial, addr: int, length: int): + offset = addr >> 16 + extra = addr & 0xFFFF + extra = struct.pack(" 0xFFFF: - offset = extra >> 16 - extra = extra & 0xFFFF +def write_extra_eeprom(serial_port: serial.Serial, addr: int, data: bytes): + offset = addr >> 16 + extra = addr & 0xFFFF extra = struct.pack(" Date: Sat, 24 Feb 2024 03:08:25 +0800 Subject: [PATCH 6/8] fix: `check_eeprom_writeable` args --- functions.py | 2 +- serial_utils.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/functions.py b/functions.py index d7a46e0..b737173 100644 --- a/functions.py +++ b/functions.py @@ -72,7 +72,7 @@ def check_serial_port(serial_port: serial.Serial, for i in range(1, 5): # 128 KiB offset 0x1, 256 KiB offset 0x3, 384 KiB offset 0x5, 512 KiB offset 0x7 # 1 -> 0x1, 2 -> 0x3, 3 -> 0x5, 4 -> 0x7 符合 2n-1 - if check_eeprom_writeable(serial_port, 2 * i - 1, 0x8000): + if check_eeprom_writeable(serial_port, (2 * i - 1) * 0x10000 + 0x8000): eeprom_size = i else: break diff --git a/serial_utils.py b/serial_utils.py index 31550a4..fe6cdab 100644 --- a/serial_utils.py +++ b/serial_utils.py @@ -105,7 +105,6 @@ def read_eeprom(serial_port: serial.Serial, offset: int, length: int): def read_extra_eeprom(serial_port: serial.Serial, addr: int, length: int): offset = addr >> 16 extra = addr & 0xFFFF - extra = struct.pack(" Date: Sat, 24 Feb 2024 04:04:25 +0800 Subject: [PATCH 7/8] fix: K firmware auto writing and writing order --- functions.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/functions.py b/functions.py index b737173..f7fb342 100644 --- a/functions.py +++ b/functions.py @@ -384,32 +384,23 @@ def auto_write_font(serial_port_text: str, window: tk.Tk, progress: ttk.Progress messagebox.showinfo('提示', f'{version_number}{version_code}版本字库\n写入成功') else: n = 4 if version_code == 'H' else 3 - m = 1 + log(f'正在进行 1/{n}: 写入{version_number}{version_code}版字库') + write_font(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, font_type, True) + log(f'正在进行 2/{n}: 写入字库配置') + write_font_conf(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) + log(f'正在进行 3/{n}: 写入亚音参数') + write_tone_options(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) if n == 4: - log(f'正在进行 {m}/{n}: 写入拼音检索表') + log(f'正在进行 4/4: 写入拼音检索表') if version_number == 123: write_pinyin_index(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) - m += 1 elif version_number > 123: write_pinyin_index(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True, True) - m += 1 - else: - return - log(f'正在进行 {m}/{n}: 写入{version_number}{version_code}版字库') - write_font(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, font_type, True) - m += 1 - log(f'正在进行 {m}/{n}: 写入字库配置') - write_font_conf(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) - m += 1 - log(f'正在进行 {m}/{n}: 写入亚音参数') - write_tone_options(serial_port_text, window, progress, status_label, eeprom_size, firmware_version, True) reset_radio(serial_port_text, status_label) - if n == 4: - messagebox.showinfo('提示', f'{version_number}{version_code}版本字库\n字库配置\n亚音参数\n拼音检索表\n写入成功!') - else: - messagebox.showinfo('提示', f'{version_number}{version_code}版本字库\n字库配置\n亚音参数\n写入成功!') + extra_msg = '拼音检索表\n' if n == 4 else '' + messagebox.showinfo('提示', f'{version_number}{version_code}版本字库\n字库配置\n亚音参数\n{extra_msg}写入成功!') else: messagebox.showinfo('提示', f'非LOSEHU扩容固件,无法写入') From 9b08259e72943b4d146839bd395683fb5b44a668 Mon Sep 17 00:00:00 2001 From: hank9999 Date: Sat, 24 Feb 2024 04:05:42 +0800 Subject: [PATCH 8/8] build: 0.6 --- main.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 16b58d9..d4e94fa 100644 --- a/main.py +++ b/main.py @@ -24,7 +24,7 @@ ) window = ttk.Window() -version = '0.5' +version = '0.6' appdata_path = os.getenv('APPDATA') if os.getenv('APPDATA') is not None else '' config_dir = os.path.join(appdata_path, 'K5_Tools') diff --git a/pyproject.toml b/pyproject.toml index bc5d911..0e7c9ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "k5-tools" -version = "0.5" +version = "0.6" description = "" authors = ["hank9999 "] readme = "README.md"