//RGBW Lichtsteuerung mit Magic-UFO Wifi controller //Version 0.1 by N1ghth4wk //Version 0.2 by RL //Version 0.3 by Iksi char szBuffer[128]; unsigned char intro, R, G, B, W, K, cs; float iA, iR, iG, iB, iW, iK; //Eingangswerte in Gleitpunkt float sA, sW, sK; //gespeicherte Variablen von letzen Senden char isON, ON; char cnt; isON = 0; intro = 0x31; while(TRUE) { //von Eingängen gelesen iA = getinput(0) ; iW = getinput(1); iK = getinput(2); if ((iA!=sA) || (iW!=sW) || (iK!=sK)) { sA = iA; sW = iW; sK = iK; iB = iA / 1000000; B = (int)iB; iA = iA - (float)B * 1000000; iG = iA / 1000; G = (int)iG; iR = iA - (float)G * 1000; R = (int)iR; iR = iR * 2.55; iG = iG * 2.55; iB = iB * 2.55; iW = iW * 2.55; B = (int)iB; G = (int)iG; R = (int)iR; W = (int)iW; if ((B==0) && (G==0 ) && (R==0 )) { iB = W * iK / 100; B = (int)iB; G = B; R = B; } if ((B!=0) || (G!=0 ) || (R!=0 ) || (W!=0 )) { ON = 1; cs = intro + R + G + B + W + 0 + 0; STREAM* stream = stream_create("/dev/tcp/192.168.178.29/5577",0,0); sprintf(szBuffer,"%c%c%c%c%c%c%c%c",intro, R, G, B, W, 0, 0, cs); stream_write(stream,szBuffer,8); stream_flush(stream); stream_close(stream); sleep(10); } else { ON = 0; } if (ON != isON) { isON = ON; if (ON) { sprintf(szBuffer,"%c%c%c", 0x71, 0x23, 0x94); } else { sprintf(szBuffer,"%c%c%c", 0x71, 0x24, 0x95); } STREAM* stream2 = stream_create("/dev/tcp/192.168.178.29/5577",0,0); stream_write(stream2,szBuffer,3); stream_flush(stream2); stream_close(stream2); sleep(10); } } sleep(10); }