diff --git a/GUIboard.java b/GUIboard.java index ff2e4ef..0beb4ff 100644 --- a/GUIboard.java +++ b/GUIboard.java @@ -1,3 +1,4 @@ +package weerstation; import java.util.ArrayList; @@ -156,15 +157,25 @@ public class GUIboard { * @param regel2 De tekst die je op de tweede regel wilt weergeven. * @param regel3 De tekst die je op de derde regel wilt weergeven. Wordt standaard gevolgd door de navigatie. */ - public static boolean writePageToMatrix(String regel1, String regel2, String regel3) + public static boolean writePageToMatrix(String regel1, String regel2, String regel3, Boolean pPeriod, Boolean pScreen) { + String p = "||"; + String s = "||"; + + if(pPeriod){ + p = "|>"; + } + if(pScreen){ + s = "|>"; + } + clearBottom(); if(regel1.length() > 20 && regel2.length() > 20 && regel3.length() > 11) //check if the length is not to long { return false; } - String nav = "< > S"; //creates the navigation and will center it out to the right + String nav = p + " " + s + " G"; //creates the navigation and will center it out to the right for(int i=0; i < (12-regel3.length()); i++){ nav = " " + nav; diff --git a/GraadDagen.java b/GraadDagen.java index a7a437c..6edb211 100644 --- a/GraadDagen.java +++ b/GraadDagen.java @@ -1,4 +1,4 @@ -package weerstation1; +package weerstation; import java.util.ArrayList; @@ -26,7 +26,7 @@ public class GraadDagen extends Grootheid{ } public void display(){ - GUIboard.writePageToMatrix("Aantal Graaddagen", graadDagen + "", ""); + GUIboard.writePageToMatrix("Aantal Graaddagen", graadDagen + "", "", true, true); } public void displayGraph() diff --git a/Grootheid.java b/Grootheid.java index 007d81f..11c332f 100644 --- a/Grootheid.java +++ b/Grootheid.java @@ -1,4 +1,4 @@ -package weerstation1; +package weerstation; import java.util.ArrayList; @@ -124,7 +124,7 @@ public class Grootheid } - public void display(String periodname){ + public void display(String periodname, Boolean p, Boolean s){ GUIboard.clearLeft(); GUIboard.clearRight(); GUIboard.clearTop(); @@ -139,13 +139,13 @@ public class Grootheid } if(!(statics_name == "")){ - GUIboard.writePageToMatrix(getName(), statics_name + getStatics(), periodname); + GUIboard.writePageToMatrix(getName(), statics_name + getStatics(), periodname, p, s); }else if(!(custom == "")){ - GUIboard.writePageToMatrix(getName(), custom, periodname); + GUIboard.writePageToMatrix(getName(), custom, periodname, p, s); } if(!(period == null)){ - GUIboard.writePageToMatrix(getName(), period.toString(), periodname); + GUIboard.writePageToMatrix(getName(), period.toString(), periodname, p, s); } } diff --git a/LangsteRegenPeriode.java b/LangsteRegenPeriode.java index 51705a8..8f70d89 100644 --- a/LangsteRegenPeriode.java +++ b/LangsteRegenPeriode.java @@ -1,3 +1,4 @@ +package weerstation; import java.util.ArrayList; public class LangsteRegenPeriode extends Grootheid{ @@ -25,7 +26,7 @@ public class LangsteRegenPeriode extends Grootheid{ public void display() { - GUIboard.writePageToMatrix("Langste Regen Periode", regenPeriode.toString(), ""); + GUIboard.writePageToMatrix("Langste Regen Periode", regenPeriode.toString(), "", true, true); } public void displayGraph() diff --git a/LangsteTempStijgingPeriode.java b/LangsteTempStijgingPeriode.java index 81805c4..e80e39c 100644 --- a/LangsteTempStijgingPeriode.java +++ b/LangsteTempStijgingPeriode.java @@ -1,3 +1,4 @@ +package weerstation; import java.util.ArrayList; public class LangsteTempStijgingPeriode extends Grootheid @@ -31,7 +32,7 @@ public class LangsteTempStijgingPeriode extends Grootheid public void display() { - GUIboard.writePageToMatrix("Langste temp.stijging", StijgingPeriode.toString(), ""); + GUIboard.writePageToMatrix("Langste temp.stijging", StijgingPeriode.toString(), "", true, true); } public void displayGraph() diff --git a/Weerstation.java b/Weerstation.java index 61ab2cf..095a894 100644 --- a/Weerstation.java +++ b/Weerstation.java @@ -1,3 +1,4 @@ +package weerstation; import java.util.ArrayList; import java.util.Calendar; @@ -89,51 +90,20 @@ public class Weerstation{ { if(button2) { - currentScreen++; - if (currentScreen+1 > periodsScreens.get(periodeNr).size()) - { - currentScreen = 0; - if(button1) - { - periodeNr++; - if (currentScreen+1 > periodsScreens.get(periodeNr).size()) - { - currentScreen = 0; - } - } - } + nextScreen(); } else if(button1) { - periodeNr++; - if (currentScreen+1 > periodsScreens.get(periodeNr).size()) - { - currentScreen = 0; - } + nextPeriod(); } - - if(periodeNr+1 > periodsScreens.size()) - { - periodeNr = 0; - if (currentScreen+1 > periodsScreens.get(periodeNr).size()) - { - currentScreen = 0; - } - } - Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen); - + if(button3) { - if(!graphIsDisplayed) - { - obj.displayGraph(); - graphIsDisplayed = true; - } + displayGraph(); } else { - obj.display(periods.get(periodeNr).getName()); - graphIsDisplayed = false; + displayMain(); } } }, 0, 5*1000); @@ -157,36 +127,37 @@ public class Weerstation{ //Button checker timer.scheduleAtFixedRate( new TimerTask() { - public void run() - { + boolean oldButton1, oldButton2; + public void run() { if(IO.readShort(0x0090) == 1){ //Blauw 1 aan - button1 = true; + button1 = true; }else{ - button1 = false; + button1 = false; } if(IO.readShort(0x00100) == 1){ //Blauw 2 aan button2 = true; }else{ - button2 = false; + button2 = false; } - - Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen); - if(IO.readShort(0x0080) == 1){ //Rood aan button3 = true; - if(!graphIsDisplayed){ - obj.displayGraph(); - graphIsDisplayed = true; - } + displayGraph(); }else{ - if(graphIsDisplayed){ - obj.display(periods.get(periodeNr).getName()); - graphIsDisplayed = false; - } - button3 = false; + button3 = false; + if(graphIsDisplayed){ + displayMain(); + } + } + if(button2 == !oldButton2){ // If the button is changed, the play/pauze icon wil be updated + displayMain(); + oldButton2 = button2; + } + if(button1 == !oldButton1){ // If the button is changed, the play/pauze icon wil be updated + displayMain(); + oldButton1 = button1; } } - }, 0, 100); + }, 0, 200); } public void createPeriods() @@ -571,6 +542,41 @@ public class Weerstation{ { animator.cancel(); } + + public void nextScreen(){ //Set the next screen one screen higher + currentScreen++; + if (currentScreen >= periodsScreens.get(periodeNr).size()){ + currentScreen = 0; + if(button1){ + nextPeriod(); + } + } + } + + public void nextPeriod(){ //Set the next period one period higher + periodeNr++; + if(periodeNr >= periodsScreens.size()){ + periodeNr = 0; + if (currentScreen+1 > periodsScreens.get(periodeNr).size()) + { + currentScreen = 0; + } + } + } + + public void displayGraph(){ + if(!graphIsDisplayed){ + Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen); + obj.displayGraph(); + graphIsDisplayed = true; + } + } + + public void displayMain(){ + Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen); + obj.display(periods.get(periodeNr).getName(), button1, button2); + graphIsDisplayed = false; + } }