+ $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}};
+ $h{Batt_TX_OK} = (unpack("C", substr $blk,86,1)+0) ^ 1;
+ $h{Batt_Console} = nearest(0.01, unpack("s", substr $blk,87,2) * 0.005859375);
+ $h{Forecast_Icon} = unpack("C", substr $blk,89,1);
+ $h{Forecast_Rule} = unpack("C", substr $blk,90,1);
+ $h{Sunrise} = sprintf( "%04d", unpack("S", substr $blk,91,2) );
+ $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}});
+
+ $h{Wind_1h} = nearest(0.1, $a->{w});
+ $h{Dir_1h} = nearest(0.1, $a->{d});
+
+ $a = wind_average(@{$ld->{wind_min}});
+ $h{Wind_1m} = nearest(0.1, $a->{w});
+ $h{Dir_1m} = nearest(1, $a->{d});
+
+ ($h{Rain_1m}, $h{Rain_1h}, $h{Rain_24h}) = calc_rain($rain);
+ }
+ $ld->{last_rain_min} = $ld->{last_rain_hour} = $rain;
+
+ $s = genstr($ts, 'h', \%h);
+
+ $ld->{last_hour} = int($ts/3600)*3600;
+ $ld->{last_min} = int($ts/60)*60;
+ @{$ld->{wind_hour}} = ();
+ @{$ld->{wind_min}} = ();
+
+ write_ld();
+
+ } elsif ($ts >= $ld->{last_min} + 60) {
+ my $a = wind_average(@{$ld->{wind_min}});
+ my %save;
+
+ push @{$ld->{wind_hour}}, $a;
+
+ if ($loop_count) { # i.e not the first
+ my $rm;
+
+ $h{Wind_1m} = nearest(0.1, $a->{w});
+ $h{Dir_1m} = nearest(1, $a->{d});
+ ($h{Rain_1m}, $h{Rain_1h}, $h{Rain_24h}) = calc_rain($rain);
+ }
+ $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;
+ @{$ld->{wind_min}} = ();
+
+ write_ld();
+
+ } else {
+ my $o = gen_hash_diff($ld->{last_h}, \%h);
+ if ($o) {
+ $s = genstr($ts, 'r', $o);
+ }
+ else {
+ dbg "loop rec not changed" if isdbg 'chan';
+ }