Final Commit for TUI

This commit is contained in:
Tempest 2025-07-25 18:15:11 +07:00
parent 528ca5da5b
commit b7cd8d18e8

View File

@ -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,13 +40,13 @@ 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)
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):