fix windrose and other tarting
[dweather.git] / loop.pl
diff --git a/loop.pl b/loop.pl
index fe9165779d3ac551e9b0a66a9ecb5b943e9f016b..e287ce5913b0370d0aa32345ac6348b42b343541 100755 (executable)
--- a/loop.pl
+++ b/loop.pl
@@ -42,8 +42,9 @@ our $WS = {};                                 # websocket connections
 our $ld = {};
 our @last10minsr = ();
 our @last5daysh = ();
-our $windmins = 5;                             # no of minutes of wind data for the windrose
+our $windmins = 2;                             # no of minutes of wind data for the windrose
 our $histdays = 5;                             # no of days of (half)hour data to search for main graph
+our $updatepermin = 60 / 2.5;  # no of updates per minute
 
 our $loop_count;                               # how many LOOPs we have done, used as start indicator
 
@@ -164,6 +165,7 @@ our $dlog = SMGLog->new("day");
 dbg "before next tick";
 Mojo::IOLoop->next_tick(sub { loop() });       
 dbg "before app start";
+app->secrets([qw(Here's something that's really seakrett)]);
 app->start;
 dbg "after app start";
 
@@ -486,9 +488,13 @@ sub process
                } else {
                        my $o = gen_hash_diff($ld->{last_h}, \%h);
                        if ($o) {
+                               $o->{Dir} ||= $h{Dir};
+                               $o->{Wind} ||= $h{Wind};
+                               $o->{Dir} += 0;
+                               $o->{Wind} += 0;
                                $s = genstr($ts, 'r', $o);
                                push @last10minsr, $s;
-                               shift @last10minsr if @last10minsr > 240;
+                               shift @last10minsr while @last10minsr > ($windmins * $updatepermin);
                        }
                        else {
                                dbg "loop rec not changed" if isdbg 'chan';