From b7cd8d18e81addb6a6f3f56c19084cc56bd4f919 Mon Sep 17 00:00:00 2001 From: Tempest Date: Fri, 25 Jul 2025 18:15:11 +0700 Subject: [PATCH] Final Commit for TUI --- src/controllerSoftware/run.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/controllerSoftware/run.py b/src/controllerSoftware/run.py index 9d8b5df..9a44db5 100644 --- a/src/controllerSoftware/run.py +++ b/src/controllerSoftware/run.py @@ -16,14 +16,14 @@ colorArray = ["500000","005000","000050"] colorArrayTest = ["050000","000500"] def sectionInitializer(): - result = [0] * lampAmount + result = [b'\x00\x00\x00'] * lampAmount return result -def sectionSerializer(section): +def sectionSerializer(section, color): result = sectionInitializer() sectionResult = LampArray[section] for pos in sectionResult: - result[pos] = 1 + result[pos] = int(color,16).to_bytes(3) return result def posColorByte(pos, section, color): @@ -40,14 +40,14 @@ async def setOnUserInput(client, chars): await setLampToColor(client, chars, configZone, configColor, configColorCenter) async def setLampToColor(bleClient, bleChars, section, color, colorCenter): - sectionSerial = sectionSerializer(section) - colorCenterFactor = int(colorCenter, 16)/int(color,16) - sectionSerial[0] = colorCenterFactor + sectionSerial = sectionSerializer(section, color) + sectionSerial[0] = int(colorCenter,16).to_bytes(3) for char in bleChars: lampPos = bleChars.index(char) - print(f"Setting Lamp number {lampPos}") - value = posColorByte(lampPos, sectionSerial, color) - await bleClient.write_gatt_char(char.uuid, value) + value = sectionSerial[lampPos] + print(f"Setting Lamp number {lampPos} to {value}") + + await bleClient.write_gatt_char(char.uuid, value) async def connect_to_ble_device(device_name): print(f"Scanning for device: {device_name}...")