<?php
//Davis Console gemaakt door Frans Veenstra van www.meteonoordwest.nl
//Ook dank aan Gert-Jan van www.weerstation-holwerd.nl voor de gifjes en icoontjes
//En de tipgevers in het forum van www.hetweeractueel.nl

$data_file_path  = 'http://weerstationtilburgreeshof.organisten.eu/cumulus/realtime.txt'; 
$image_format = 'gif';
$font_file = './Digital.ttf';
$barom_units = ' mb';
$rain_units = ' mm';
$degree_units = ' C';
$wind_units = '';
$wind_chill_threshold = '60';
$heat_index_threshold = '70';
//$curr_cond_icon = 'no';
$time_format = 'hh:mm';
$temp_conv = 'C';
$temp_prec = '1';
//$wind_conv = 'KPH';
$wind_prec = '1';
//$barom_conv = 'MB';
$barom_prec = '2';
//$rain_conv = 'MM';
$rain_prec = '2';
$bft_units = 'Bft';



// $console_icon_x: x coordinate on default image of the upper left most pixel of icon
// $console_icon_y: y coordinate on default image of the upper left most pixel of icon
$console_icon_x = '110';
$console_icon_y = '209';

function define_colors() {
  global $img, $color1, $color2, $color3, $color4, $color5, $trans_color,
         $anti_alias;

  $color1 = imagecolorallocate($img,255,0,0);      // RED
  $color2 = imagecolorallocate($img,0,128,0);      // GREEN
  $color3 = imagecolorallocate($img,0,0,255);      // BLUE
  $color4 = imagecolorallocate($img,0,0,0);        // BLACK
  $color5 = imagecolorallocate($img,255,255,255);  // WHITE  
  $color6 = imagecolorallocate($img,229,229,229);  // GREY  

  $anti_alias = 'on';

}

function write_console() {

  global $color1, $color2, $color3, $color4, $color5, $date, $time, $forecast, $temp, $avgwind, 
         $degree_units, $winds, $winddir, $wind_units, $gust, $raintoday, $rainmonth, $rainyear, $rain_units, 
         $barom, $barom_units, $baromtrendwords, $dewpt, $humidity, $heatindex,
         $heat_index_threshold, $windchill, $wind_chill_threshold, $bft_units, $baromtrend, 
         $banner_icon_x, $banner_icon_y, $anti_alias, $xx, $yy, $bft, $angle, $aa, $bb, $cc;

  
  switch (TRUE){
  case ($windchill <= $wind_chill_threshold):
       $feelslike = "$windchill$degree_units";
       imagecenteredtext(230, 185, "$feelslike", 5, 14, $color4, 0);
  break; 
  case ($heatindex >= $heat_index_threshold):
       $feelslike = "Heat Idx: $heatindex$degree_units";
       imagecenteredtext(90, 50, "$feelslike", 5, 14, $color4, 0);
  break;
  }
  imagecenteredtext(300, 30, "Weerstation Tilburg-Reeshof", 5, 14, $color5, 0); 
  imagecenteredtext(150, 100, " ", 2, 7, $color4, 0); 
  imagecenteredtext(300, 80, "$time", 5, 18, $color4, 0); 
  imagecenteredtext(420, 80, "$date ", 5, 18, $color4, 0); 
  imagecenteredtext(230, 130, "$temp$degree_units", 5, 18, $color4, 0); 
  imagecenteredtext(315, 130, "$humidity % ", 5, 18, $color4, 0); 
  imagecenteredtext(275, 285, "$avgwind km/u", 1, 18, $color4, 0);
  imagecenteredtext(120, 130, "$winds", 1, 18, $color4, 0);  
  imagecenteredtext(300, 240, "$raintoday$rain_units", 5, 18, $color4, 0);
  imagecenteredtext(300, 260, "$rainmonth$rain_units", 5, 18, $color4, 0); 
  imagecenteredtext(420, 260, "$rainyear$rain_units", 5, 18, $color4, 0);
  imagecenteredtext(405, 130, "$barom$barom_units", 5, 18, $color4, 0); 
  imagecenteredtext(400, 185, "$dewpt$degree_units", 5, 18, $color4, 0);
  imagecenteredtext($aa, $bb, "!", 5, 28, $color4, $cc); 
  imagecenteredtext(370, 285, "$bft", 1, 18, $color4, 0);
//imagecenteredtext(110, 100, "$baromtrend", 1, 18, $color4, 0);
  
  
//imagecenteredtext(116, 74, "!", 5, 24, $color1, 188);			//N
//imagecenteredtext(136, 76, "!", 5, 24, $color1, 166);			//NNO  
//imagecenteredtext(150, 86, "!", 5, 24, $color1, 144);			//NO 
//imagecenteredtext(162, 101, "!", 5, 24, $color1, 122);		//ONO  
//imagecenteredtext(96, 120, "!", 5, 24, $color1, 98);			//O
//imagecenteredtext(164, 138, "!", 5, 24, $color1, 76);			//OZO
//imagecenteredtext(154, 154, "!", 5, 24, $color1, 54);			//ZO   
//imagecenteredtext(138, 166, "!", 5, 24, $color1, 32);			//ZZO  
//imagecenteredtext(118, 144, "!", 5, 24, $color1, 188);		//Z 			
//imagecenteredtext(108, 142, "!", 5, 24, $color1, 166);		//ZZW  
//imagecenteredtext(102, 136, "!", 5, 24, $color1, 144);		//ZW
//imagecenteredtext(98, 128, "!", 5, 24, $color1, 122);			//WZW   
//imagecenteredtext(166, 122, "!", 5, 24, $color1, 98);			//W
//imagecenteredtext(96, 112, "!", 5, 24, $color1, 76);			//WNW  
//imagecenteredtext(102, 104, "!", 5, 24, $color1, 54);			//NW
//imagecenteredtext(110, 100, "!", 5, 24, $color1, 32);			//NNW  
} 
?>