Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import time
- global aSocket
- global IP
- global PORT
- IP = "192.168.1.204"
- PORT = 8899
- aSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
- def sendOnCommand(zone=0):
- codes = bytes([0x42, 0x45, 0x47, 0x49, 0x4B])
- sendCommand(codes[zone], 0x00)
- time.sleep(0.1)
- def sendOffCommand(zone=0):
- codes = bytes([0x41, 0x46, 0x48, 0x4A, 0x4C])
- sendCommand(codes[zone], 0x00)
- def sendWhiteCommand(zone=0):
- sendOnCommand(zone)
- codes = bytes([0xC2, 0xC5, 0xC7, 0xC9, 0xCB])
- sendCommand(codes[zone], 0x00)
- def sendDiscoCommand(zone=0):
- sendOnCommand(zone)
- sendCommand(0x4D, 0x00)
- def sendDiscoDecCommand(zone=0):
- sendOnCommand(zone)
- sendCommand(0x43, 0x00)
- def sendDiscoIncCommand(zone=0):
- sendOnCommand(zone)
- sendCommand(0x44, 0x00)
- #brightness between 0 & 18
- def sendBrightnessCommand(zone, brightness):
- sendOnCommand(zone)
- codes = bytes([0x02, 0x03, 0x04, 0x05, 0x08, 0x09, 0x0A, 0x0B, 0x0D, 0x0E, 0x0F, 0x10, 0x12, 0x13, 0x14, 0x15, 0x17, 0x18, 0x19])
- sendCommand(0x4E, codes[brightness])
- #brightness between 0 & 255
- #note there are more colours (0-255) in between, this color chart is just steps of 16.
- # 0x00 Violet
- # 0x10 Royal_Blue
- # 0x20 Baby_Blue
- # 0x30 Aqua
- # 0x40 Mint
- # 0x50 Seafoam_Green
- # 0x60 Green
- # 0x70 Lime_Green
- # 0x80 Yellow
- # 0x90 Yellow_Orange
- # 0xA0 Orange
- # 0xB0 Red
- # 0xC0 Pink
- # 0xD0 Fusia
- # 0xE0 Lilac
- # 0xF0 Lavendar
- def sendColorCommand(zone, color):
- sendOnCommand(zone)
- sendCommand(0x40, color)
- def sendCommand(code, param):
- sendData(bytes([code, param, 0x55]))
- def sendData(byArr):
- aSocket.sendto(byArr, (IP, PORT))
- #sendWhiteCommand(0)
- #sendBrightnessCommand(0,0)
- #time.sleep(3)
- #sendBrightnessCommand(0,18)
- #col = 0
- #while True:
- # sendColorCommand(0, col)
- # col = col + 1
- # time.sleep(0.1)
- #sendColorCommand(0, 255)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement