]>
git.gir.st - Ledberg-ESP8266.git/blob - hue-wheel.pl
2 # (c) 2019 Tobias Girstmair <https://gir.st/>; GPLv3
14 return ( 1, $t, 00) if $h < 1;
15 return ($q, 1, 00) if $h < 2;
16 return (00, 1, $t) if $h < 3;
17 return (00, $q, 1) if $h < 4;
18 return ($t, 00, 1) if $h < 5;
19 return ( 1, 00, $q) if $h < 6;
22 my ($type, $r, $g, $b) = @_;
23 open(my $netcat, "| nc -u $ip 1337");
24 print $netcat pack "CC", 0x01, $r if ($type eq "power");
25 print $netcat pack "CCCC", 0x02, $r*0xFF, $g*0x7F, $b*0x7F if ($type eq "color");
32 packet
"color", hue2rgb
($_, 1, 1);
33 select(undef, undef, undef, 0.2); # sub-second sleep() substitute