rgb.pl
Code:
my $ip = "localhost";
my $ga = "0/0/18";
my @rgb = (100,100,100);
write_rgb(@rgb);
sub write_rgb {
my @colors = @_;
my $bytes;
foreach my $color(@colors){
$bytes = $bytes.encode_color($color);
}
$bytes =~ s/(.{2})/$1 /g;
system ("groupwrite ip:$ip $ga $bytes");
}
sub encode_color {
my $value = shift;
$value = 100 if ($value > 100);
$value = 0 if ($value < 0);
my $byte = sprintf ("%.0f", $value * 255 / 100);
my $hex = sprintf "%x", $byte;
return $hex;
}


.
Einen Kommentar schreiben: