From 9fb9a3a9700ef4faab90bf280de7fa91f50be82d Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Tue, 5 May 2020 12:30:29 +0000 Subject: [PATCH] 60_Watches: contrib 0.17.0 git-svn-id: https://svn.fhem.de/fhem/trunk@21870 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/60_Watches.pm | 64 ++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/fhem/contrib/DS_Starter/60_Watches.pm b/fhem/contrib/DS_Starter/60_Watches.pm index 346dd9892..9aa3788e6 100644 --- a/fhem/contrib/DS_Starter/60_Watches.pm +++ b/fhem/contrib/DS_Starter/60_Watches.pm @@ -72,6 +72,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "0.17.0" => "05.05.2020 new attr 'digitalTextTicker', 'digitalTextDigitNumber' ", "0.16.0" => "04.05.2020 delete attr 'digitalDisplayText', new setter 'displayText', 'displayTextDel' ", "0.15.1" => "04.05.2020 fix permanently events when no alarmTime is set in countdownwatch and countdown is finished ", "0.15.0" => "04.05.2020 new attribute 'digitalSegmentType' for different segement count, also new attributes ". @@ -114,6 +115,8 @@ sub Initialize { "digitalSegmentDistance:slider,0,0.1,5,1 ". "digitalSegmentType:7,14,16 ". "digitalSegmentWidth:slider,0.3,0.1,3.5,1 ". + "digitalTextTicker:1,0 ". + "digitalTextDigitNumber ". "disable:1,0 ". "hideDisplayName:1,0 ". "htmlattr ". @@ -324,6 +327,12 @@ sub Attr { my $ms = int(time*1000); readingsSingleUpdate($hash, "starttime", $ms, 0); } + } + + if ($cmd eq "set") { + if ($aName eq "digitalTextDigitNumber" && $aVal !~ /^\d+$/x) { + return qq{The value of "$aName" is not valid. Only integers are allowed !}; + } } return; @@ -397,13 +406,16 @@ sub digitalWatch { my $addd = AttrVal($d, "digitalDigitDistance", 2); my $adsd = AttrVal($d, "digitalSegmentDistance", 0.5); my $adda = AttrVal($d, "digitalDigitAngle", 9); + my $adtt = AttrVal($d, "digitalTextTicker", 0); + my $adtdn = AttrVal($d, "digitalTextDigitNumber", 0); my $ddt = ReadingsVal($d, "displayText", "----"); $ddt =~ s/[\r\n]//g; my $alarm = " ".ReadingsVal($d, "alarmTime", "aa:bb:cc"); - my $ddp = "###:##:##"; # dummy - my ($h,$m,$s) = (0,0,0); + my $ddp = "###:##:##"; # dummy + my ($h,$m,$s,$txtc) = (0,0,0,0); + my $forerun = ""; # init Vorlauf bei Laufschrift if($addp eq "watch") { $ddp = "###:##:##"; @@ -412,7 +424,7 @@ sub digitalWatch { + ':' + ((seconds < 10) ? '0' : '') + seconds"; } elsif ($addp eq "stopwatch" || $addp eq "countdownwatch") { - $alarmdef = "aa:bb:cc" if($addp eq "stopwatch"); # Stoppuhr bei Start 00:00:00 nicht Alerm auslösen + $alarmdef = "aa:bb:cc" if($addp eq "stopwatch"); # Stoppuhr bei Start 00:00:00 nicht Alerm auslösen $ddp = "###:##:##"; $ddt = "((hours_$d < 10) ? ' 0' : ' ') + hours_$d + ':' + ((minutes_$d < 10) ? '0' : '') + minutes_$d @@ -428,11 +440,15 @@ sub digitalWatch { + ':' + ((seconds_$d < 10) ? '0' : '') + seconds_$d"; } elsif ($addp eq "text") { - my $txtc = length($ddt); - $ddp = ""; - for(my $i = 0; $i <= $txtc; $i++) { - $ddp .= "#"; + $txtc = length($ddt); + $txtc = $adtdn if($adtdn); # per Attribut definierte Anzahl der TextDigits im Display + $ddp = ""; + + for(my $i = 0; $i <= $txtc; $i++) { # die Anzahl der TextDigits im Display berechnen + $ddp .= "#"; + $forerun .= " "; # Vorlauf bei Laufschrift = Länge des Schriftzuges (default) } + $ddt = "' ".$ddt."'"; } @@ -1272,11 +1288,23 @@ sub digitalWatch { seconds_$d = 0; localStoreSet (hours_$d, minutes_$d, seconds_$d); - localStoreSetLastalm ('NaN'); // letzte Alarmzeit zurücksetzen + localStoreSetLastalm ('NaN'); // letzte Alarmzeit zurücksetzen } } var value = $ddt; + + if (watchkind_$d == 'text' && $adtt == 1) { // Laufschrift anzeigen + var rttime = new Date(); + var rthours = rttime.getHours(); + var rtminutes = rttime.getMinutes(); + var rtseconds = rttime.getSeconds(); + var rtmillis = rttime.getMilliseconds(); + // var text = ' abcdefghijklmnopqrstuvwxyz 0123456789 '; + var text = '$forerun'+value+' '; + var index = ( 2 * (rtseconds + 60*rtminutes + 24*60*rthours) + Math.floor(rtmillis / 500) ) % (text.length - 6); + value = text.substr(index, $txtc+parseInt(1)); + } if(value == ' undefined:undefined:undefined' || value == ' NaN:NaN:NaN') { value = ' : : '; @@ -2218,7 +2246,7 @@ Als Zeitquelle können sowohl der Client (Browserzeit) als auch der FHEM-Server
  • htmlattr
    - Zusätzliche HTML Tags zur Größenänderung de Uhr.

    + Zusätzliche HTML Tags zur Größenänderung der Uhr / Anzeige.