2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-24 02:59:22 +00:00

added Color_devStateIcon() function

git-svn-id: https://svn.fhem.de/fhem/trunk@4303 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2013-11-30 22:07:38 +00:00
parent 4f058a51fe
commit 8c6959efd7

View File

@ -54,6 +54,45 @@ FHEM_colorpickerFn($$$)
}
}
my %dim_values = (
0 => "dim06%",
1 => "dim12%",
2 => "dim18%",
3 => "dim25%",
4 => "dim31%",
5 => "dim37%",
6 => "dim43%",
7 => "dim50%",
8 => "dim56%",
9 => "dim62%",
10 => "dim68%",
11 => "dim75%",
12 => "dim81%",
13 => "dim87%",
14 => "dim93%",
);
sub
Color_devStateIcon($)
{
my ($rgb) = @_;
my @channels = RgbToChannels($rgb,3);
my $dim = ChannelsToBrightness(@channels);
my $percent = $dim->{bri};
my $RGB = ChannelsToRgb(@{$dim->{channels}});
return ".*:off:toggle"
if( $rgb eq "off" || $rgb eq "000000" || $percent == 0 );
$percent = 100 if( $rgb eq "on" );
my $s = $dim_values{int($percent/7)};
$s="on" if( $percent eq "100" );
return ".*:$s@#$RGB:toggle" if( $percent < 100 );
return ".*:on@#$rgb:toggle";
}
package Color;
require Exporter;
our @ISA = qw(Exporter);
@ -72,6 +111,7 @@ RgbToChannels($$) {
sub
ChannelsToRgb(@) {
return "abc";
my @channels = @_;
return sprintf("%02X" x @_, @_);
}