From 68e2c0c4815c17d353499463e5141d6c59c44b6a Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Sat, 17 Jan 2015 19:56:10 +0000 Subject: [PATCH] add min/max outside temperature --- loop.pl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/loop.pl b/loop.pl index 21c436d..ca85bbd 100755 --- a/loop.pl +++ b/loop.pl @@ -280,6 +280,7 @@ sub process } my $tmp; + my $temp; my $rain; my %h; @@ -294,8 +295,8 @@ sub process $tmp = unpack("s", substr $blk,9,2) / 10; $h{Temp_In} = nearest(0.1, f2c($tmp)); - $tmp = unpack("s", substr $blk,12,2) / 10; - $h{Temp_Out} = nearest(0.1, f2c($tmp)); + $temp = nearest(0.1, f2c(unpack("s", substr $blk,12,2) / 10)); + $h{Temp_Out} = $temp; $tmp = unpack("C", substr $blk,14,1); $h{Wind} = nearest(0.1, mph2mps($tmp)); @@ -345,6 +346,14 @@ sub process my $ts = time; my $s; + my $dayno = int($ts/86400); + if ($dayno > $ld->{last_day}) { + $ld->{Temp_Out_Max} = $ld->{Temp_Out_Min} = $temp; + $ld->{last_day} = $dayno; + } + $ld->{Temp_Out_Max} = $temp if $temp > $ld->{Temp_Out_Max}; + $ld->{Temp_Out_Min} = $temp if $temp < $ld->{Temp_Out_Min}; + if ($ts >= $ld->{last_hour} + 3600) { $h{Pressure_Trend} = unpack("C", substr $blk,3,1); $h{Pressure_Trend_txt} = $bar_trend{$h{Pressure_Trend}}; @@ -356,6 +365,8 @@ sub process $h{Sunrise} =~ s/(\d{2})(\d{2})/$1:$2/; $h{Sunset} = sprintf( "%04d", unpack("S", substr $blk,93,2) ); $h{Sunset} =~ s/(\d{2})(\d{2})/$1:$2/; + $h{Temp_Out_Max} = $ld->{Temp_Out_Max}; + $h{Temp_Out_Min} = $ld->{Temp_Out_Min}; if ($loop_count) { # i.e not the first my $a = wind_average(scalar @{$ld->{wind_hour}} ? @{$ld->{wind_hour}} : {w => $h{Wind}, d => $h{Dir}}); @@ -395,6 +406,9 @@ sub process } $ld->{last_rain_min} = $rain; + $h{Temp_Out_Max} = $ld->{Temp_Out_Max}; + $h{Temp_Out_Min} = $ld->{Temp_Out_Min}; + $s = genstr($ts, 'm', \%h); $ld->{last_min} = int($ts/60)*60; @@ -554,7 +568,7 @@ sub calc_rain $ld->{rain24} ||= []; my $Rain_1h = nearest(0.1, $rain >= $ld->{last_rain_hour} ? $rain - $ld->{last_rain_hour} : $rain); # this is the rate for this hour, so far - my $rm = $rain >= $ld->{last_rain_min} ? $rain - $ld->{last_rain_min} : $rain; + my $rm = nearest(0.1, $rain >= $ld->{last_rain_min} ? $rain - $ld->{last_rain_min} : $rain); my $Rain_1m = nearest(0.1, $rm); push @{$ld->{rain24}}, $Rain_1m; $ld->{rain_24} += $rm; -- 2.43.0