Graphic gauges for weatherdata-display

Hallo zusammen,

habe hier
Graphic gauges for weatherdata-display

ein paar interessante Grafiken samt zugehörigem PHP Script’e gefunden, ob man das allerdings in IP-Symcon benutzen kann müsst ihr mal nachsehen.

Vieleicht kann das ja einer brauchen.

Gruß Michael

Hallo Michael,

coole Sache. Ich habe mir das mal angesehen und das Script für die Temperatur an IPS angepasst. Funktioniert. Alles was man machen muß ist: Zip Datei in den IPS Ordner entpacken, Script importieren und die Pfade der Bilder anpassen. Fertig. Das Script habe ich mal als Beispiel angehängt.

<?
//Graphic gauges for weatherdata-display V.1.0
// by Weatherstation Halikko/Henkka http://www.nordicweather.net 16-Dec-2008

//Orginal calculations by Pinto http://cumulus.joske-online.be/
// Angepass an IPS 02.02.2009 Attain
$solar = GetValue(20798);
$min = -10;   // hier könnten noch Werte eingelesen werden
$max = 10;
$trend = GetValue(55188);  // kann auch weggelassen werden

if(isset($trend)) {
if ($trend > 3){$trendix = IPS_GetKernelDir()."graphic\\falling-old.gif";} //4+5 ist fallend
if ($trend < 3){$trendix = IPS_GetKernelDir()."graphic\\rising-old.gif";}  //1+2 ist steigend
} else {
$trendix = null;
}

$trend = IPS_GetKernelDir()."graphic\
el.png";
$unt = "°C";
$font = 'tahoma.ttf';


$cd = ($solar + 131 + (3.5 * $solar));
$degs = (360 - 131 + $cd);


$degrees = (131 - $cd);

//##########need to do this, or our colors won't work##########################
$im = imagecreatetruecolor(110,110);
$src = imagecreatefrompng(IPS_GetKernelDir()."graphic\	emp.png"); // this is the background image graphic. It should be GIF format
$background = imagecolorallocate($im,255,255,255);
imagefilledrectangle($im,244,180,0,0,$background);
imagecopymerge($im, $src, 0, 0, 0, 0, 220, 180, 100);
###############################################################################
$center_x = imagesx($im)/2;
$center_y = imagesy($im)/2;

                        //color definitions
                $red = imagecolorallocate ($im, 255, 36, 0);
                $blue = imagecolorallocate ($im, 0, 0, 255);
                $green = imagecolorallocate ($im, 0, 255, 0);
                $black = imagecolorallocate ($im, 0, 0, 0);
                $grey = imagecolorallocate ($im, 42, 42, 42);

			if ($trendix) {
                        //put trendimage on graphic (do this first so it is in the background,behind the needle)
                        $trendimagex  = imagecreatefromgif ($trendix);
                        imagecolortransparent ($trendimagex, imagecolorat ($trendimagex, 0, 0));
                        imagecopy ($im, $trendimagex, 33, 82, 0, 0, 7, 8);
                        imagedestroy ($trendimagex);
			}

	imagettftext($im, 10, 0, $center_x-(strlen($solar)*imagefontwidth(1))/2-1, $center_y+20, $grey, $font, $solar);
        imagettftext($im, 9, 0, $center_x-(strlen($unt)*imagefontwidth(2))/2-3, $center_y+35, $grey, $font, $unt); 


                        //find where we are drawing our line to
                         $to=getpixel($center_x+1,$center_y+4,8,$degs,1);//parameter 3=length of need
                        
			$posx = $to[0];
			$posy = $to[1];

                        //put trendimage on graphic (do this first so it is in the background,behind the needle)
                        $trendimage  = imagecreatefrompng ($trend);
			$trendimage  = imagerotate($trendimage, $degrees, -1);
			$trendx = imagesx($trendimage);
			$trendy = imagesy($trendimage);
			$trendxx = imagesx($trendimage)/2;
			$trendyy = imagesy($trendimage)/2;
                        imagecolortransparent ($trendimage, imagecolorat ($trendimage, 0, 0));
                        imagecopy ($im, $trendimage, $posx-$trendxx, $posy-$trendyy, 0, 0, $trendx, $trendy);
                        imagedestroy ($trendimage);

                        //put knobimage on graphic
                        $knop  = imagecreatefrompng (IPS_GetKernelDir()."graphic\\knop.png");
                        imagecolortransparent ($knop, imagecolorat ($knop, 0, 0));
                        imagecopy ($im, $knop, 50, 53, 0, 0, 11, 11);
                        imagedestroy ($knop);


//send our picture
//header("Content-Type: image/png");
//echo ($im);
imagepng($im,IPS_GetKernelDir()."media\\Aussentemp.png");
imagedestroy($im);

########################FUNCTIONS########################################################
function getpixel($midx, $midy, $speed, $degrees, $factor){
 $ret=Array();
 $x=$midx;
 $y=$midy;
 $dia=(($speed)/$factor)*2;
 $point=(int)($degrees);
 $angle=((90-$point)*(2*M_PI))/360;
 $xx=(int)(round(cos($angle)*$dia));
 $ret[0]=$x+$xx;
 $yy=(int)(round(sin($angle)*$dia));
 $ret[1]=$y-$yy;
 return($ret);
}

######################THICK LINES########################################################
function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 2)
{
    /* this way it works well only for orthogonal lines
    imagesetthickness($image, $thick);
    return imageline($image, $x1, $y1, $x2, $y2, $color);
    */
    if ($thick == 1) {
        return imageline($image, $x1, $y1, $x2, $y2, $color);
    }
    $t = $thick / 2 - 0.5;
    if ($x1 == $x2 || $y1 == $y2) {
        return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color);
    }
    $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q
    $a = $t / sqrt(1 + pow($k, 2));
    $points = array(
        round($x1 - (1+$k)*$a), round($y1 + (1-$k)*$a),
        round($x1 - (1-$k)*$a), round($y1 - (1+$k)*$a),
        round($x2 + (1+$k)*$a), round($y2 - (1-$k)*$a),
        round($x2 + (1-$k)*$a), round($y2 + (1+$k)*$a),
    );
    imagefilledpolygon($image, $points, 4, $color);
    return imagepolygon($image, $points, 4, $color);
}
?> 

Tack så mycket :slight_smile: bra

… anstatt $solar sollte man ggf. besser $ist_wert verwenden

„Auf die Schnelle“ sehe ich leider nicht was Min / Max machen :confused:

MST

Hallo,

freut mich :smiley: das man was damit anfangen kann, werde das script auch mal testen und bestimmt einen platz dafür finden.

Gruß Michael