Browse Source

fixed the bug that the display stayed dark the machine is turned on over openhab and added another todo for the heating time

Sebastian 7 years ago
parent
commit
123d6691e5
4 changed files with 12 additions and 9 deletions
  1. 1 1
      CoffeeCode/buildno
  2. 9 7
      CoffeeCode/hal.cpp
  3. 1 1
      CoffeeCode/hal.h
  4. 1 0
      CoffeeCode/server.cpp

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-244
+245

+ 9 - 7
CoffeeCode/hal.cpp

@@ -275,14 +275,17 @@ void halIntPressure(void) {
  * If called during a heating process, it returns the time elapsed since the heating started
  * If called after a heating process, it returns the total time elapsed during the heating cycle
  */
-double halgetHeatingTime(void){
+float halgetHeatingTime(void){
+	//TODO clock is the improper function for this purpose due to overflow etc
+	//maybe clock_gettime() or use time() and localtime()
+	//stackoverflow: clock() is defined to tell you how much CPU time is used; using more threads uses more CPU time, sleeping threads use less time.
 	if (halIsHeating()) {
-		logger(V_HAL, "Heating Time: %f", (double)(clock() - heatingCycle[0]) / CLOCKS_PER_SEC);
-		return (double)(clock() - heatingCycle[0]) / CLOCKS_PER_SEC;
+		logger(V_HAL, "Hot Heating Time: %f\n", (float)(clock() - heatingCycle[0]) / CLOCKS_PER_SEC);
+		return (float)(clock() - heatingCycle[0]) / CLOCKS_PER_SEC;
 	}
 	else {
-		logger(V_HAL, "Heating Time: %f", (double)(heatingCycle[1] - heatingCycle[0]) / CLOCKS_PER_SEC);
-		return (double)(heatingCycle[1] - heatingCycle[0]) / CLOCKS_PER_SEC;
+		logger(V_HAL, "Heating Time: %f\n", (float)(heatingCycle[1] - heatingCycle[0]) / CLOCKS_PER_SEC);
+		return (float)(heatingCycle[1] - heatingCycle[0]) / CLOCKS_PER_SEC;
 	}
 }
 
@@ -366,7 +369,6 @@ void halSendSignal(HalSig val) {
 	switch (val) {
 	case SigInt0Psh:
 	case SigInt1Psh:
-		idleCounter = 0;
 		if (idle) {
 			return;
 		}
@@ -376,7 +378,6 @@ void halSendSignal(HalSig val) {
 	case SigInt0RlsLong:
 	case SigInt1Rls:
 	case SigInt1RlsLong:
-		idleCounter = 0;
 		if (idle) {
 			halLeaveIdle();
 			return;
@@ -440,6 +441,7 @@ void halEnterIdle(void){
  *
  */
 void halLeaveIdle(void){
+	idleCounter = 0;
 	logger(V_HAL, "Leaving Idle Mode\n");
 	halDisplayOn();
 	idleTimer.start();

+ 1 - 1
CoffeeCode/hal.h

@@ -68,7 +68,7 @@ void halInt0(void);
 void halInt1(void);
 void halIntFlow(void);
 void halIntPressure(void);
-double halgetHeatingTime(void);
+float halgetHeatingTime(void);
 void halIntProximity(void);
 float halGetFlow(void);
 void halResetFlow(void);

+ 1 - 0
CoffeeCode/server.cpp

@@ -131,6 +131,7 @@ void* serverThread(void* threadid) {
 
 			if (!strcmp(SERVER_CMD_ON, pcmd)) {
 				if (getState() == STATE_OFF) {
+					halLeaveIdle();
 					halSendSignal(SigPowerUp);
 					sendACK();
 				}