|
@@ -29,7 +29,9 @@ coffee_mode_t mode;
|
|
|
|
|
|
int sigValue;
|
|
|
int brewTime; //Brew time in ms
|
|
|
+int menuTimeout;
|
|
|
timer brewTimer(&brewTimeHandler);
|
|
|
+timer menuTimer(&menuTimeHandler);
|
|
|
|
|
|
uint64_t totalHeatingTime; //local copies of the corresponding database entries
|
|
|
uint16_t brewCounter;
|
|
@@ -64,6 +66,10 @@ void *coffeeThread(void *threadid) {
|
|
|
brewTimer.stop();
|
|
|
brewTime = 0;
|
|
|
|
|
|
+ menuTimer.setDivider(4);
|
|
|
+ menuTimer.stop();
|
|
|
+ menuTimeout = 0;
|
|
|
+
|
|
|
initalHeating = true;
|
|
|
mode = MODE_STATE; //Unless we enter the menu we start in state mode
|
|
|
page = PAGE_SOFTOFF;
|
|
@@ -138,9 +144,13 @@ void *coffeeThread(void *threadid) {
|
|
|
leaveMenu();
|
|
|
break;
|
|
|
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
changePage(PAGE_KILL);
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_EXIT);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -157,13 +167,17 @@ void *coffeeThread(void *threadid) {
|
|
|
leaveMenu();
|
|
|
break;
|
|
|
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
if (state == STATE_IDLE || state == STATE_HEATING) {
|
|
|
changePage(PAGE_CLEAN);
|
|
|
} else {
|
|
|
changePage(PAGE_DEMO);
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_SOFTOFF);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -183,9 +197,13 @@ void *coffeeThread(void *threadid) {
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
changePage(PAGE_DEMO);
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_KILL);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -194,9 +212,19 @@ void *coffeeThread(void *threadid) {
|
|
|
pause();
|
|
|
|
|
|
switch (getSigValue(MODE_MENU)) {
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
changePage(PAGE_TEMP);
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ if(state == STATE_IDLE || state == STATE_HEATING){
|
|
|
+ changePage(PAGE_CLEAN);
|
|
|
+ } else if (state == STATE_ERROR || state == STATE_INITALHEATING) {
|
|
|
+ changePage(PAGE_KILL);
|
|
|
+ } else {
|
|
|
+ changePage(PAGE_EXIT);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -205,9 +233,13 @@ void *coffeeThread(void *threadid) {
|
|
|
pause();
|
|
|
|
|
|
switch (getSigValue(MODE_MENU)) {
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
changePage(PAGE_STATS);
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_DEMO);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
case PAGE_STATS:
|
|
@@ -215,9 +247,13 @@ void *coffeeThread(void *threadid) {
|
|
|
pause();
|
|
|
|
|
|
switch (getSigValue(MODE_MENU)) {
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
changePage(PAGE_STATS2);
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_TEMP);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
case PAGE_STATS2:
|
|
@@ -225,9 +261,13 @@ void *coffeeThread(void *threadid) {
|
|
|
pause();
|
|
|
|
|
|
switch (getSigValue(MODE_MENU)) {
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
changePage(PAGE_DESCALING);
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_STATS);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
case PAGE_DESCALING:
|
|
@@ -235,9 +275,13 @@ void *coffeeThread(void *threadid) {
|
|
|
pause();
|
|
|
|
|
|
switch (getSigValue(MODE_MENU)) {
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
changePage(PAGE_EXIT);
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_STATS2);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
case PAGE_EXIT:
|
|
@@ -249,7 +293,7 @@ void *coffeeThread(void *threadid) {
|
|
|
leaveMenu();
|
|
|
break;
|
|
|
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCW:
|
|
|
if (state == STATE_HEATING || state == STATE_ERROR
|
|
|
|| state == STATE_IDLE
|
|
|
|| state == STATE_INITALHEATING) {
|
|
@@ -258,6 +302,10 @@ void *coffeeThread(void *threadid) {
|
|
|
changePage(PAGE_DEMO);
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
+ case SigRotCCW:
|
|
|
+ changePage(PAGE_DESCALING);
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
} //end switch (page)
|
|
@@ -273,6 +321,7 @@ void *coffeeThread(void *threadid) {
|
|
|
if (mode == MODE_STATE) {
|
|
|
halMachineOff();
|
|
|
writeBackCache();
|
|
|
+ //TODO this might be a bit confusing to change the page here even if the menu isnt actually displayed
|
|
|
changePage(PAGE_DEMO);
|
|
|
if (SigValueEmpty())
|
|
|
pause();
|
|
@@ -297,11 +346,13 @@ void *coffeeThread(void *threadid) {
|
|
|
changePage(PAGE_SOFTOFF); //the machine is on, the menu starts with the turning off page
|
|
|
break;
|
|
|
|
|
|
- case SigInt1Psh:
|
|
|
+ case SigRotCCW:
|
|
|
+ case SigRotCW:
|
|
|
//Enter the menu
|
|
|
- if (page != PAGE_DEMO)
|
|
|
- changePage(PAGE_DEMO); //machine is off, the menu starts with the demo page
|
|
|
- changeMode(MODE_MENU);
|
|
|
+ /* This should be not necessary!
|
|
|
+ * if (page != PAGE_DEMO)
|
|
|
+ changePage(PAGE_DEMO); //machine is off, the menu starts with the demo page*/
|
|
|
+ enterMenu();
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
@@ -368,7 +419,7 @@ void *coffeeThread(void *threadid) {
|
|
|
break;
|
|
|
|
|
|
case SigInt1Psh:
|
|
|
- changeMode(MODE_MENU);
|
|
|
+ enterMenu();
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
@@ -416,7 +467,7 @@ void *coffeeThread(void *threadid) {
|
|
|
|
|
|
case SigInt1Psh:
|
|
|
//Enter the menu
|
|
|
- changeMode(MODE_MENU);
|
|
|
+ enterMenu();
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
@@ -460,7 +511,7 @@ void *coffeeThread(void *threadid) {
|
|
|
|
|
|
case SigInt1Psh:
|
|
|
//Enter the menu
|
|
|
- changeMode(MODE_MENU);
|
|
|
+ enterMenu();
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
@@ -583,7 +634,10 @@ int getSigValue(coffee_mode_t mode) {
|
|
|
case SigInt1Psh:
|
|
|
case SigInt1Rls:
|
|
|
case SigInt1RlsLong:
|
|
|
+ case SigRotCCW:
|
|
|
+ case SigRotCW:
|
|
|
sigValue = 0;
|
|
|
+ menuTimeout = 0;
|
|
|
return tmp;
|
|
|
break;
|
|
|
|
|
@@ -644,14 +698,29 @@ void changeMode(coffee_mode_t newMode) {
|
|
|
* leaving the menu
|
|
|
* sets the start page for the next menu call to softoff
|
|
|
*/
|
|
|
-void leaveMenu() {
|
|
|
- //TODO leave the menu after certain time automatically
|
|
|
- logger(V_BREW, "Leaving the menu again...\n");
|
|
|
+void leaveMenu(void) {
|
|
|
+ logger(V_BREW, "Leaving the menu again\n");
|
|
|
//leave the menu again
|
|
|
changeMode(MODE_STATE);
|
|
|
//change page to initial page
|
|
|
changePage(PAGE_SOFTOFF);
|
|
|
+
|
|
|
+ //stop the timeout counter
|
|
|
+ menuTimeout = 0;
|
|
|
+ menuTimer.stop();
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * entering the menu
|
|
|
+ * starts the timeoutcounter and changes the mode to the Menu Mode
|
|
|
+ */
|
|
|
+void enterMenu(void) {
|
|
|
+ logger(V_BREW, "Entering the menu\n");
|
|
|
+ changeMode(MODE_MENU);
|
|
|
+ menuTimeout = 0;
|
|
|
+ menuTimer.start();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Returns the current state of the FSM
|
|
|
*/
|
|
@@ -695,6 +764,17 @@ void brewTimeHandler(void) {
|
|
|
brewTime += 200;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Counter for the menu timeout
|
|
|
+ * When no input is coming from the user the machine leaves the menu automatically after MENUTIMEOUT seconds
|
|
|
+ */
|
|
|
+void menuTimeHandler(void){
|
|
|
+ menuTimeout += 200;
|
|
|
+ if((menuTimeout/1000) >= MENUTIMEOUT) {
|
|
|
+ leaveMenu();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* handles program termination
|
|
|
*/
|