diff --git a/fhem/contrib/1-Wire/00_OWX.pm b/fhem/contrib/1-Wire/00_OWX.pm index 4b518c663..8b27d3512 100644 --- a/fhem/contrib/1-Wire/00_OWX.pm +++ b/fhem/contrib/1-Wire/00_OWX.pm @@ -6,7 +6,7 @@ # via an active DS2480/DS2490/DS9097U bus master interface or # via a passive DS9097 interface # -# Version 1.12 - April, 2012 +# Version 1.13 - May, 2012 # # Prof. Dr. Peter A. Henning, 2012 # diff --git a/fhem/contrib/1-Wire/21_OWAD.pm b/fhem/contrib/1-Wire/21_OWAD.pm index 0a85721fb..21552a96d 100644 --- a/fhem/contrib/1-Wire/21_OWAD.pm +++ b/fhem/contrib/1-Wire/21_OWAD.pm @@ -14,7 +14,7 @@ # # Prof. Dr. Peter A. Henning, 2012 # -# Version 1.12 - April, 2012 +# Version 1.13 - May, 2012 # # Setup bus device in fhem.cfg as # diff --git a/fhem/contrib/1-Wire/21_OWCOUNT.pm b/fhem/contrib/1-Wire/21_OWCOUNT.pm index 5bd62e034..037c954ed 100644 --- a/fhem/contrib/1-Wire/21_OWCOUNT.pm +++ b/fhem/contrib/1-Wire/21_OWCOUNT.pm @@ -18,7 +18,7 @@ # # Prof. Dr. Peter A. Henning, 2012 # -# Version 1.12 - April, 2012 +# Version 1.13 - May, 2012 # # Setup bus device in fhem.cfg as # diff --git a/fhem/contrib/1-Wire/21_OWID.pm b/fhem/contrib/1-Wire/21_OWID.pm index c85c25720..4d8907cd6 100644 --- a/fhem/contrib/1-Wire/21_OWID.pm +++ b/fhem/contrib/1-Wire/21_OWID.pm @@ -12,7 +12,7 @@ # # Prof. Dr. Peter A. Henning, 2012 # -# Version 1.12 - April, 2012 +# Version 1.13 - May, 2012 # # Setup bus device in fhem.cfg as # diff --git a/fhem/contrib/1-Wire/21_OWLCD.pm b/fhem/contrib/1-Wire/21_OWLCD.pm index c6b5b7136..ff15e8084 100644 --- a/fhem/contrib/1-Wire/21_OWLCD.pm +++ b/fhem/contrib/1-Wire/21_OWLCD.pm @@ -12,7 +12,7 @@ # # Prof. Dr. Peter A. Henning, 2012 # -# Version 1.12 - April, 2012 +# Version 1.13 - May, 2012 # # Setup bus device in fhem.cfg as # @@ -68,12 +68,12 @@ use warnings; sub Log($$); #-- controller may be HD44780 or KS0073 +# these values have to be changed for different display +# geometries or memory maps my $lcdcontroller = "KS0073"; my $lcdlines = 4; my $lcdchars = 20; - -#-- global variable; -my $lcddata; +my @lcdpage = (0,32,64,96); #-- declare variables my %gets = ( @@ -89,6 +89,7 @@ my %gets = ( my %sets = ( "icon" => "", "line" => "", + "alert" => "", "memory" => "", "gpio" => "", "backlight" => "", @@ -291,7 +292,7 @@ sub OWLCD_Set($@) { #-- check syntax for setting line if( $key eq "line" ){ - return "OWLCD: Set needs two parameters when setting line value: <#line> " + return "OWLCD: Set needs one or two parameters when setting line value: <#line> " if( int(@a)<3 ); $line = ($a[2] =~ m/\d/) ? $a[2] : 0; $value = $a[3]; @@ -301,12 +302,16 @@ sub OWLCD_Set($@) { #-- check syntax for setting memory } elsif( $key eq "memory" ){ return "OWLCD: Set needs two parameters when setting memory page: <#page> " - if( int(@a)<3 ); + if( int(@a)<4 ); $line = ($a[2] =~ m/\d/) ? int($a[2]) : 0; $value = $a[3]; for( $i=4; $i< int(@a); $i++){ $value .= " ".$a[$i]; } + #-- check syntax for setting alert + } elsif( $key eq "alert" ){ + return "OWLCD: Set needs a parameter when setting alert: " + if( int(@a)<3 ); #-- check syntax for setting icon } elsif ( $key eq "icon" ){ if( ($a[2] ne "0") && ($a[2] ne "none") ){ @@ -426,7 +431,26 @@ sub OWLCD_Set($@) { #-- check value and write to device Log 1,"Calling SetMemory with page $line"; OWXLCD_SetMemory($hash,$line,$value); - return undef; + return undef; + } + + #-- set alert + if($key eq "alert") { + if($value eq "beep") { + OWXLCD_SetFunction($hash,"gpio",14); + return undef; + }elsif($value eq "red") { + OWXLCD_SetFunction($hash,"gpio",13); + return undef; + }elsif($value eq "yellow") { + OWXLCD_SetFunction($hash,"gpio",11); + return undef; + }elsif($value eq "off") { + OWXLCD_SetFunction($hash,"gpio",15); + return undef; + }else{ + return "OWLCD: Set with wrong value for alert type, must be beep/red/yellow/off"; + } } #-- start test @@ -617,7 +641,7 @@ sub OWXLCD_Get($$) { ######################################################################################## # -# OWXLCD_GetMemory - get memory page from LCD device +# OWXLCD_GetMemory - get memory page from LCD device (EXPERIMENTAL) # # Parameter hash = hash of device addressed # page = memory page address @@ -983,15 +1007,25 @@ sub OWXLCD_SetLine($$$) { #-- split if longer than 16 bytes, fill each with blanks # has already been checked to be <= $lcdchars - if( length($msg) > 16 ) { - $msgA = substr($msg,0,16); - $msgB = substr($msg,16,length($msg)-16); - for($i = 0;$i<$lcdchars-length($msg);$i++){ - $msgB .= "\x20"; + if( $lcdchars > 16 ){ + if( length($msg) > 16 ) { + $msgA = substr($msg,0,16); + $msgB = substr($msg,16,length($msg)-16); + for($i = 0;$i<$lcdchars-length($msg);$i++){ + $msgB .= "\x20"; + } + } else { + $msgA = $msg; + for($i = 0;$i<16-length($msg);$i++){ + $msgA .= "\x20"; + } + for($i = 0;$i<$lcdchars-16;$i++){ + $msgB .= "\x20"; + } } - } else { + }else{ $msgA = $msg; - for($i = 0;$i<16-length($msg);$i++){ + for($i = 0;$i<$lcdchars-length($msg);$i++){ $msgA .= "\x20"; } $msgB = undef; @@ -999,26 +1033,24 @@ sub OWXLCD_SetLine($$$) { #-- issue the match ROM command \x55 and the write scratchpad command \x4E # followed by LCD page address and the text - $select=sprintf("\x55%c%c%c%c%c%c%c%c\x4E\%c",@owx_ROM_ID,$line*32).$msgA; + $select=sprintf("\x55%c%c%c%c%c%c%c%c\x4E\%c",@owx_ROM_ID,$lcdpage[$line]).$msgA; OWX_Reset($master); $res=OWX_Block($master,$select); - #select(undef,undef,undef,0.005); #-- issue the copy scratchpad to LCD command \x48 $select=sprintf("\x55%c%c%c%c%c%c%c%c\x48",@owx_ROM_ID); OWX_Reset($master); $res3=OWX_Block($master,$select); #-- if second string available: - if( length($msg) > 16 ) { + if( defined($msgB) ) { #select(undef,undef,undef,0.005); #-- issue the match ROM command \x55 and the write scratchpad command \x4E # followed by LCD page address and the text - $select=sprintf("\x55%c%c%c%c%c%c%c%c\x4E\%c",@owx_ROM_ID,$line*32+16).$msgB; + $select=sprintf("\x55%c%c%c%c%c%c%c%c\x4E\%c",@owx_ROM_ID,$lcdpage[$line]+16).$msgB; OWX_Reset($master); $res2=OWX_Block($master,$select); - #select(undef,undef,undef,0.005); #-- issue the copy scratchpad to LCD command \x48 $select=sprintf("\x55%c%c%c%c%c%c%c%c\x48",@owx_ROM_ID); OWX_Reset($master); diff --git a/fhem/contrib/1-Wire/21_OWTEMP.pm b/fhem/contrib/1-Wire/21_OWTEMP.pm index ab08edb99..4c1ffc1ad 100644 --- a/fhem/contrib/1-Wire/21_OWTEMP.pm +++ b/fhem/contrib/1-Wire/21_OWTEMP.pm @@ -16,7 +16,7 @@ # Prof. Dr. Peter A. Henning, 2012 # Martin Fischer, 2011 # -# Version 1.12 - April, 2012 +# Version 1.13 - May, 2012 # # Setup bus device in fhem.cfg as #