Colour picker code.
Piles of Wires
Posts: 8
The internal colour picker on the touchpanels is not transmited to the master.
So I wrote code to take three floats in the range 0.0 to 1.0 as a hsl colour, and create rgb colour in hex to send to buttons and use to drive lighting control from the DMX512 box.
Heres my code and the main function for those who had similar requirements.
So I wrote code to take three floats in the range 0.0 to 1.0 as a hsl colour, and create rgb colour in hex to send to buttons and use to drive lighting control from the DMX512 box.
Heres my code and the main function for those who had similar requirements.
DEFINE_FUNCTION HSLtoRGBHex(FLOAT HSL[], CHAR hexrgb[]) { FLOAT temp1, temp2, t3[3], clr[3] INTEGER index INTEGER red, green, blue IF(HSL[3]=0.0) { clr[1]=0.0 clr[2]=0.0 clr[3]=0.0 } ELSE { IF(HSL[2]=0.0) { clr[1]=HSL[3] clr[2]=HSL[3] clr[3]=HSL[3] } ELSE { IF(HSL[3]<=0.5) { temp2 = HSL[3]*(1.0+HSL[2]) } ELSE { temp2 = HSL[3]+HSL[2]-(HSL[3]*HSL[2]) } temp1 = (2.0*HSL[3])-temp2 t3[1] = HSL[1] + 0.3333 IF(t3[1] < 0.0) t3[1] = t3[1] + 1.0 IF(t3[1] > 1.0) t3[1] = t3[1] - 1.0 t3[2] = HSL[1] t3[3] = HSL[1] - 0.3333 IF(t3[3] < 0.0) t3[3] = t3[3] + 1.0 IF(t3[3] > 1.0) t3[3] = t3[3] - 1.0 FOR(index=1;index<4;index++) { IF((6.0*t3[index]) < 1.0) { clr[index]=temp1+((temp2-temp1)*t3[index]*6.0) } ELSE { IF((2.0*t3[index]) < 1.0) { clr[index]=temp2 } ELSE { IF((3.0*t3[index]) < 2.0) { clr[index]=(temp1+((temp2-temp1)*(0.6667 - t3[index])*6.0)) } ELSE { clr[index]=temp1 } } } } } } red = TYPE_CAST(clr[1]*255.0) green = TYPE_CAST(clr[2]*255.0) blue = TYPE_CAST(clr[3]*255.0) hexrgb = "FORMAT('%02X', red),FORMAT('%02X', green),FORMAT('%02X', blue)" } LEVEL_EVENT[TP,1] // Hue 0 - 255 LEVEL_EVENT[TP,2] // Sat 0 - 255 LEVEL_EVENT[TP,3] // Lum 0 - 255 { CHAR RGBH[6] // store hsl colour in global TPHSLColour[level.input.level] = level.value/255.0 // convert to RGBHex HSLtoRGBHex(TPHSLColour, RGBH); // make command to set button 1 to the picked colour SEND_COMMAND TP, "'^BCF-1,0,#',RGBH" }
0
Comments
the colour picker code is transmitted to the master
check this out
http://amxforums.com/showthread.php?t=2594
I can see trav's code that requires a button press to get the colour.
And your reply about your code but I don't see your code!?
here it is
Cheers for that
check out the little dot on the left bottom corner of the colour picker. That's actually the button i'm copying to