|
@@ -24,13 +24,14 @@
|
|
|
#include "database.h"
|
|
|
#include "display.h"
|
|
|
|
|
|
-int state;
|
|
|
+coffee_status_t state;
|
|
|
int sigValue;
|
|
|
int brewTime; //Brew time in ms
|
|
|
timer brewTimer(&brewTimeHandler);
|
|
|
clock_t beginHeating;
|
|
|
clock_t endHeating;
|
|
|
double heatingTime;
|
|
|
+
|
|
|
/**
|
|
|
* Thread for the finite state machine
|
|
|
* It represents the current state of the machine and handles signals coming from
|
|
@@ -247,7 +248,7 @@ bool SigValueEmpty(void) {
|
|
|
* prints the change to the logger
|
|
|
* @param newState
|
|
|
*/
|
|
|
-void changeState(int newState) {
|
|
|
+void changeState(coffee_status_t newState) {
|
|
|
logger(V_BREW, "Changing state to %d\n", newState);
|
|
|
state = newState;
|
|
|
|
|
@@ -257,7 +258,7 @@ void changeState(int newState) {
|
|
|
/**
|
|
|
* Returns the current state of the FSM
|
|
|
*/
|
|
|
-int getState(void) {
|
|
|
+coffee_status_t getState(void) {
|
|
|
return state;
|
|
|
}
|
|
|
|
|
@@ -295,7 +296,7 @@ void coffeeBrew(void) {
|
|
|
brewTimer.start();
|
|
|
while (halGetFlow() < AMOUNT_PREINFUSION) {
|
|
|
usleep(100000);
|
|
|
- if (getState() == SigInt1Psh)
|
|
|
+ if (getSigValue() == SigInt1Psh)
|
|
|
return;
|
|
|
}
|
|
|
brewTimer.stop();
|
|
@@ -309,7 +310,7 @@ void coffeeBrew(void) {
|
|
|
brewTimer.start();
|
|
|
while (brewTime < TIME_SOAK) {
|
|
|
usleep(100000);
|
|
|
- if (getState() == SigInt1Psh)
|
|
|
+ if (getSigValue() == SigInt1Psh)
|
|
|
return;
|
|
|
}
|
|
|
brewTimer.stop();
|
|
@@ -323,7 +324,7 @@ void coffeeBrew(void) {
|
|
|
brewTimer.start();
|
|
|
while (brewTime < TIME_INFUSION && halGetFlow() < AMOUNT_DBLESPRESSO) {
|
|
|
usleep(100000);
|
|
|
- if (getState() == SigInt1Psh)
|
|
|
+ if (getSigValue() == SigInt1Psh)
|
|
|
return;
|
|
|
}
|
|
|
halRelaisOff(RELAIS_PUMP);
|