You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
command_packet=bytearray.fromhex("04 44 4F 4F 54 01 00 00 00 00 00 00 00 00 00 00") # I think the 01 is an indication is there is more data to follow. Max payload size per message is 96 pixels
118
-
write_packet(command_packet)
119
-
ifLAMP_COUNT>96:
120
-
print("Too many lamps. Truncating to 96")
121
-
count=96
122
-
else:
123
-
count=LAMP_COUNT
124
-
colour_data=build_rainbow_colour_list(count)
125
-
payload= []
126
-
payload.append(0) # Needs to be overwritten with the length of the colour data
127
-
payload.append(0) # Might be second byte of length? Max length of my lights is 100, so I don't know
128
-
foreachincolour_data:
129
-
r, g, b=each
130
-
payload.append(0) # Start of data
131
-
payload.append(1) # Number of pixels to be this colour
colour_data.append(0) # Needs to be overwritten with the length of the colour data
138
+
colour_data.append(pos) # Sequence number
139
+
pos+=1
140
+
forpixelinchunk:
141
+
print(f"Chunk: {chunk}")
142
+
#print(f"Pixel: {pixel}")
143
+
144
+
colour_data.append(0) # Start of data
145
+
colour_data.append(1) # Number of pixels to be this colour.
146
+
# There is an optimisation to be done here. If the next pixel is the same colour
147
+
# you can change this number to be the number of pixels that are the same colour.
148
+
# That will shorten the message and so the time it takes to send it. In the interests
149
+
# of simplicity, I'm not doing that here. Each pixel is assumed to be a different colour.
150
+
r, g, b=pixel
151
+
colour_data.append(r>>3) # Shifting right 3 bits to get 5 bit colour and so lower the brightness to save over loading the voltage regulator on the controller
0 commit comments