From b74d676ca76af7d9eb38441abe7a41fac7da2411 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 26 Oct 2023 07:45:43 +0800 Subject: [PATCH] Add flash commands to python GUI Signed-off-by: Daniel Schaefer --- qmk_gui.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/qmk_gui.py b/qmk_gui.py index 719ca22..98bdc5d 100755 --- a/qmk_gui.py +++ b/qmk_gui.py @@ -210,7 +210,17 @@ def main(devices): sg.Column([ [sg.Text("Factory Mode")], [sg.Button("Enable", k='-FACTORY-MODE-ENABLE-'), sg.Button("Disable", k='-FACTORY-MODE-DISABLE-')], - ]) + ]), + sg.VSeperator(), + sg.Column([ + [sg.Text("Lock Flash")], + [sg.Button("Lock", k='-LOCK-FLASH-'), sg.Button("Unlock", k='-UNLOCK-FLASH-')], + ]), + sg.VSeperator(), + sg.Column([ + [sg.Text("Read/write flash")], + [sg.Button("Read", k='-READ-FLASH-'), sg.Button("Write", k='-WRITE-FLASH-')], + ]), ], [sg.HorizontalSeparator()], @@ -298,6 +308,15 @@ def main(devices): if event == "-FACTORY-MODE-DISABLE-": factory_mode(dev, False) + if event == "-LOCK-FLASH-": + lock_flash(dev, True) + if event == "-UNLOCK-FLASH-": + lock_flash(dev, False) + if event == "-WRITE-FLASH-": + write_flash(dev, True) + if event == "-READ-FLASH-": + write_flash(dev, False) + if event == '-BRIGHTNESS-': set_brightness(dev, int(values['-BRIGHTNESS-'])) set_rgb_brightness(dev, int(values['-BRIGHTNESS-'])) @@ -578,6 +597,17 @@ def factory_mode(dev, enable): param = 0x01 if enable else 0x00 send_message(dev, BOOTLOADER_JUMP, [0x06, param], 0) +def lock_flash(dev, enable): + cmd = 0x07 if enable else 0x08 + param = 0x00 + send_message(dev, BOOTLOADER_JUMP, [cmd, param], 0) + +# Read/write flash +def write_flash(dev, enable): + cmd = 0x0A if enable else 0x09 + param = 0x00 + send_message(dev, BOOTLOADER_JUMP, [cmd, param], 0) + def set_rgb_brightness(dev, brightness): set_rgb_u8(dev, RGB_MATRIX_VALUE_BRIGHTNESS, brightness)