Dr. Arne Jachens

Set up the Raspberry Pi

no warranty for any of the provided information

To have a unicly defined color map for all temperatures this function returns the appropriate color for the given temperature argument. (Additionally a text color which contrasts nicely to the temperature color is returned.)

If the temperature argument is set to 'bar', the color bar is composed and returned as html.

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
  /*
   echo "<html><table>";
   $bar = HV_colorMap("bar");
   echo $bar;
   }
   echo "</table></html>";
  */

function HV_colorMap($T){
  /* old set
  $bgc["-10"]=" #000066"; $txt["-10"]="white";
  $bgc["0"]  =" #0000ff"; $txt["0"]  ="white";
  $bgc["10"] =" #0066ff"; $txt["10"] ="black";
  $bgc["20"] =" #00ffd6"; $txt["20"] ="black";
  $bgc["30"] =" #00ff33"; $txt["30"] ="black";
  $bgc["40"] =" #ffff00"; $txt["40"] ="black";
  $bgc["50"] =" #ff9900"; $txt["50"] ="black";
  $bgc["60"] =" #ff0000"; $txt["60"] ="white";
  $bgc["70"] =" #b80096"; $txt["70"] ="white";
  $bgc["80"] ="fuchsia"; $txt["80"] ="black";
  */
  $bgc["-10"]=" #01006c"; $txt["-10"]="white";
  $bgc["-5"] =" #0000fe"; $txt["-5"] ="white";
  $bgc["0"]  =" #0c2df6"; $txt["0"]  ="white";
  $bgc["5"]  =" #0062ff"; $txt["5"]  ="white";
  $bgc["10"] =" #0099ff"; $txt["10"] ="black";
  $bgc["15"] =" #00ccff"; $txt["15"] ="black";
  $bgc["20"] =" #339933"; $txt["20"] ="white";
  $bgc["25"] =" #009900"; $txt["25"] ="white";
  $bgc["30"] =" #33cc33"; $txt["30"] ="black";
  $bgc["35"] =" #69ff65"; $txt["35"] ="black";
  $bgc["40"] =" #ffff66"; $txt["40"] ="black";
  $bgc["45"] =" #ffff00"; $txt["45"] ="black";
  $bgc["50"] =" #ff9703"; $txt["50"] ="black";
  $bgc["55"] =" #fc6700"; $txt["55"] ="black";
  $bgc["60"] =" #ff3300"; $txt["60"] ="white";
  $bgc["65"] =" #ff68a5"; $txt["65"] ="white";
  $bgc["70"] =" #cc3467"; $txt["70"] ="white";
  $bgc["75"] ="fuchsia"; $txt["75"] ="black";

  if($T=="bar"){
    $colorBar ="<table>";
    $keys = array_keys($bgc);
    $NoColors=count($bgc);
    for($c=0;$c<$NoColors;$c++){
      $cc=$NoColors-$c-1;
      $colorBar.="<tr><td align='right'
                  style='background-color:".$bgc[$keys[$cc]].";
                  color:".$txt[$keys[$cc]].";'>".$keys[$cc]."</td></tr>";
    } #c
    $colorBar.="</table>";
    return $colorBar;
  }else{
    $keys = array_keys($bgc);
    $NoColors=count($bgc);
    for($c=0;$c<$NoColors;$c++){
      $thisKey=$keys[$NoColors-$c-1];
      if($T>1.0*$thisKey-2.5){
	return array($bgc[$thisKey],$txt[$thisKey]);
      } #fi
    } #c
    return array("white","black");
  }
}
?>

python

1HvcControl.py
2HvcHCSR04ultrasonic.py
3HvcMain.py
4HvcMotorDriver.py
5HvcOneWire.py
6HvcOperationMode.py
7HvcRaw2phys.py
8HvcReadSPI.py
9HvcSendI2C.py
10HvcSetGPIO.py
11HvcTables.py
12HvcWeather.py
13makeDoc.py

php

1HV_Admin_Login.php
2HV_colorMap.php
3HV_composeH2Oplot.php
4HV_config.php
5HV_H2Olevel.php
6HV_readOperationState.php
7HV_restart.php
8HV_serviceLog.php
9HV_setParameters.php
10HV_showHouse.php
11HV_showLog.php
12HV_showWeatherForecast.php
13HV_TempCal.php
14index.php
15readFilenames.php
16readNamedData.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.