Просмотр исходного кода

altered idle handling. Not entering idle mode anymore when machine is on. Lets see if this fixes another bug :)

Sebastian 7 лет назад
Родитель
Сommit
95721a7fa6
2 измененных файлов с 11 добавлено и 2 удалено
  1. 1 1
      CoffeeCode/buildno
  2. 10 1
      CoffeeCode/hal.cpp

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-233
+236

+ 10 - 1
CoffeeCode/hal.cpp

@@ -68,6 +68,7 @@ void halInit(void) {
 	idleTimer.start();
 	idleCounter = 0;
 	idle = false;
+	halDisplayOn();
 
 	flagIgnoreRlsInt0 = false;
 	flagIgnoreRlsInt1 = false;
@@ -361,7 +362,6 @@ int halGetInt1(void) {
  */
 void halSendSignal(HalSig val) {
 	//catch if machine is idle and drop button event
-
 	switch (val) {
 	case SigInt0Psh:
 	case SigInt1Psh:
@@ -385,6 +385,7 @@ void halSendSignal(HalSig val) {
 	default:
 		break;
 	}
+
 	sigval value = { 0 };
 	value.sival_int = (int) val;
 
@@ -407,6 +408,7 @@ void halMachineOn(void) {
 	halRelaisOn(RELAIS_HEAT);
 	halRelaisOff(RELAIS_PUMP);
 	halRelaisOn(RELAIS_POWER);
+	idleTimer.stop();
 	logger(V_HAL, "Turning machine on\n");
 }
 
@@ -417,6 +419,9 @@ void halMachineOff(void) {
 	halRelaisOff(RELAIS_HEAT);
 	halRelaisOff(RELAIS_PUMP);
 	halRelaisOff(RELAIS_POWER);
+
+	idleCounter = 0;
+	idleTimer.start();
 	logger(V_HAL, "Turning machine off\n");
 }
 
@@ -424,6 +429,8 @@ void halMachineOff(void) {
  *
  */
 void halEnterIdle(void){
+	logger(V_HAL, "Entering Idle Mode\n");
+	idleTimer.stop();
 	halDisplayOff();
 	idle = true;
 }
@@ -432,6 +439,8 @@ void halEnterIdle(void){
  *
  */
 void halLeaveIdle(void){
+	logger(V_HAL, "Leaving Idle Mode\n");
 	halDisplayOn();
+	idleTimer.start();
 	idle = false;
 }