Skip to content

Commit

Permalink
remove log, update button text
Browse files Browse the repository at this point in the history
  • Loading branch information
yulei committed May 3, 2024
1 parent f9ac255 commit 667311f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
16 changes: 9 additions & 7 deletions src/main/python/amk/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@

DOWNLOAD_BTN_CONVERTING = "Converting 正在转换"
DOWNLOAD_BTN_UPLOAD = "Uploading 正在上传"
DOWNLOAD_BTN_NORMAL = "Upload to keyboard 上传到键盘"
DOWNLOAD_BTN_NORMAL = "Upload to keyboard (Standard Mode) 上传到键盘(标准模式)"

FASTDOWNLOAD_BTN_UPLOAD = "Quick uploading 正在上传"
FASTDOWNLOAD_BTN_NORMAL = "Quick upload to keyboard 上传到键盘"
FASTDOWNLOAD_BTN_UPLOAD = "Uploading 正在上传"
FASTDOWNLOAD_BTN_NORMAL = "Upload to keyboard (Advance Mode) 上传到键盘(高级模式)"

COPY_BTN_DOWNLOAD = "Downloading 正在下载"
COPY_BTN_NORMAL = "Download 下载"
Expand Down Expand Up @@ -583,7 +583,8 @@ def rebuild(self, device):
self.keyboard = device.keyboard
self.rebuild_ui()
if self.keyboard.animations["transfer"] == "fast":
self.keyboard.fast_init(device)
if not self.keyboard.fast_init(device):
self.fastdownload_btn.setEnabled(False)
else:
self.fastdownload_btn.hide()

Expand Down Expand Up @@ -636,7 +637,8 @@ def on_task_done(self, refresh):
self.download_btn.setText(DOWNLOAD_BTN_NORMAL)
self.download_btn.setEnabled(True)
self.fastdownload_btn.setText(FASTDOWNLOAD_BTN_NORMAL)
self.fastdownload_btn.setEnabled(True)
if self.keyboard.fast_available():
self.fastdownload_btn.setEnabled(True)
self.copy_btn.setText(COPY_BTN_NORMAL)
self.copy_btn.setEnabled(True)
self.convert_btn.setText(CONVERT_BTN_NORMAL)
Expand Down Expand Up @@ -667,10 +669,10 @@ def is_space_available(self, frame_size):
free_space = self.keyboard.animations["disk"].get("free_space")

if free_space is None:
print("don't get free space")
#print("don't get free space")
return False

print("Free sapce:{}, File size:{}".format(free_space, total))
#print("Free sapce:{}, File size:{}".format(free_space, total))
return free_space > total

def on_download_btn_clicked(self):
Expand Down
2 changes: 1 addition & 1 deletion src/main/python/amk/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def on_im_btn(self):
pole = kbd.get("pole", None)
if pole is not None:
self.keyboard.apply_pole(pole)
print("set pole as {}".format(pole))
#print("set pole as {}".format(pole))
nkro = kbd.get("nkro", None)
if nkro is not None:
self.keyboard.apply_nkro(nkro)
Expand Down
21 changes: 11 additions & 10 deletions src/main/python/amk/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ def reload_anim_file_list(self):
total_file, free_space, total_space = struct.unpack("<BII", data[3:12])
self.animations["disk"] = {"total_file":total_file, "free_space":free_space, "total_space":total_space}
self.animations["file"] = []
print("total file: {}, free space: {}, total space: {}".format(total_file, free_space, total_space))
#print("total file: {}, free space: {}, total space: {}".format(total_file, free_space, total_space))
for i in range(total_file):
data = self.usb_send(self.dev,
struct.pack("BBB", AMK_PROTOCOL_PREFIX, AMK_PROTOCOL_GET_FILE_INFO, i),
Expand All @@ -769,26 +769,27 @@ def reload_anim_file_list(self):
def fast_init(self, keyboard):
if keyboard is None:
print("hid device not initialized")
return
return False
be = usb.backend.libusb1.get_backend(find_library=libusb_package.find_library)
self.fastdev = usb.core.find(backend=be, idVendor=keyboard.desc["vendor_id"], idProduct=keyboard.desc["product_id"])
if self.fastdev is None:
print("can't find dev")
else:
print(self.fastdev)
return False
return True

def fast_available(self):
return self.fastdev is not None

def fastopen_anim_file(self, name, read, index=0xFF):
data = struct.pack("BBBB", AMK_PROTOCOL_PREFIX, AMK_PROTOCOL_OPEN_FILE, index, 1 if read else 0) + bytearray(name, "utf-8")
data += b"\x00" * (64 - len(data))

self.fastdev.write(4, data)
data = self.fastdev.read(0x84, 64)
print(data)
if data[2] == AMK_PROTOCOL_OK:
print("Open file at index:", data[3])
#print("Open file at index:", data[3])
return data[3]
else:
print("Failed to open file: ", name)
#print("Failed to open file: ", name)
return 0xFF

def fastwrite_anim_file(self, index, data, offset):
Expand Down Expand Up @@ -904,7 +905,7 @@ def reload_amk_rgb_matrix(self):
self.amk_rgb_matrix["mode"]["custom"] = data[4]
self.amk_rgb_matrix["mode"]["total"] = data[5]
self.amk_rgb_matrix["mode"]["default"] = data[6]
print("RGB Matrix: current={}, custom={}, total={}, default={}".format(data[3], data[4], data[5], data[6]))
#print("RGB Matrix: current={}, custom={}, total={}, default={}".format(data[3], data[4], data[5], data[6]))

self.amk_rgb_matrix["data"] = {}
for i in range(self.rows):
Expand Down Expand Up @@ -950,7 +951,7 @@ def apply_rgb_matrix_mode(self, index, mode):
def get_rgb_matrix_led_index(self, row, col):
index = self.amk_rgb_matrix["data"].get((row, col)) - self.amk_rgb_matrix["start"]
if index is None:
print("get led index at row: {}, col: {}".format(row, col))
#print("get led index at row: {}, col: {}".format(row, col))
return None
if index >= len(self.amk_rgb_matrix["leds"]):
return None
Expand Down

0 comments on commit 667311f

Please sign in to comment.