|
@@ -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]);
|
|
|
}
|
|
|
}
|