Fix for screens + layout improvements

Fixed the screens continuing to move on, even when they should pause
when looking at a graph.
This commit is contained in:
Kenneth van Ewijk
2014-10-26 12:09:20 +01:00
parent 923065bc99
commit 0bcb978190
+74 -47
View File
@@ -1,4 +1,4 @@
package weerstation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@@ -90,20 +90,26 @@ public class Weerstation{
{ {
if(button2) if(button2)
{ {
nextScreen(); if(!graphIsDisplayed)
{
nextScreen();
}
} }
else if(button1) else if(button1)
{ {
nextPeriod(); if(!graphIsDisplayed)
{
nextPeriod();
}
} }
if(button3) if(button3)
{ {
displayGraph(); displayGraph();
} }
else else
{ {
displayMain(); displayMain();
} }
} }
}, 0, 5*1000); }, 0, 5*1000);
@@ -127,34 +133,47 @@ public class Weerstation{
//Button checker //Button checker
timer.scheduleAtFixedRate( new TimerTask() timer.scheduleAtFixedRate( new TimerTask()
{ {
boolean oldButton1, oldButton2; boolean oldButton1, oldButton2;
public void run() { public void run()
if(IO.readShort(0x0090) == 1){ //Blauw 1 aan {
button1 = true; if(IO.readShort(0x0090) == 1)
}else{ { //Blauw 1 aan
button1 = false; button1 = true;
} }
if(IO.readShort(0x00100) == 1){ //Blauw 2 aan else
{
button1 = false;
}
if(IO.readShort(0x00100) == 1)
{ //Blauw 2 aan
button2 = true; button2 = true;
}else{
button2 = false;
} }
if(IO.readShort(0x0080) == 1){ //Rood aan else
{
button2 = false;
}
if(IO.readShort(0x0080) == 1)
{ //Rood aan
button3 = true; button3 = true;
displayGraph(); displayGraph();
}else{
button3 = false;
if(graphIsDisplayed){
displayMain();
}
} }
if(button2 == !oldButton2){ // If the button is changed, the play/pauze icon wil be updated else
displayMain(); {
oldButton2 = button2; button3 = false;
if(graphIsDisplayed)
{
displayMain();
}
} }
if(button1 == !oldButton1){ // If the button is changed, the play/pauze icon wil be updated if(button2 == !oldButton2)
displayMain(); { // If the button is changed, the play/pauze icon wil be updated
oldButton1 = button1; displayMain();
oldButton2 = button2;
}
if(button1 == !oldButton1)
{ // If the button is changed, the play/pauze icon wil be updated
displayMain();
oldButton1 = button1;
} }
} }
}, 0, 200); }, 0, 200);
@@ -543,39 +562,47 @@ public class Weerstation{
animator.cancel(); animator.cancel();
} }
public void nextScreen(){ //Set the next screen one screen higher public void nextScreen()
currentScreen++; { //Set the next screen one screen higher
if (currentScreen >= periodsScreens.get(periodeNr).size()){ currentScreen++;
currentScreen = 0; if (currentScreen >= periodsScreens.get(periodeNr).size())
if(button1){ {
nextPeriod(); currentScreen = 0;
} if(button1)
} {
nextPeriod();
}
}
} }
public void nextPeriod(){ //Set the next period one period higher public void nextPeriod()
periodeNr++; { //Set the next period one period higher
if(periodeNr >= periodsScreens.size()){ periodeNr++;
periodeNr = 0; if(periodeNr >= periodsScreens.size())
{
periodeNr = 0;
if (currentScreen+1 > periodsScreens.get(periodeNr).size()) if (currentScreen+1 > periodsScreens.get(periodeNr).size())
{ {
currentScreen = 0; currentScreen = 0;
} }
} }
} }
public void displayGraph(){ public void displayGraph()
if(!graphIsDisplayed){ {
if(!graphIsDisplayed)
{
Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen); Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen);
obj.displayGraph(); obj.displayGraph();
graphIsDisplayed = true; graphIsDisplayed = true;
} }
} }
public void displayMain(){ public void displayMain()
{
Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen); Grootheid obj = periodsScreens.get(periodeNr).get(currentScreen);
obj.display(periods.get(periodeNr).getName(), button1, button2); obj.display(periods.get(periodeNr).getName(), button1, button2);
graphIsDisplayed = false; graphIsDisplayed = false;
} }
} }