pimowo pisze: PS2
Jeszcze trzeba zmienić linię:na:Kod: Zaznacz cały
$dbpress=new PDO("sqlite:$root/db/wireless_METEO6_press.sql") or die ("cannot open database");
Kod: Zaznacz cały
$dbpress=new PDO("sqlite:$root/db/ip_meteoid6_press.sql") or die ("cannot open database");
[METEO] Meteograf
Re: [METEO] Meteograf
W pierwszym poście w aktualnej wersji nie jest jeszcze poprawione:
Re: [METEO] Meteograf
Zmieniłem wartośćslawko pisze:Mam ustawione swoje współrzędne, przekopiowalem kod z wersji która działała dłuższy czas bez problemu, ale nadal godziny wschodu i zachodu nie działają jak powinny, za chwilę sprawdzę jeszcze raz.pimowo pisze:
W kodzie trzeba ustawić współrzędne geograficzne gdzie mieszkasz.
Kod: Zaznacz cały
var TZ=1;
Kod: Zaznacz cały
var TZ=2;
Tylko pewnie później przy zmianie czasu trzeba będzie wartość z powrotem zmienić.
Re: [METEO] Meteograf
Dzięki @Darko_P-wygląda na to, że jest OK ;)
[email protected] HP MicroServer N54L, Raspberry Pi 3B, Raspberry Pi B+
Re: [METEO] Meteograf
Proszę :)pimowo pisze:Dzięki @Darko_P-wygląda na to, że jest OK ;)
Re: [METEO] Meteograf
Mam problem z uruchomieniem Meteografu.
Musiałem przeinstalować raspbiana - padła karta.
Zainstalowany w chwili obecnej raspbian stretch i NT w wersji 4.1.21
Przed padnięciem karty na raspbianie jeesie działał bez problemu.
Coś muszę doinstalować?
Zauważyłem jeszcze, że jak wkleję i zapiszę wigdet, to że się nie pokazuje to jedno
ale nie odświeżają się wówczas automatycznie u mnie dane
jak usunę wigdet OwnWiget dane się odświeżają.
Musiałem przeinstalować raspbiana - padła karta.
Zainstalowany w chwili obecnej raspbian stretch i NT w wersji 4.1.21
Przed padnięciem karty na raspbianie jeesie działał bez problemu.
Coś muszę doinstalować?
Zauważyłem jeszcze, że jak wkleję i zapiszę wigdet, to że się nie pokazuje to jedno
ale nie odświeżają się wówczas automatycznie u mnie dane
jak usunę wigdet OwnWiget dane się odświeżają.
Re: [METEO] Meteograf
Działa Wam ten widget?
Ja coś nie mogę go odpalić po przesiadce z maliny na PC :(
Ja coś nie mogę go odpalić po przesiadce z maliny na PC :(
[email protected] HP MicroServer N54L, Raspberry Pi 3B, Raspberry Pi B+
Re: [METEO] Meteograf
Naprawdę nikt nie używa tego widgetu?
[email protected] HP MicroServer N54L, Raspberry Pi 3B, Raspberry Pi B+
Re: [METEO] Meteograf
Dla tych, którzy mają postawione nt na php7:
Kod: Zaznacz cały
<div><p id="meteo_error"></p></div>
<canvas id="myCanvas" width="328" height="200"></canvas>
<?php
$root=$_SERVER["DOCUMENT_ROOT"];
//$root="/var/www/nettemp";
$db = new PDO("sqlite:$root/dbf/nettemp.db") or die ("cannot open database");
$query = $db->prepare("select tmp,rom from sensors where rom like'%meteo%'");
$meteo_data=$query->execute();
$meteo_data=$query->fetchAll();
$meteo_sorted=array();
foreach($meteo_data as $d){
$meteo_sorted[substr(explode('_',$d[1])[1],7)]=$d[0];
}
require_once("$root/status/Meteo.class.php");
$meteo=new Meteo();
$cz=$meteo->getCisnienieZnormalizowane();
$dbpress=new PDO("sqlite:$root/db/ip_meteoid6_press.sql") or die ("cannot open database");
$pressgraf=array();
for($i=0;$i>-72;$i-=2){
$query = $dbpress->prepare("select avg(value) from def where time > datetime('now',:tstart, 'localtime') and time < datetime('now',:tstop, 'localtime')");
$query->bindValue(':tstart',($i-2).' hour');
$query->bindValue(':tstop',$i.' hour');
$query->execute();
$press_data=$query->fetchAll();
array_push($pressgraf,round($press_data[0][0],2));
}
?>
<script>
/*
* Algorytmy wschodów i zachodów słońca oraz fazy księżyca
* ze strony
* http://cybermoon.pl
*/
try{
/* SETTINGS */
var Lat=52.0693546;
var Long=19.4729312;
var groundColour="#303030";
var groundFontColour="white";
var groundFont="15px Arial";
var dayColour="#8ED6FF";
var nightColour="black";
var dayFontColour="black";
var nightFontColour="white";
var airFontColour="white";
var airFont="15px Arial";
var sunTimesColour="red";
var sunTimeFont="10px Arial";
var presureGraphColour="red";
var presureScaleColour="white";
var presureScaleFont="9px Arial";
var windRoseBackground="navy";
var windRoseFontColour="yellow";
var windRoseArrowColour="white";
var batteryFontColour="black";
var batteryFont="10px Arial";
var showAircraft=false;
var showBigDipper=true;
var showMeteor=true;
/* END SETTINGS */
var cloude_x=0;
if (big_dipper_angle == undefined){
var big_dipper_angle=-100;
}
var dayTime=true;
var meteografTimer;
var TZ=1;
var Rainfall=<?php echo $meteo_sorted[1] !='' ? $meteo_sorted[1] : -1 ; ?>;
var Presure=<?php echo round($cz,1) !='' ? round($cz,1) : -1; ?>;
var Humidity=<?php echo $meteo_sorted[7] != '' ? round($meteo_sorted[7],1) : -1; ?>;//46;
var Temperature=<?php echo $meteo_sorted[8] != '' ? round($meteo_sorted[8],1) : -273.15; ?>;
var UV=<?php echo $meteo_sorted[4] != '' ? round($meteo_sorted[4]) : -1; ?>;
var Intensity=<?php echo $meteo_sorted[5] != '' ? round($meteo_sorted[5],1) : -1; ?>;//1;
var Speed=<?php echo $meteo_sorted[2] != '' ? $meteo_sorted[2] : -1; ?>;
var Direction=<?php echo $meteo_sorted[3] != '' ?$meteo_sorted[3] : 0; ?>;
var TempSun=<?php echo $meteo_sorted[9] != '' ? round($meteo_sorted[9],1) : -273.15; ?>;
var TempPlus10=<?php echo $meteo_sorted[10] != '' ? round($meteo_sorted[10],1) : -273.15; ?>;
var Temp10=<?php echo $meteo_sorted[11] != '' ? round($meteo_sorted[11],1) : -273.15; ?>;
var Temp25=<?php echo $meteo_sorted[12] != '' ? round($meteo_sorted[12],1) : -273.15; ?>;
var Temp50=<?php echo $meteo_sorted[13] != '' ? round($meteo_sorted[13],1) : -273.15; ?>;
var Temp100=<?php echo $meteo_sorted[14] != '' ? round($meteo_sorted[14],1) : -273.15; ?>;
var Volt1=<?php echo $meteo_sorted[15] != '' ? round($meteo_sorted[15],2) : -1; ?>;
var Volt2=<?php echo $meteo_sorted[16] != '' ? round($meteo_sorted[16],2) : -1; ?>;
var Volt3=<?php echo $meteo_sorted[17] != '' ? round($meteo_sorted[17],2) : -1; ?>;
var Volt4=<?php echo $meteo_sorted[18] != '' ? round($meteo_sorted[18],2) : -1; ?>;
var Battery=<?php echo $meteo_sorted[19] != '' ? round($meteo_sorted[19],1) : -1; ?>;
var Gust=<?php echo $meteo_sorted[20] != '' ? round($meteo_sorted[20],1) : -1; ?>;
var Lightning=<?php echo $meteo_sorted[21] != '' ? round($meteo_sorted[21],1) : -1; ?>;
var Lightning_cnt=<?php echo $meteo_sorted[22] != '' ? round($meteo_sorted[22],1) : -1; ?>;
var canvas = document.getElementById('myCanvas');
canvas.width = canvas.parentNode.clientWidth-30;
canvas.height = canvas.parentNode.clientHeight;
var context = canvas.getContext('2d');
canvas.addEventListener("dblclick", showCoords);
var centerX = canvas.width / 2;
var horizon = canvas.height / 5*3;
var meteorX=[200,150];
var meteorY=[10,20];
var meteorXstart= meteorX.slice();
var meteorYstart= meteorY.slice();
var meteorNb=2;
var meteorAngle=[30,50];
var meteorLength=[50,74];
var meteorIncrement=1;
var meteorShow=false;
var meteorShowTimer;
var alternatorAngle=0;
var aircraftX=100;
var aircraftY=20;
var aircraftScale=0.5;
var d = new Date();
var Dzien = d.getDate();
var Miesiac = d.getMonth()+1;
var Rok = d.getFullYear();
var Godzina = d.getHours()+d.getMinutes()/60;
var Minuta=d.getMinutes();
var Sekunda=0;
var demoRunning=false;
var meteografDemoData=[0,0,25,0,0,0,1000,70,21.3,21.5,15.9,8.6,4.2,2.1,13.5,3.6,3.7,4.2,0,0,73,0,0,2016,9,10];//METEO1-21,h,moon
if (meteografTimer !== undefined){
clearInterval(meteografTimer);
}
meteografTimer=setInterval(meteograf,100);
function meteograf(){
var sun = 15;
var sun_trip = 100;
var sun_pos = -80;
var sunray = 10;
var Req=-0.833;//don't change
d = new Date();
Dzien = d.getDate();
Miesiac = d.getMonth()+1;
Rok = d.getFullYear();
Godzina = d.getHours()+d.getMinutes()/60;
Minuta=d.getMinutes();
Sekunda=0;
var Moon=15;
var MoonVisibility=100;
var presureHistory=[<?php echo '"'.implode('","', $pressgraf).'"' ?>];
if (demoRunning==true){
demo();
}
var J=367*Rok-Math.round(7*(Rok+Math.round((Miesiac+9)/12))/4)+Math.round(275*Miesiac/9)+Dzien-730531.5;
var Cent =J/36525;
var L=(4.8949504201433+628.331969753199*Cent) % 6.28318530718;
var G=(6.2400408+628.3019501*Cent) % 6.28318530718;
var O=0.409093-0.0002269*Cent;
var F=0.033423*Math.sin(G)+0.00034907*Math.sin(2*G);
var E=0.0430398*Math.sin(2*(L+F)) - 0.00092502*Math.sin(4*(L+F)) - F;
var A=Math.asin(Math.sin(O)*Math.sin(L+F));
var C=(Math.sin(0.017453293*Req) - Math.sin(0.017453293*Lat)*Math.sin(A))/(Math.cos(0.017453293*Lat)*Math.cos(A));
var Wsch=((Math.PI - (E+0.017453293*Long + 1*Math.acos(C)))*57.29577951/15)+TZ;
var Tran=((Math.PI - (E+0.017453293*Long + 0*Math.acos(C)))*57.29577951/15)+TZ;
var Zach=((Math.PI - (E+0.017453293*Long + -1*Math.acos(C)))*57.29577951/15)+TZ;
var sun_move_time=Zach-Wsch;
sun_pos=(Godzina-Wsch)/sun_move_time;
var sun_x=centerX-Math.cos(sun_pos*Math.PI)*sun_trip;
var sun_y=horizon-Math.sin(sun_pos*Math.PI)*sun_trip;
dayTime=false;
if(Godzina > Wsch && Godzina <Zach){
dayTime=true;
}
if(dayTime){
context.fillStyle = dayColour;
context.fillRect(0,0,canvas.width,horizon);
context.beginPath();
context.arc(centerX,horizon,sun_trip,Math.PI,0,false);
context.strokeStyle='silver';
context.lineWidth=1;
context.stroke();
context.beginPath();
context.strokeStyle='yellow';
context.stroke();
context.beginPath();
context.arc(sun_x,sun_y,sun,0,2*Math.PI,false);
context.fillStyle= 'yellow';
var sunColour;
switch (Math.ceil(UV)){
case 0:
sunColour="#FFFFCC";
break;
case 1:
sunColour="#FFFFAB";
break;
case 2:
sunColour="#FFFF9A";
break;
case 3:
sunColour="#FFFF80";
break;
case 4:
sunColour="#FFFF6F";
break;
case 5:
sunColour="#FFFF5E";
break;
case 6:
sunColour="#FFFF4D";
break;
case 7:
sunColour="#FFFF3C";
break;
case 8:
sunColour="#FFFF2B";
break;
case 9:
sunColour="#FFFF1A";
break;
case 10:
sunColour="#FFFF00";
break;
case 11:
sunColour="#e6e600";
break;
case 12:
sunColour="#CCCC00";
break;
}
context.fillStyle=sunColour;
context.fill();
context.lineWidth = 1;
context.strokeStyle = 'lightred';
context.stroke();
for(i=0;i<12;i++){
context.beginPath();
var angle=i*30/180*Math.PI;
context.moveTo(Math.cos(angle)*sun+sun_x,Math.sin(angle)*sun+sun_y);
context.lineTo(Math.cos(angle)*(sun+sunray)+sun_x,Math.sin(angle)*(sun+sunray)+sun_y);
context.lineWidth=2;
context.strikeStyle ='yellow';
context.stroke();
}
}
else{
//night
//dayTime=false;
context.fillStyle = nightColour;
context.fillRect(0,0,canvas.width,horizon);
//Big Dipper and Polar Star
context.save();
if (showBigDipper==true){
context.translate(150,20);//move to Polar Star position
context.rotate(big_dipper_angle*Math.PI/180);
context.translate(-150,-20);
for(i=0;i<8;i++){
var starX=[20,40,60,80,120,90,110,150];
var starY=[55,40,45,60,55,80,80,20];
context.beginPath();
context.lineWidth=1;
if (i==7){
context.strokeStyle = 'white';
}
else{
context.strokeStyle = 'gold';
}
context.moveTo(starX[i]-5,starY[i]);
context.lineTo(starX[i]+5,starY[i]);
context.moveTo(starX[i],starY-5[i]);
context.lineTo(starX[i],starY+5[i]);
context.moveTo(starX[i]-3,starY[i]-3);
context.lineTo(starX[i]+3,starY[i]+3);
context.moveTo(starX[i]-3,starY[i]+3);
context.lineTo(starX[i]+3,starY[i]-3);
context.stroke()
}
}
context.restore();
big_dipper_angle=big_dipper_angle+0.05;
if (big_dipper_angle>360){big_dipper_angle=-180};
}
//underground
context.fillStyle = groundColour;
context.fillRect(0,horizon,canvas.width,canvas.height);
//moon
moon();
if(showAircraft==true){
aircraft();
}
//wind rose
var wind=20;
var arrow_w=8;
var arrow_h=20;
context.beginPath();
context.arc(centerX,horizon+wind+10,wind,0,2*Math.PI,false);
context.fillStyle=windRoseBackground;
context.fill();
context.fillStyle = windRoseFontColour;
context.font = "10px Arial";
context.fillText("N",centerX-4,horizon+10);
context.fillText("S",centerX-4,horizon+wind*2+10+10);
context.fillText("W",centerX-wind-10,horizon+wind+10+5);
context.fillText("E",centerX+wind,horizon+wind+10+5);
context.stroke();
context.save();
//wind direction
if (Direction == 360){
Direction=0;
}
context.beginPath();
context.strokeStyle=windRoseArrowColour;
context.translate(centerX,horizon+wind+10);
context.rotate(Direction*Math.PI/180);
context.moveTo(0,wind-2);
context.lineTo(0,-wind+2);
context.moveTo(0,-wind+2);
context.lineTo(0-arrow_w/2,-wind+2+arrow_h);
context.lineTo(0+arrow_w/2,-wind+2+arrow_h);
context.lineTo(0,-wind+2);
context.fillStyle=windRoseBackground;
context.fill();
context.stroke();
context.restore();
//cloude
context.translate(cloude_x,0);
context.beginPath();
context.moveTo(8, 16);
context.bezierCurveTo(0, 20, 0, 30, 20, 30);
context.bezierCurveTo(24, 36, 38, 36, 38, 30);
context.bezierCurveTo(58, 30, 58, 24, 52, 20);
context.bezierCurveTo(60, 8, 48, 6, 42, 10);
context.bezierCurveTo(38, 1, 24, 4, 24, 10);
context.bezierCurveTo(14, 1, 4, 4, 8, 16);
context.closePath();
context.lineWidth = 1;
context.fillStyle = "#0000ff";
context.fill();
context.strokeStyle = "#0000ff";
if(Rainfall > 0){
for (j=0;j<80;j+=10){
for(k=0;k<50;k+=10){
context.moveTo(14+k+j%20,40+j);
context.lineTo(14+k+j%20,45+j);
}
}
}
context.stroke();
context.translate(cloude_x*(-1),0);
cloude_x=cloude_x+Math.ceil(Speed/50);
if (cloude_x>canvas.width){cloude_x=0};
context.restore();
context.beginPath();
context.fillStyle = groundFontColour;
context.font = groundFont;
context.fillText(Temp10+"°C",50-context.measureText(Temp10+"°C").width,horizon+(canvas.height-horizon)/5*1);
context.fillText(Temp25+"°C",50-context.measureText(Temp25+"°C").width,horizon+(canvas.height-horizon)/5*2);
context.fillText(Temp50+"°C",50-context.measureText(Temp50+"°C").width,horizon+(canvas.height-horizon)/5*3);
context.fillText(Temp100+"°C",50-context.measureText(Temp100+"°C").width,horizon+(canvas.height-horizon)/5*4);
context.fillText(Speed+"("+Gust+") km/h",centerX-context.measureText(Speed+"("+Gust+") km/h").width,canvas.height-2);
context.fillText(Presure+"hPa npm",canvas.width-context.measureText(Presure+"hPa npm").width,horizon+15);
context.beginPath();
if (dayTime==true){
context.fillStyle = dayFontColour;
}
else {
context.fillStyle = nightFontColour;
}
context.font = airFont;
context.fillText(UV+" UV",centerX-context.measureText(UV+" UV").width-10,horizon-1);
context.fillText(Intensity + " lux",centerX+10,horizon-1);
context.fillText(TempSun+"°C",centerX-context.measureText(TempSun+"°C").width/2,horizon-sun_trip+sun+sunray+25);
context.fillText(TempPlus10+"°C",50-context.measureText(TempPlus10+"°C").width,horizon-2);
context.fillText(Temperature+"°C",5,horizon/5*1);
context.fillText(Humidity+"%",5,horizon/5*2);
var Storm_str="";
if((Lightning == 63 && Lightning_cnt == 0) || (Lightning == 0 && Lightning_cnt == 0)){
Storm_str="0/min";
}
else if(Lightning < 63 && Lightning_cnt > 0){
Storm_str=Lightning_cnt + "/min (" + Lightning +" km)";
}
else if (Lightning == 63 && Lightning_cnt > 0){
Storm_str=Lightning_cnt + "/min (>40 km)";
}
else {
Storm_str="?? "+Lightning+" "+Lightning_cnt+" ??";
}
context.fillText(Storm_str,5,horizon/5*3);
var rainfallX=50;//canvas.width-context.measureText(Rainfall+"----").width-2;
context.fillText(Rainfall,rainfallX-context.measureText(Rainfall+" ---").width,horizon/5*4);
var rainfallWidth=context.measureText(" ---").width;
context.font = "9px Arial";
context.fillText(" mm",rainfallX-rainfallWidth,horizon/5*4-9);
context.fillText(" -----",rainfallX-rainfallWidth,horizon/5*4-5);
context.fillText(" m2",rainfallX-rainfallWidth,horizon/5*4);
//sunrise, sunset, transit time
context.beginPath();
context.fillStyle =sunTimesColour;
context.font = sunTimeFont;
var sunrise=Math.floor(Wsch)+":"
var sunriseMin=Math.floor((Wsch-Math.floor(Wsch))*60);
if (sunriseMin<10){
sunrise+="0";
}
sunrise+=sunriseMin;
var transit=Math.floor(Tran)+":";
var transitMin=Math.floor((Tran-Math.floor(Tran))*60);
if(transitMin<10){
transit+="0";
}
transit+=transitMin;
var sunset=Math.floor(Zach)+":";
var sunsetMin=Math.floor((Zach-Math.floor(Zach))*60);
if (sunsetMin<10){
sunset+="0";
}
sunset+=sunsetMin;
context.fillText(sunrise,centerX-sun_trip,horizon-5);
context.fillText(transit,centerX-context.measureText(transit).width/2,horizon-sun_trip+sun+sunray+10);
context.fillText(sunset,centerX+sun_trip-context.measureText(sunset).width,horizon-5);
//presure history graph
var topGraph=20;
var colWidth=2.5;
context.beginPath();
context.fillStyle=presureGraphColour;
var grafDiv=(canvas.height-horizon-topGraph)/100;
for(i=0;i<presureHistory.length;i++){
context.fillRect(canvas.width-3-i*colWidth,horizon+topGraph+(canvas.height-horizon-topGraph-grafDiv*(presureHistory[i]-950)),colWidth,grafDiv*(presureHistory[i]-950));
}
context.stroke();
context.beginPath();
context.fillStyle=presureScaleColour;
context.strokeStyle=presureScaleColour;
context.lineWidth=1;
context.moveTo(canvas.width-presureHistory.length*colWidth,horizon+topGraph);
context.lineTo(canvas.width,horizon+topGraph);
context.moveTo(canvas.width-presureHistory.length*colWidth,horizon+topGraph+(canvas.height-horizon-topGraph)/2);
context.lineTo(canvas.width,horizon+topGraph+(canvas.height-horizon-topGraph)/2);
context.moveTo(canvas.width-presureHistory.length*colWidth,horizon+topGraph);
context.lineTo(canvas.width-presureHistory.length*colWidth,canvas.height);
context.moveTo(canvas.width-presureHistory.length*colWidth/3*2,horizon+topGraph);
context.lineTo(canvas.width-presureHistory.length*colWidth/3*2,canvas.height);
context.moveTo(canvas.width-presureHistory.length*colWidth/3,horizon+topGraph);
context.lineTo(canvas.width-presureHistory.length*colWidth/3,canvas.height);
context.fill();
context.stroke();
context.beginPath();
context.font = presureScaleFont;
context.fillStyle=presureScaleColour;
context.strokeStyle=presureScaleColour;
context.fillText("Real pressure",canvas.width-presureHistory.length*2+10,canvas.height-5);
context.fillText("1050",canvas.width-presureHistory.length*colWidth-23,horizon+topGraph+5);
context.fillText("1000",canvas.width-presureHistory.length*colWidth-23,horizon+topGraph+(canvas.height-horizon-topGraph)/2+3);
context.fillText("950",canvas.width-presureHistory.length*colWidth-23,canvas.height-2);
context.fillText("72",canvas.width-presureHistory.length*colWidth,horizon+topGraph+(canvas.height-horizon-topGraph)/4+3);
context.fillText("48",canvas.width-presureHistory.length*colWidth/3*2,horizon+topGraph+(canvas.height-horizon-topGraph)/4+3);
context.fillText("24",canvas.width-presureHistory.length*colWidth/3,horizon+topGraph+(canvas.height-horizon-topGraph)/4+3);
context.stroke();
if(meteorShow==false && dayTime==false) {
if (meteorShowTimer !== undefined){
clearInterval(meteorShowTimer);
}
var test= Math.random();
if (test > 0.99 && showMeteor==true){
meteorShow=true;
//console.log("meteor");
meteorShowTimer=setInterval(meteor,100);
}
}
solarPanel();
voltage();
if(Lightning_cnt>0 && Lightning < 63){
bolt();
}
alternator();
//roadSign()
}
/* FUNCTIONS */
function roadSign(){
context.beginPath();
var roadSignColour="pink";
var signHeight=100;
var signWidth=50;
var signX=100;
var signY=horizon+20;
context.fillStyle=roadSignColour;
context.fillRect(signX,signY-signHeight,5,signHeight);
context.fillRect(signX-signWidth/2,signY-signHeight,signWidth,10);
context.fill();
context.fillStyle="white";
context.font="10px Arial";
context.fillText("nettemp.pl",signX-context.measureText("nettemp.pl").width/2,signY-signHeight+5);
context.fill();
}
function moon(){
MoonVisibility = Math.round(faza_ksiezyca(Rok,Miesiac,Dzien,Godzina,Minuta,Sekunda));
var Moon=15;
var moonX=canvas.width-30;
var moonY1=10;
var moonY2=moonY1+Moon*2;
var moonR=moonX+Moon*1.3;
var moonL=moonX-Moon*1.3;
context.beginPath();
context.arc(moonX,moonY1+Moon,Moon,0,2*Math.PI,false);
context.fillStyle="black";
context.fill();
context.strokeStyle='silver';
context.stroke();
if (MoonVisibility<0){
moonR=moonR-Math.round((moonR-moonL)/100*(100-Math.abs(MoonVisibility)));
}
else
{
moonL=moonL+Math.round((moonR-moonL)/100*(100-Math.abs(MoonVisibility)));
}
context.beginPath();
context.moveTo(moonX, moonY1);
context.bezierCurveTo(moonR, moonY1, moonR,moonY2, moonX, moonY2);
context.bezierCurveTo(moonL, moonY2, moonL, moonY1, moonX, moonY1);
context.fillStyle="#e0e0e0";
context.fill();
context.strokeStyle='grey';
context.stroke();
}
function aircraft(){
context.save();
context.scale(aircraftScale,aircraftScale);
context.translate(aircraftX,aircraftY);
var transparentWidth=55;
var transparentHeight=11;
context.scale(2,2);
context.beginPath();
context.fillStyle="yellow";
context.strokeStyle="black";
context.fillRect(0,7,transparentWidth,transparentHeight);
context.fill();
context.stroke();
context.beginPath();
context.fillStyle="blue";
context.font="10px Arial";
context.fillText("nettemp.pl",1,16);
context.fill();
context.strokeStyle="black";
context.fillStyle="orange";
context.moveTo(transparentWidth,7+transparentHeight/2);
context.lineTo(transparentWidth+5,7+transparentHeight/2);
context.moveTo(transparentWidth+5+0,17);
context.lineTo(transparentWidth+5+0,7);
context.arcTo(transparentWidth+5+3,0,transparentWidth+5+13,10,5);
context.lineTo(transparentWidth+5+10,10);
context.lineTo(transparentWidth+5+40,7);
context.arcTo(transparentWidth+5+50,7,transparentWidth+5+45,15,5);
context.lineTo(transparentWidth+5+0,17);
context.moveTo(transparentWidth+5+25,8);
context.arcTo(transparentWidth+5+25,5,transparentWidth+5+30,4,2);
context.lineTo(transparentWidth+5+33,4);
context.arcTo(transparentWidth+5+35,6,transparentWidth+5+35,8,3);
context.moveTo(transparentWidth+5+20,15);
context.arcTo(transparentWidth+5+25,13,transparentWidth+5+30,12,2);
context.lineTo(transparentWidth+5+33,12);
context.arcTo(transparentWidth+5+36,13,transparentWidth+5+37,15,4);
context.moveTo(transparentWidth+5+3,17);
context.lineTo(transparentWidth+5+3,18);
context.fill();
context.stroke();
context.beginPath();
context.fillStyle="black";
context.strokeStyle="white";
context.arc(transparentWidth+5+2,20,2,0,2*Math.PI/180,true);
context.fill();
context.stroke();
context.beginPath();
context.arc(92,21,4,0,2*Math.PI/180,true);
context.fill();
context.stroke();
context.beginPath();
var tmp=transparentWidth+5+49;
context.moveTo(tmp-3,10);
context.lineTo(tmp,10);
context.fillStyle="silver";
context.bezierCurveTo(tmp-2,6,tmp-0,6,tmp,6);
context.bezierCurveTo(tmp+0,6,tmp+2,6,tmp,10);
context.bezierCurveTo(tmp-2,14,tmp-0,14,tmp,14);
context.bezierCurveTo(tmp+0,14,tmp+2,14,tmp,10);
context.fill();
context.stroke();
aircraftX+=3;
if (aircraftX > canvas.width/aircraftScale){
aircraftScale=Math.round(Math.random()*10)/10;
aircraftX=-120;}
context.restore();
}
function alternator(){
var alternatorX=canvas.width-12;
var alternatorY=horizon-65;
context.save();
context.translate(alternatorX,alternatorY);
context.beginPath();
context.fillStyle="white";
context.strokeStyle="white";
context.arc(0,0,5,0,2*Math.PI/180,false);
alternatorAngle+=Speed/3;
context.rotate((alternatorAngle)*Math.PI/180);
for (i=1;i<5;i++){
context.rotate((90)*Math.PI/180);
context.moveTo(0,0);
context.bezierCurveTo(0-4,0,0-4,0-10,0,0-10);
}
context.fill();
context.stroke();
context.restore();
context.font=airFont;
if(dayTime==true){
context.fillStyle=dayFontColour;
}
else {
context.fillStyle=nightFontColour;
}
context.fillText(Volt3+"V",alternatorX-context.measureText(Volt3+"V").width-12,alternatorY+5);
context.fill();
context.stroke();
}
function showCoords(event) {
// alert("Clicked");
var canvasOffset=$("#myCanvas").offset();
var canvasX=canvasOffset.left;
var canvasY=canvasOffset.top;
var x = event.clientX+$(window).scrollLeft()-canvasX;
var y = event.clientY+$(window).scrollTop()-canvasY;
var coor = "DEMO"; //coords: " + x + "," + y + " ; " + canvasX + "," +canvasY;
document.getElementById("meteo_error").innerHTML = coor;
demoRunning=true;
}
function bolt(){
var boltY=12+Math.floor(Math.random()*30);
var boltX=cloude_x+Math.round(Math.random()*50);
var boltAngle=0;
var partLength=0;
context.beginPath();
if (Lightning <5 ){
context.lineWidth=3;
}
else if (Lightning <20){
context.lineWidth=2;
}
else{
context.lineWidth=1;
}
context.strokeStyle="white";
while(boltY<horizon){
context.moveTo(boltX,boltY);
boltAngle=Math.floor(Math.random()*120);
partLength=Math.floor(Math.random()*30);
boltX+=Math.floor(Math.sin(30+boltAngle*Math.PI/180)*partLength);
boltY+=Math.floor(Math.cos(30+boltAngle*Math.PI/180)*partLength);
if(boltY>horizon){
boltY=horizon;
}
context.lineTo(boltX,boltY);
}
context.stroke();
}
function solarPanel(){
var solarX=canvas.width-30;
var solarY=horizon-40;
var solarWidth=30;
var solarHeight=30;
var solarAngle=30;
context.beginPath();
context.fillStyle="#404040";
context.fillRect(solarX+5,solarY,2,solarHeight);
//context.fillRect(solarX+5,solarY+solarHeight/2+10,30,2);
context.fill();
context.stroke();
context.beginPath();
context.strokeStyle="white";
context.fillStyle="brown";
context.lineWidth=1;
context.moveTo(solarX-solarWidth/2,solarY+solarHeight/2);
context.lineTo(solarX-solarWidth/2+Math.sin(solarAngle * Math.PI/180)*solarHeight,solarY+solarHeight/2-Math.cos(solarAngle*Math.PI/180)*solarWidth);
context.lineTo(solarX+solarWidth/2+Math.sin(solarAngle * Math.PI/180)*solarHeight,solarY+solarHeight/2-Math.cos(solarAngle*Math.PI/180)*solarWidth);
context.lineTo(solarX+solarWidth/2,solarY+solarHeight/2);
context.closePath();
context.fill();
context.stroke();
context.beginPath();
context.strokeStyle="blue";
context.moveTo(solarX,solarY+solarHeight/2);
context.lineTo(solarX+Math.sin(solarAngle * Math.PI/180)*solarHeight,solarY+solarHeight/2-Math.cos(solarAngle*Math.PI/180)*solarWidth);
context.moveTo(solarX-solarWidth/2+Math.sin(solarAngle * Math.PI/180)*solarHeight/2,solarY+solarHeight/2-Math.cos(solarAngle*Math.PI/180)*solarWidth/2);
context.lineTo(solarX+solarWidth/2+Math.sin(solarAngle * Math.PI/180)*solarHeight/2,solarY+solarHeight/2-Math.cos(solarAngle*Math.PI/180)*solarWidth/2);
context.stroke();
context.beginPath();
context.font = "12px Arial";
context.fillStyle="white";
context.fillText(Volt1+"V",solarX-context.measureText(Volt1+"V").width/2+Math.sin(solarAngle * Math.PI/180)*(solarHeight/2+4),solarY);
context.fillText(Volt2+"V",solarX-context.measureText(Volt2+"V").width/2+Math.sin(solarAngle * Math.PI/180)*(solarHeight/2-10),solarY+12);
context.stroke();
}
function meteor(){
context.beginPath();
context.fillStyle='white';
context.strokeStyle="white";
context.lineWidth=1;
var meteorFinish=true;
// for(i=0;i<meteorIncrement;i++){
for(j=0;j<meteorNb;j++){
if(meteorIncrement <= meteorLength[j]){
context.moveTo(meteorXstart[j],meteorYstart[j]);
context.lineTo(meteorX[j]+meteorIncrement*Math.sin(meteorAngle[j]*Math.PI/180),meteorY[j]+meteorIncrement*Math.cos(meteorAngle[j]*Math.PI/180));
if (meteorIncrement > meteorLength[j]/3){
meteorXstart[j]=meteorX[j]+(meteorIncrement-Math.round(meteorLength[j]/3))*Math.sin(meteorAngle[j]*Math.PI/180);
meteorYstart[j]=meteorY[j]+(meteorIncrement-Math.round(meteorLength[j]/3))*Math.cos(meteorAngle[j]*Math.PI/180);
}
//context.fillRect(meteorX[j]+i*Math.sin(meteorAngle*Math.PI/180),meteorY[j]+i*Math.cos(meteorAngle*Math.PI/180),2,2);
meteorFinish=false;
}
}
if (meteorFinish==true){
meteorShow=false;
clearInterval(meteorShowTimer);
}
// }
context.fill();
context.stroke();
if(meteorFinish == false){
meteorIncrement+=1;
}else{
meteorIncrement=1;
meteorNb=1+Math.floor(Math.random()*10);
meteorX=[];
meteorY=[];
meteorLength=[];
meteorAngle=[];
for(j=0;j<meteorNb;j++){
meteorX.push(Math.random()*canvas.width/3);
meteorY.push(Math.random()*30);
meteorLength.push(1+Math.random()*horizon/4*2);
meteorAngle.push(10+Math.random()*60);
}
meteorXstart= meteorX.slice();
meteorYstart= meteorY.slice();
}
}
function voltage(){
var batX=30;
var batY=15;
context.beginPath();
if (Volt4 > 3.7){
context.fillStyle="#00ff00";
}
else if (Volt4 >= 3.4 && Volt4 <= 3.7){
context.fillStyle="#ffff00";
}
else{
context.fillStyle="#ff0000";
}
context.strokeStyle="#00ff00";
context.fillRect(canvas.width-batX/2-20,horizon-batY-1,batX,batY);
context.fill();
context.stroke();
context.beginPath();
context.fillStyle="#888888";
context.strokeStyle="#006060";
context.fillRect(canvas.width-batX/2-20+2,horizon-batY-3,3,3);
context.fillRect(canvas.width+batX/2-20-5,horizon-batY-3,3,3);
context.fill();
context.stroke();
context.beginPath();
context.font=batteryFont;
context.fillStyle=batteryFontColour;
var bat_v=Math.round(Volt4*100)/100+"V";
context.fillText(bat_v,canvas.width-20-context.measureText(bat_v).width/2,horizon-batY/2);
context.stroke();
}
function faza_ksiezyca(Rok,Miesiac,Dzien,Godzina,Minuta,Sekunda){
var Miesiac_J=0;
var Rok_J=0;
var faza=0;
if (Miesiac > 2){
Miesiac_J= Miesiac;
Rok_J= Rok;
}
else if (Miesiac <= 2){
Miesiac_J= Miesiac + 12;
Rok_J= Rok - 1;
}
var A= Math.floor(Rok_J / 100);
var b= 2 - A + Math.floor(A / 4);
var jdp= Math.floor(365.25 * (Rok_J + 4716)) + Math.floor(30.6001 * (Miesiac_J + 1)) + Dzien + b +((Godzina + Minuta / 60 + Sekunda / 3600) / 24) - 1524.5;
//jdp= jdp;
var tzd= (jdp - 2451545) / 36525;
var elm= rang(297.8502042 + 445267.1115168 * tzd - (0.00163 * tzd * tzd) + tzd*tzd*tzd / 545868 - tzd*tzd*tzd*tzd / 113065000);
var ams= rang(357.5291092 + 35999.0502909 * tzd - 0.0001536 * tzd * tzd + tzd*tzd*tzd / 24490000);
var aml= rang(134.9634114 + 477198.8676313 * tzd - 0.008997 * tzd * tzd + tzd*tzd*tzd / 69699 - tzd*tzd*tzd*tzd / 14712000);
var asd= 180 - elm - (6.289 * Math.sin((Math.PI / 180) * ((aml)))) +
(2.1 * Math.sin((Math.PI / 180) * ((ams)))) -
(1.274 * Math.sin((Math.PI / 180) * (((2 * elm) - aml)))) -
(0.658 * Math.sin((Math.PI / 180) * ((2 * elm)))) -
(0.214 * Math.sin((Math.PI / 180) * ((2 * aml)))) -
(0.11 * Math.sin((Math.PI / 180) * ((elm))));
var phi1= (1 + Math.cos((Math.PI / 180) * (asd))) / 2;
tzd= (jdp + (0.5 / 24) - 2451545) / 36525;
elm= rang(297.8502042 + 445267.1115168 * tzd - (0.00163 * tzd * tzd) + tzd*tzd*tzd / 545868 - tzd*tzd*tzd*tzd / 113065000);
ams= rang(357.5291092 + 35999.0502909 * tzd - 0.0001536 * tzd * tzd + tzd*tzd*tzd / 24490000);
aml= rang(134.9634114 + 477198.8676313 * tzd - 0.008997 * tzd * tzd + tzd*tzd*tzd / 69699 - tzd*tzd*tzd*tzd / 14712000);
asd= 180 - elm - (6.289 * Math.sin((Math.PI / 180) * ((aml)))) +
(2.1 * Math.sin((Math.PI / 180) * ((ams)))) -
(1.274 * Math.sin((Math.PI / 180) * (((2 * elm) - aml)))) -
(0.658 * Math.sin((Math.PI / 180) * ((2 * elm)))) -
(0.214 * Math.sin((Math.PI / 180) * ((2 * aml)))) -
(0.11 * Math.sin((Math.PI / 180) * ((elm))));
var phi2= (1 + Math.cos((Math.PI / 180) * (asd))) / 2;
if ((phi2-phi1)<0) {
phi1=-1*phi1;
}
faza=100*phi1;
return faza;
}
function rang(x){
b= x / 360;
A= 360 * (b - Math.floor(b));
if (A < 0) { A= A + 360};
return A;
}
function demo(){
//if (demoRunning==false){
Rainfall=meteografDemoData[1];
Presure=meteografDemoData[6];
Humidity=meteografDemoData[7];//46;
Temperature=meteografDemoData[8];
UV=meteografDemoData[4];
Intensity=meteografDemoData[5];//1;
Speed=meteografDemoData[2];
Direction=meteografDemoData[3];
TempSun=meteografDemoData[9];
TempPlus10=meteografDemoData[10];
Temp10=meteografDemoData[11];
Temp25=meteografDemoData[12];
Temp50=meteografDemoData[13];
Temp100=meteografDemoData[14];
Volt1=meteografDemoData[15];
Volt2=meteografDemoData[16];
Volt3=meteografDemoData[17];
Volt4=meteografDemoData[18];
Battery=meteografDemoData[19];
Gust=meteografDemoData[20];
Lightning=meteografDemoData[21];
Godzina=meteografDemoData[22];
Rok=meteografDemoData[23];
Miesiac=meteografDemoData[24];
Dzien=meteografDemoData[25];
// demoRunning=true;
//}
//else{
var cond=Math.random();
if (cond>0.8){
meteografDemoData[1]+=Math.round(Math.random()*5,1);
}
else if(cond < 0.2){
meteografDemoData[1]=0;
}
cond=Math.random();
if (cond>0.8){
meteografDemoData[6]+=Math.round(Math.random()*5,1);
if(meteografDemoData[6]>1050){meteografDemoData[6]=1050};
}
else if(cond < 0.2){
meteografDemoData[6]-=Math.round(Math.random()*5,1);
if(meteografDemoData[6]<950){meteografDemoData[6]=050};
}
cond=Math.random();
if (cond>0.8){
meteografDemoData[7]+=Math.round(Math.random()*5,1);
if(meteografDemoData[7]>100){meteografDemoData[7]=100};
}
else if(cond < 0.2){
meteografDemoData[7]-=Math.round(Math.random()*5,1);
if(meteografDemoData[7]<0){meteografDemoData[7]=0};
}
cond=Math.random();
if (cond>0.8){
meteografDemoData[8]+=Math.round(Math.random()*5,0);
Math.round(meteografDemoData[8],0);
if(meteografDemoData[8]>50){meteografDemoData[8]=50};
}
else if(cond < 0.2){
meteografDemoData[8]-=Math.round(Math.random()*5,0);
Math.round(meteografDemoData[8],0);
if(meteografDemoData[8]<-50){meteografDemoData[8]=-50};
}
cond=Math.random();
if (cond>0.8){
meteografDemoData[2]+=Math.round(Math.random()*20,1);
if(meteografDemoData[2]>150){meteografDemoData[2]=150};
}
else if(cond < 0.2){
meteografDemoData[2]-=Math.round(Math.random()*20,1);
if(meteografDemoData[2]<0){meteografDemoData[2]=0};
}
cond=Math.random();
if (cond>0.8){
meteografDemoData[3]+=Math.round(Math.random()*20,1);
if(meteografDemoData[3]>360){meteografDemoData[3]=0};
}
else if(cond < 0.2){
meteografDemoData[3]-=Math.round(Math.random()*20,1);
if(meteografDemoData[3]<0){meteografDemoData[3]=360};
}
cond=Math.random();
if (cond>0.6){
meteografDemoData[18]+=0.2;
if(meteografDemoData[18]>4.2){meteografDemoData[18]=4.2};
}
else if(cond < 0.4){
meteografDemoData[18]-=0.2;
if(meteografDemoData[18]<2.4){meteografDemoData[18]=2.4};
}
if (Godzina%1 < 0.02){
meteografDemoData[25]++;
}
cond=Math.random();
if (cond>0.8){
meteografDemoData[21]=Math.round(Math.random()*30,1);
}
else if(cond < 0.2){
meteografDemoData[21]=0;
}
meteografDemoData[22]+=0.1;
if (meteografDemoData[22]>24){
meteografDemoData[22]=0;
demoRunning=false;
}
//}
//console.log(meteografDemoData[22]);
}
}
catch(err){
document.getElementById("meteo_error").innerHTML = err.message;
}
</script>
Rpi 3 + SSD 240 GB + nettemp.
Re: [METEO] Meteograf
Panowie, mieliśmy zmianę czasu na letni i zegarki zapewne już dawno wszystkie przestawione, ale czy ustawiliście Meteograf na czas letni? :)
[email protected] HP MicroServer N54L, Raspberry Pi 3B, Raspberry Pi B+
Kto jest online
Użytkownicy przeglądający to forum: Obecnie na forum nie ma żadnego zarejestrowanego użytkownika i 1 gość