mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
ZWave: multilevel signed values by simli
git-svn-id: https://svn.fhem.de/fhem/trunk@4854 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f713ee665f
commit
e13d0b1a5e
@ -484,9 +484,12 @@ ZWave_ParseMultilevel($$$)
|
||||
|
||||
my $pr = (hex($fl)>>5)&0x07; # precision
|
||||
my $sc = (hex($fl)>>3)&0x03; # scale
|
||||
my $bc = (hex($fl)>>0)&0x07; # bytecount
|
||||
my $msb = (hex($arg)>>8*$bc-1); # most significant bit ( 0 = pos, 1 = neg )
|
||||
my $val = $msb ? -( 2 ** (8 * $bc) - hex($arg) ) : hex($arg); # 2's complement
|
||||
my $ml = $ml_tbl{$type};
|
||||
return "UNKNOWN multilevel type: $type fl: $fl arg: $arg" if(!$ml);
|
||||
return sprintf("%s:%.*f %s", $ml->{n}, $pr, hex($arg)/(10**$pr),
|
||||
return sprintf("%s:%.*f %s", $ml->{n}, $pr, $val/(10**$pr),
|
||||
int(@{$ml->{st}}) > $sc ? $ml->{st}->[$sc] : "");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user