Wil now show play and pauze icons, cleaner code for changing buttons & screens

This commit is contained in:
jancoow
2014-10-25 23:24:39 +02:00
parent 370bca2137
commit 923065bc99
6 changed files with 84 additions and 65 deletions
+13 -2
View File
@@ -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;
+2 -2
View File
@@ -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()
+5 -5
View File
@@ -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);
}
}
+2 -1
View File
@@ -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()
+2 -1
View File
@@ -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()
+60 -54
View File
@@ -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;
}
}