Quellcode durchsuchen

changed energy page to only kwh, added pinstate for the pressure sensor as well to get a reliable heating time

Sebastian vor 7 Jahren
Ursprung
Commit
65bd16b2d2
3 geänderte Dateien mit 15 neuen und 9 gelöschten Zeilen
  1. 1 1
      CoffeeCode/buildno
  2. 1 1
      CoffeeCode/display.cpp
  3. 13 7
      CoffeeCode/hal.cpp

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-245
+248

+ 1 - 1
CoffeeCode/display.cpp

@@ -81,7 +81,7 @@ void displayPrintStats2(int line) {
 		line = 0;
 
 	uint64_t totalkWh = 2 * getTotalHeatingTime()/(60*60);
-	sprintf(buffer, "%lld min %lld kWh", getTotalHeatingTime()/60, totalkWh);
+	sprintf(buffer, "%lld kWh", totalkWh);
 	displayPrintLn(line, buffer, true);
 }
 

+ 13 - 7
CoffeeCode/hal.cpp

@@ -10,6 +10,7 @@
 #include <string.h>
 #include <signal.h>
 #include <ctime>
+#include <unistd.h>
 #include "hal.h"
 #include "global.h"
 #include "logger.h"
@@ -22,14 +23,14 @@ int idleCounter;
 bool idle;
 bool flagIgnoreRlsInt0, flagIgnoreRlsInt1;
 
-//storage for the last state of the buttons and the proximity sensor
-int pinState[3] = {1, 1, 1};
+//storage for the last state of the buttons, the proximity sensor and the pressure sensor
+int pinState[4] = {1, 1, 1, 0};
 
 timer Int0Timer(&halInt0TimerHandler);
 timer Int1Timer(&halInt1TimerHandler);
 timer idleTimer(&halIdleTimerHandler);
 
-time_t heatingCycle[2] = {0, 0};
+time_t heatingCycle[] = {0, 0};
 
 //delay of the debounce in milliseconds
 #define DELAY_DEBOUNCE	50
@@ -63,6 +64,9 @@ void halInit(void) {
 	} else {
 		halMachineOff();
 	}
+	sleep(1); //wait till the machine eventually turned on when optPower
+
+	pinState[3] = halIsHeating();
 
 	Int0Timer.setDivider(4); //200ms
 	Int1Timer.setDivider(4);
@@ -261,10 +265,12 @@ void halIntFlow(void) {
  */
 void halIntPressure(void) {
 	logger(V_HAL, "IntPressure Control triggered\n");
-	if (halIsHeating()) {
+	if (halIsHeating() && !pinState[3]) {
+		pinState[3] = 1;
 		time(&heatingCycle[0]);
 		halSendSignal(SigPressCls);
-	} else {
+	} else if(!halIsHeating() && pinState[3]) {
+		pinState[3] = 0;
 		time(&heatingCycle[1]);
 		halSendSignal(SigPressOpn);
 	}
@@ -277,11 +283,11 @@ void halIntPressure(void) {
  */
 double halgetHeatingTime(void){
 	if (halIsHeating()) {
-		logger(V_HAL, "Hot Heating Time: %f\n", difftime(time(0), heatingCycle[0]));
+		logger(V_HAL, "Hot Heating Time: %f\n", difftime(time(NULL), heatingCycle[0]));
 		return difftime(time(0), heatingCycle[0]);
 	}
 	else {
-		logger(V_HAL, "Heating Time: %f\n", difftime(heatingCycle[1], heatingCycle[0]));
+		logger(V_HAL, "Heating time: %f\n", difftime(heatingCycle[1], heatingCycle[0]));
 		return difftime(heatingCycle[1], heatingCycle[0]);
 	}
 }