Final Commit for TUI
This commit is contained in:
parent
528ca5da5b
commit
b7cd8d18e8
@ -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}...")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user