#!/usr/bin/perl
use strict;
print "Content-type: text/html\n\n";
chdir "results";
my ($hours, $smooth) = ('24', '.7');
$hours = $1 if $ENV{'QUERY_STRING'} =~ /\bhours=(\d+)\b/;
$smooth = $1 if $ENV{'QUERY_STRING'} =~ /\bsmooth=(0\.\d+)\b/;
my $first = time - $hours*60*60;
my $tail = $hours * 12;
my $data;
for (<*>) {
my $label = `head -1 '$_/info.txt'` || $_;
# next if $label =~ /Backyard/;
$label =~ s/\n//g;
my $bias = `grep 'bias:' '$_/info.txt'` || "bias: 0.0";
$bias =~ s/bias://;
$data .= "{ id: '$_', label: '$label', data: [";
my @samples = `tail -$tail '$_/history.txt'`;
my $samples;
for (@samples) {
next unless /(\d+)\t(\d+\.\d)/;
next unless $1 >= $first;
my $temp = (((($2*10)+4) % 9)*0.0125) + $2 - $bias;
$samples .= "[${1}000,$temp], ";
}
$data .= $samples;
$data .= "] }, ";
}
print <
Arduino/Linux Interface to 1-Wire Digital Thermometers
about
6 |
12 |
24 |
48 |
96 hours