В приложение добавлено отключени от мышки, чтобы её потом можно было подключить

также добавлен удобный ярлык для доступа к приложению
This commit is contained in:
2025-05-23 20:52:57 +03:00
parent 90245151d9
commit 8166052960
10 changed files with 8320 additions and 8299 deletions

BIN
BallMouse.exe.lnk Normal file

Binary file not shown.

View File

@@ -7,6 +7,7 @@ from bleak import BleakClient, BleakScanner
import math
TARGET_NAME = "Ball Mouse"
TARGET_MAC = "50:78:7D:1A:0C:79"
COLOR_SERVICE_UUID = "12345678-1234-5678-1234-56789abcdef0"
COLOR_CHAR_R_UUID = "12345678-1234-5678-1234-56789abcdef1"
@@ -258,9 +259,26 @@ def run_gui():
threading.Thread(target=connect_and_sync).start()
def disconnect():
if ble.client and ble.client.is_connected:
def disconnect_task():
try:
asyncio.run(ble.client.disconnect())
print("BLE отключено")
root.after(0, lambda: label.config(text="Отключено от устройства"))
except Exception as e:
print("Ошибка при отключении:", e)
root.after(0, lambda: label.config(text=f"Ошибка при отключении: {e}"))
threading.Thread(target=disconnect_task).start()
else:
print("Нет активного подключения")
label.config(text="Нет активного подключения")
def on_close():
disconnect()
root.destroy()
root.protocol("WM_DELETE_WINDOW", on_close)
connect_btn = Button(root, text="Подключиться к мыши", command=on_connect)
connect_btn.pack(pady=10)
@@ -268,6 +286,9 @@ def run_gui():
read_btn = Button(root, text="Считать", command=on_read)
read_btn.pack(pady=10)
disconnect_button = Button(root, text="Отключиться от мыши", command=disconnect)
disconnect_button.pack(pady=5)
root.mainloop()
if __name__ == "__main__":

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.