Skip to content

Commit

Permalink
Add flash commands to python GUI
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Oct 25, 2023
1 parent 9c243d8 commit b74d676
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion qmk_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down Expand Up @@ -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-']))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b74d676

Please sign in to comment.