Prechádzať zdrojové kódy

fixed bug in softoff where machine waited one more heating cycle when turned off in idle, added two more signals for the openhab connection

Sebastian 7 rokov pred
rodič
commit
b75b3c04ef
4 zmenil súbory, kde vykonal 26 pridanie a 10 odobranie
  1. 1 1
      CoffeeCode/buildno
  2. 20 1
      CoffeeCode/coffee.cpp
  3. 3 1
      CoffeeCode/hal.h
  4. 2 7
      CoffeeCode/server.cpp

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-240
+241

+ 20 - 1
CoffeeCode/coffee.cpp

@@ -129,7 +129,12 @@ void *coffeeThread(void *threadid) {
 
 			switch (getSigValue(MODE_MENU)) {
 			case SigInt0Rls:
-				changeState(STATE_WAIT_OFF);
+				if(halIsHeating()){
+					changeState(STATE_WAIT_OFF);
+				}
+				else {
+					changeState(STATE_OFF);
+				}
 				leaveMenu();
 				break;
 
@@ -257,6 +262,7 @@ void *coffeeThread(void *threadid) {
 
 			switch (getSigValue(MODE_STATE)) {
 			case SigInt0Rls:
+			case SigPowerUp:
 				//Check waterlevel in gray water tank
 				//turn machine on
 				halMachineOn();
@@ -297,6 +303,7 @@ void *coffeeThread(void *threadid) {
 
 			case SigInt0Psh:
 			case SigInt1Psh:
+			case SigPowerUp:
 				if (halProxSensorCovered()) {
 					changeState(STATE_FULLTANK);
 				} else if (initalHeating) {
@@ -338,6 +345,10 @@ void *coffeeThread(void *threadid) {
 				changeState(STATE_IDLE);
 				break;
 
+			case SigPowerDown:
+				changeState(STATE_WAIT_OFF);
+				break;
+
 			case SigInt1Psh:
 				changeMode(MODE_MENU);
 				break;
@@ -381,6 +392,10 @@ void *coffeeThread(void *threadid) {
 				changeState(STATE_BREWMANUAL);
 				break;
 
+			case SigPowerDown:
+				changeState(STATE_WAIT_OFF);
+				break;
+
 			case SigInt1Psh:
 				//Enter the menu
 				changeMode(MODE_MENU);
@@ -421,6 +436,10 @@ void *coffeeThread(void *threadid) {
 				changeState(STATE_BREWMANUAL);
 				break;
 
+			case SigPowerDown:
+				changeState(STATE_OFF);
+				break;
+
 			case SigInt1Psh:
 				//Enter the menu
 				changeMode(MODE_MENU);

+ 3 - 1
CoffeeCode/hal.h

@@ -50,7 +50,9 @@ enum HalSig {
 	SigProxOpn = 9,
 	SigProxCvrd = 10,
 	SigBrewOn = 11,
-	SigBrewOff = 12
+	SigBrewOff = 12,
+	SigPowerUp = 13,
+	SigPowerDown = 14
 };
 
 

+ 2 - 7
CoffeeCode/server.cpp

@@ -131,17 +131,12 @@ void* serverThread(void* threadid) {
 
 			if (!strcmp(SERVER_CMD_ON, pcmd)) {
 				if (getState() == STATE_OFF) {
-					halSendSignal(SigInt0Rls);
+					halSendSignal(SigPowerUp);
 					sendACK();
 				}
 			} else if (!strcmp(SERVER_CMD_OFF, pcmd)) {
 				if (getState() != STATE_OFF) {
-					halSendSignal(SigInt1RlsLong);
-					sendACK();
-				}
-			} else if (!strcmp(SERVER_CMD_BREW, pcmd)) {
-				if (getState() == STATE_IDLE || getState() == STATE_HEATING) {
-					halSendSignal(SigInt1Rls);
+					halSendSignal(SigPowerDown);
 					sendACK();
 				}
 			} else if (!strcmp(SERVER_CMD_STATUS, pcmd)) {