2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

added realtimePicker option

git-svn-id: https://svn.fhem.de/fhem/trunk@4405 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2013-12-16 23:27:12 +00:00
parent f1f3a5cbee
commit c8efc64bfe
3 changed files with 45 additions and 11 deletions

View File

@ -60,6 +60,7 @@ sub HUEDevice_Initialize($)
$hash->{GetFn} = "HUEDevice_Get";
$hash->{AttrList} = "IODev ".
"delayedUpdate:1 ".
"realtimePicker:1 ".
"color-icons:1,2 ".
"model:".join(",", sort keys %hueModels)." ".
"subType:colordimmer,dimmer,switch ".
@ -312,6 +313,8 @@ HUEDevice_SetParam($$@)
$defs{$name}->{fhem}->{update_timeout} = 1;
} elsif( $cmd eq "immediateUpdate" ) {
$defs{$name}->{fhem}->{update_timeout} = 0;
} elsif( $cmd eq "noUpdate" ) {
$defs{$name}->{fhem}->{update_timeout} = -1;
} else {
return 0;
}
@ -345,6 +348,18 @@ HUEDevice_Set($@)
HUEDevice_SetParam($name, \%obj, $cmd, $value, $value2);
}
# if( $defs{$name}->{fhem}->{update_timeout} == -1 ) {
# my $diff;
# my ($seconds, $microseconds) = gettimeofday();
# if( $defs{$name}->{fhem}->{timestamp} ) {
# my ($seconds2, $microseconds2) = @{$defs{$name}->{fhem}->{timestamp}};
#
# $diff = (($seconds-$seconds2)*1000000 + $microseconds-$microseconds2)/1000;
# }
# $defs{$name}->{fhem}->{timestamp} = [$seconds, $microseconds];
#
# return undef if( $diff < 100 );
# }
if( scalar keys %obj ) {
my $result;
@ -358,7 +373,8 @@ HUEDevice_Set($@)
return undef;
}
if( $defs{$name}->{fhem}->{update_timeout}
if( $defs{$name}->{fhem}->{update_timeout} == -1 ) {
} elsif( $defs{$name}->{fhem}->{update_timeout}
&& !$hash->{fhem}->{group} ) {
RemoveInternalTimer($hash);
InternalTimer(gettimeofday()+1, "HUEDevice_GetUpdate", $hash, 1);

View File

@ -46,6 +46,13 @@ FHEM_colorpickerFn($$$)
'border:1px solid #fff;border-radius:8px;background-color:#'. $args[1] .';"></div>'.
'</a>'.
'</td>';
} elsif(AttrVal($d,"realtimePicker",0)) {
my $c = "$FW_ME?XHR=1&cmd=set $d $cmd %$srf";
my $ci = $c;
$ci = "$FW_ME?XHR=1&cmd=set $d $cmd % : transitiontime 0 : noUpdate$srf" if($defs{$d}->{TYPE} eq "HUEDevice");
return '<td align="center">'.
"<input maxlength='6' size='6' id='colorpicker.$d-RGB' class=\"color {pickerMode:'$mode',pickerFaceColor:'transparent',pickerFace:3,pickerBorder:0,pickerInsetColor:'red',command:'$ci',onImmediateChange:'colorpicker_setColor(this)'}\" value='$cv' onChange='colorpicker_setColor(this,\"$mode\",\"$c\")'>".
'</td>';
} else {
my $c = "$FW_ME?XHR=1&cmd=set $d $cmd %$srf";
return '<td align="center">'.
@ -112,7 +119,7 @@ RgbToChannels($$) {
sub
ChannelsToRgb(@) {
my @channels = @_;
return sprintf("%02X" x @_, @_);
return sprintf("%02X" x @_, @_);
}
sub
@ -124,14 +131,15 @@ ChannelsToBrightness(@) {
$max = $value if ($max < $value);
}
return {
bri => 0,
channels => \(255 x @channels),
} unless ($max > 0);
my @bri = ();
if( $max == 0) {
@bri = (0) x @channels;
} else {
my $norm = 255/$max;
foreach my $value (@channels) {
push @bri,int($value*$norm);
}
my $norm = 255/$max;
foreach my $value (@channels) {
push @bri,int($value*$norm);
}
return {

View File

@ -9,13 +9,23 @@ FW_colorpickerUpdateLine(d)
if(el) {
el.color.fromString(d[1]);
}
}
function
colorpicker_setColor(el,mode,cmd)
{
var v = el.color;
if(mode==undefined) {
mode=el.pickerMode;
}
if(cmd==undefined) {
cmd=el.command;
}
if(v==undefined) {
v=el.toString();
}
if(mode=="HSV") {
v = (0x100 | Math.round(42*el.color.hsv[0])).toString(16).substr(1) +
(0x100 | Math.round(255*el.color.hsv[1])).toString(16).substr(1) +
@ -31,7 +41,7 @@ colorpicker_setColor(el,mode,cmd)
document.location = cmd.replace('%',v);
}
FW_widgets['colorpicker'] = {
FW_widgets['colorpicker'] = {
updateLine:FW_colorpickerUpdateLine
};