HeatIndex
derp
This commit is contained in:
+73
-56
@@ -1,23 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
public class Calculator {
|
public class Calculator {
|
||||||
|
|
||||||
// Luchtdruk in hPa
|
// Luchtdruk in hPa
|
||||||
// Malek&Tom
|
// Malek&Tom
|
||||||
public static double luchtdruk(short mval)
|
public static double luchtdruk(short mval)
|
||||||
{
|
{
|
||||||
double luchtdruk = (mval / 1000f) * 33.86389;
|
double luchtdruk = (mval / 1000f) * 33.86389;
|
||||||
return luchtdruk;
|
return luchtdruk;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temperatuur in graden Celcius
|
// Temperatuur in graden Celcius
|
||||||
// Malek&Tom
|
// Malek&Tom
|
||||||
public static double temperatuur(short mval)
|
public static double temperatuur(short mval)
|
||||||
{
|
{
|
||||||
double temperatuur = (((double)mval / 10) -32) / 1.8;
|
double temperatuur = (((double)mval / 10) -32) / 1.8;
|
||||||
return temperatuur;
|
return temperatuur;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relatieve luchtvochtigheid in %
|
// Relatieve luchtvochtigheid in %
|
||||||
// Malek&Tom
|
// Malek&Tom
|
||||||
public static double luchtVochtigheid(short mval)
|
public static double luchtVochtigheid(short mval)
|
||||||
@@ -27,15 +27,15 @@ public class Calculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Windsnelheid in m/s
|
// Windsnelheid in m/s
|
||||||
// Janco&Tim
|
// Janco&Tim
|
||||||
public static double windSnelheid(short mval)
|
public static double windSnelheid(short mval)
|
||||||
{
|
{
|
||||||
double windSpeed = mval * 0.44704;
|
double windSpeed = mval * 0.44704;
|
||||||
return windSpeed;
|
return windSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Windrichting in noord, oost, zuid en west.
|
// Windrichting in noord, oost, zuid en west.
|
||||||
// Kenneth&Daniël
|
// Kenneth&Daniël
|
||||||
public static String windRichting(short mval)
|
public static String windRichting(short mval)
|
||||||
{
|
{
|
||||||
String direction = "Error";
|
String direction = "Error";
|
||||||
@@ -111,16 +111,16 @@ public class Calculator {
|
|||||||
|
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regenmeter in mm
|
// Regenmeter in mm
|
||||||
// Kenneth&Daniël
|
// Kenneth&Daniël
|
||||||
public static double regenmeter(short mval)
|
public static double regenmeter(short mval)
|
||||||
{
|
{
|
||||||
double rainAmount = (double)mval*0.2;
|
double rainAmount = (double)mval*0.2;
|
||||||
return rainAmount;
|
return rainAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// uvIndex in index
|
// uvIndex in index
|
||||||
// Kenneth&Daniël
|
// Kenneth&Daniël
|
||||||
public static double uvIndex(short mval)
|
public static double uvIndex(short mval)
|
||||||
{
|
{
|
||||||
@@ -131,37 +131,37 @@ public class Calculator {
|
|||||||
// BatterySpanning in Volt
|
// BatterySpanning in Volt
|
||||||
// Janco&Tim
|
// Janco&Tim
|
||||||
public static double batterySpanning(short mval){
|
public static double batterySpanning(short mval){
|
||||||
double voltage = (((double)mval * 300)/512)/100;
|
double voltage = (((double)mval * 300)/512)/100;
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sunRise en Sunset in tijdformaat hh:mm
|
// sunRise en Sunset in tijdformaat hh:mm
|
||||||
// Janco&Tim
|
// Janco&Tim
|
||||||
public static String sunRise(short mval){
|
public static String sunRise(short mval){
|
||||||
return sun(mval);
|
return sun(mval);
|
||||||
}
|
}
|
||||||
public static String sunSet(short mval){
|
public static String sunSet(short mval){
|
||||||
return sun(mval);
|
return sun(mval);
|
||||||
}
|
}
|
||||||
private static String sun(short sunRaw){
|
private static String sun(short sunRaw){
|
||||||
String tijd = "";
|
String tijd = "";
|
||||||
for(int i = 0; i <= 3; i++){
|
for(int i = 0; i <= 3; i++){
|
||||||
tijd = sunRaw % 10 + tijd;
|
tijd = sunRaw % 10 + tijd;
|
||||||
sunRaw /= 10;
|
sunRaw /= 10;
|
||||||
if(i == 1){
|
if(i == 1){
|
||||||
tijd = ":" + tijd;
|
tijd = ":" + tijd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tijd;
|
return tijd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double solarRad(short mval){
|
public static double solarRad(short mval){
|
||||||
double zonSterkte = mval;
|
double zonSterkte = mval;
|
||||||
return zonSterkte;
|
return zonSterkte;
|
||||||
}
|
}
|
||||||
|
|
||||||
//windchill in graden Celcius
|
//windchill in graden Celcius
|
||||||
//Janco en Keneth
|
//Janco en Keneth
|
||||||
public static double windChill(short grdnFh, short mph)
|
public static double windChill(short grdnFh, short mph)
|
||||||
{
|
{
|
||||||
double gradenFahrenheit = grdnFh;
|
double gradenFahrenheit = grdnFh;
|
||||||
@@ -172,12 +172,29 @@ public class Calculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Heatindex in celcius
|
//Heatindex in celcius
|
||||||
//Tom met Malek
|
//Tom met Malek
|
||||||
public static double heatIndex(double RH, double T)
|
public static double heatIndex(short RH, short T2)
|
||||||
{
|
{
|
||||||
double HI = -42.379 + 2.04901523*T + 10.14333127*RH - .22475541*T*RH - .00683783*T*T - .05481717*RH*RH + .00122874*T*T*RH + .00085282*T*RH*RH - .00000199*T*T*RH*RH;
|
double T = T2/10;
|
||||||
double heatindex = Calculator.temperatuur( (short) (HI*10) );
|
double HI = -42.379 + 2.04901523*T + 10.14333127*RH - .22475541*T*RH - .00683783*T*T - .05481717*RH*RH + .00122874*T*T*RH + .00085282*T*RH*RH - .00000199*T*T*RH*RH;
|
||||||
return heatindex;
|
|
||||||
|
if (RH < 13 && T < 112 && T > 80)
|
||||||
|
{
|
||||||
|
HI =- ((13-RH)/4)*Math.sqrt((17-Math.abs(T-95.))/17);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RH > 85 && T < 87 && T > 80)
|
||||||
|
{
|
||||||
|
HI =+ ((RH-85)/10) * ((87-T)/5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (T > 80)
|
||||||
|
{
|
||||||
|
HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094));
|
||||||
|
}
|
||||||
|
|
||||||
|
double heatindex = Calculator.temperatuur( (short) (HI*10) );
|
||||||
|
return heatindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dauwpunt in Celcius
|
//Dauwpunt in Celcius
|
||||||
@@ -188,11 +205,11 @@ public class Calculator {
|
|||||||
double dauwpunt = Math.pow( hm, (1/8f)) * (112 + 0.9*omgevingsTemp) + (0.1*omgevingsTemp) - 112;
|
double dauwpunt = Math.pow( hm, (1/8f)) * (112 + 0.9*omgevingsTemp) + (0.1*omgevingsTemp) - 112;
|
||||||
return dauwpunt;
|
return dauwpunt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double cloudHeight(double temp, short luchtVochtigheid ){
|
public static double cloudHeight(double temp, short luchtVochtigheid ){
|
||||||
|
|
||||||
double wolkhoogte = 125 * (temp-dewPoint(temp, luchtVochtigheid));
|
double wolkhoogte = 125 * (temp-dewPoint(temp, luchtVochtigheid));
|
||||||
return wolkhoogte;
|
return wolkhoogte;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class HeatIndex extends Grootheid{
|
||||||
|
public ArrayList<Double> list;
|
||||||
|
//constructor
|
||||||
|
public HeatIndex(Measurement measurement1, ArrayList<Measurement> measurement2){
|
||||||
|
list = new ArrayList<Double>();
|
||||||
|
updateRecent(measurement1);
|
||||||
|
update24Hour(measurement2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateRecent(Measurement measurement1){
|
||||||
|
setCurrent(measurement1.getHeatIndex());
|
||||||
|
}
|
||||||
|
public void update24Hour(ArrayList<Measurement> measurement2){
|
||||||
|
createList(measurement2);
|
||||||
|
calculateMaxMinAvg(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display(){
|
||||||
|
super.display();
|
||||||
|
GUIboard.writePageToMatrix("Warmte indexcijfer", "Gemiddelde: " + getAvg(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayGraph()
|
||||||
|
{
|
||||||
|
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createList(ArrayList<Measurement> measurement2)
|
||||||
|
{
|
||||||
|
if(!list.isEmpty())
|
||||||
|
{
|
||||||
|
list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Measurement ms : measurement2)
|
||||||
|
{
|
||||||
|
list.add(ms.getHeatIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-5
@@ -49,6 +49,7 @@ public class Weerstation {
|
|||||||
final List<Grootheid> lstScreens = new ArrayList<Grootheid>();
|
final List<Grootheid> lstScreens = new ArrayList<Grootheid>();
|
||||||
lstScreens.add(new OutsideTemp(meting1, meting2));
|
lstScreens.add(new OutsideTemp(meting1, meting2));
|
||||||
lstScreens.add(new WindChill(meting1, meting2));
|
lstScreens.add(new WindChill(meting1, meting2));
|
||||||
|
lstScreens.add(new HeatIndex(meting1, meting2));
|
||||||
lstScreens.add(new OutsideHum(meting1, meting2));
|
lstScreens.add(new OutsideHum(meting1, meting2));
|
||||||
lstScreens.add(new Barometer(meting1, meting2));
|
lstScreens.add(new Barometer(meting1, meting2));
|
||||||
lstScreens.add(new AvgWindSpeed(meting1, meting2));
|
lstScreens.add(new AvgWindSpeed(meting1, meting2));
|
||||||
@@ -59,7 +60,6 @@ public class Weerstation {
|
|||||||
lstScreens.add(new UVLevel(meting1, meting2));
|
lstScreens.add(new UVLevel(meting1, meting2));
|
||||||
lstScreens.add(new Zonsterkte(meting1, meting2));
|
lstScreens.add(new Zonsterkte(meting1, meting2));
|
||||||
lstScreens.add(new DewPoint(meting1, meting2));
|
lstScreens.add(new DewPoint(meting1, meting2));
|
||||||
lstScreens.add(new Sun(meting1));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class Weerstation {
|
|||||||
|
|
||||||
meting1 = weerstation1.getMostRecentMeasurement();
|
meting1 = weerstation1.getMostRecentMeasurement();
|
||||||
for(Grootheid obj : lstScreens){
|
for(Grootheid obj : lstScreens){
|
||||||
obj.updateRecent(meting1);
|
obj.updateRecent(meting1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 60*1000, 60*1000);
|
}, 60*1000, 60*1000);
|
||||||
@@ -160,11 +160,10 @@ public class Weerstation {
|
|||||||
|
|
||||||
GUIboard.clearBottom();
|
GUIboard.clearBottom();
|
||||||
|
|
||||||
for(int i=1; i<128;i+=2)
|
for(int i=0; i<128;i++)
|
||||||
{
|
{
|
||||||
for(int n=0; n<32;n++)
|
for(int n=0; n<32;n++)
|
||||||
{
|
{
|
||||||
IO.writeShort(0x42, 1 << 12 | i-1 << 5 | n);
|
|
||||||
IO.writeShort(0x42, 1 << 12 | i << 5 | n);
|
IO.writeShort(0x42, 1 << 12 | i << 5 | n);
|
||||||
IO.delay(1);
|
IO.delay(1);
|
||||||
}
|
}
|
||||||
@@ -172,7 +171,7 @@ public class Weerstation {
|
|||||||
|
|
||||||
startup = false;
|
startup = false;
|
||||||
}
|
}
|
||||||
}, 0, 128*32);
|
}, 0, 64*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopAnimatie()
|
public void stopAnimatie()
|
||||||
|
|||||||
Reference in New Issue
Block a user