From f224014b7580dae80b8f33e092fcefe1bf1a40e2 Mon Sep 17 00:00:00 2001 From: klauswitt <> Date: Tue, 6 Sep 2016 21:47:53 +0000 Subject: [PATCH] 51_RPI_GPIO: fixed "Use of uninitialized value in subtraction (-) at ./FHEM/51_RPI_GPIO.pm line 524" again git-svn-id: https://svn.fhem.de/fhem/trunk@12129 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/51_RPI_GPIO.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/51_RPI_GPIO.pm b/fhem/FHEM/51_RPI_GPIO.pm index c2130ddea..ddb3c25a3 100644 --- a/fhem/FHEM/51_RPI_GPIO.pm +++ b/fhem/FHEM/51_RPI_GPIO.pm @@ -62,6 +62,7 @@ sub RPI_GPIO_Initialize($) { " interrupt:none,falling,rising,both" . " toggletostate:no,yes active_low:no,yes" . " debounce_in_ms restoreOnStartup:no,yes,on,off,last" . + " dblclicklevel:0,1 dblclicktime" . " unexportpin:no,yes longpressinterval" . " $readingFnAttributes"; } @@ -507,9 +508,11 @@ sub RPI_GPIO_Except($) { #called from main if an interrupt occured Log3 $hash, 5, "Zaehler ist jetzt $valcnt"; } #Doppelklick (noch im Teststatus) - my $testtt = (gettimeofday() - $hash->{lasttrg} ); + if (defined($hash->{lasttrg})) { + my $testtt = (gettimeofday() - $hash->{lasttrg} ); + readingsSingleUpdate($hash, 'Dblclick', "on", 1) if $testtt < 2; + } $hash->{lasttrg} = gettimeofday(); - readingsSingleUpdate($hash, 'Dblclick', "on", 1) if $testtt < 2; #langer Testendruck } elsif ($eval eq "both") { if ( $val == 1 ) { @@ -521,9 +524,11 @@ sub RPI_GPIO_Except($) { #called from main if an interrupt occured } #Doppelklick (noch im Teststatus) if ( $val == AttrVal($hash->{NAME}, "dblclicklevel", "1") ) { - my $testtt = (gettimeofday() - $hash->{lasttrg} ); + if (defined $hash->{lasttrg}) { + my $testtt = (gettimeofday() - $hash->{lasttrg} ); + readingsSingleUpdate($hash, 'Dblclick', "on", 1) if $testtt < int(AttrVal($hash->{NAME}, "dblclicktime", 2)); + } $hash->{lasttrg} = gettimeofday(); - readingsSingleUpdate($hash, 'Dblclick', "on", 1) if $testtt < 2; } else { readingsSingleUpdate($hash, 'Dblclick', "off", 1); }