#!/usr/bin/perl use strict; use CGI qw(:all escapeHTML); use CGI::Carp qw(fatalsToBrowser); # get the current temp and transform that into a 'percentage' of the thermometer # Did we push the button or no? my $choice = lc (param ("choice")); print header(); print start_html ("Joe's Thermostat"); # I'm a virgin if ( "$choice" eq "") { ; } # It's not going to be a white wedding elsif ( "$choice" eq "submit") { open(THERMOSTAT, ">/gdata/data/thermostat") or print("Could not write to file! \n"); print THERMOSTAT param('temp'); close(THERMOSTAT); #system("/gdata/bin/thermo.pl"); } # I'm a dirty, dirty whore else { print p (escapeHTML ("Something is amiss, either you're trying to cheat the system, or there's a real problem with browser interaction: $choice")); } # Read the current temp and the current thermostat setting open(THERMOSTAT2, "< /gdata/data/thermostat") or print("Could not read thermostat"); my $thermo=; if ( ! $thermo ) { $thermo='50'; } my $slider_pos=$thermo-50; $slider_pos=$slider_pos*3.33; close(THERMOSTAT2); open(TEMPERATURE, "< /gdata/data/temperature") or print("Could not read temperature"); my @current_temps=; close(TEMPERATURE); my $current_temp = 'hey'; foreach my $temp_temp (@current_temps) { if ( "$temp_temp" =~ /Sensor\ 1/ ) { $temp_temp =~ s/.*F: //; chomp $current_temp; $current_temp=$temp_temp; } } if ( ! $current_temp ) { $current_temp='80'; } my $current_percent=$current_temp - 50; $current_percent=$current_percent * 3.33; # The thermometer css print(''); # These are the scripts for the thermostat slider print (' '); print("
"); print('

Current Temperature

'); print h1("$current_temp F"); print('
'); print start_form(); print ('
'); print ('
 
 
'); print('

'); print ('
'); print p("Slide thermostat to desired temp and hit 'Submit.'"); print p(); print p(submit (-name => "choice", -value =>"Submit")); print end_form(); print("
"); print end_html();