This commit is contained in:
Greenman999 2025-09-12 04:14:30 +02:00
parent 3679e3e8e8
commit 65ed4dff1d
2 changed files with 143 additions and 17 deletions

18
main.py
View file

@ -40,24 +40,8 @@ def listen_i2c(bus_number, address, register=0x00):
print("Stopped listening.")
finally:
bus.close()
print("closed bus")
def create_led_color_packet(r, g, b):
"""
Create an 8-byte packet to set LED color for I2C transfer.
Packet format:
[0x10, 0x00, R, G, B, 0x00, 0x00, checksum]
- 0x10: Command for LED color
- 0x00: Target/channel (set as needed)
- R, G, B: Color bytes (0-255)
- 0x00, 0x00: Unused
- checksum: XOR of bytes 0-6
"""
packet = [0x10, 0x00, r & 0xFF, g & 0xFF, b & 0xFF, 0x00, 0x00]
checksum = 0
for b in packet:
checksum ^= b
packet.append(checksum)
return bytes(packet)
if __name__ == "__main__":
if len(sys.argv) < 3: