|
@@ -18,6 +18,8 @@
|
|
volatile int flowcnt = 0;
|
|
volatile int flowcnt = 0;
|
|
|
|
|
|
int Int0Time, Int1Time;
|
|
int Int0Time, Int1Time;
|
|
|
|
+int idleCounter;
|
|
|
|
+bool idle;
|
|
bool flagIgnoreRlsInt0, flagIgnoreRlsInt1;
|
|
bool flagIgnoreRlsInt0, flagIgnoreRlsInt1;
|
|
|
|
|
|
//storage for the last state of the buttons and the proximity sensor
|
|
//storage for the last state of the buttons and the proximity sensor
|
|
@@ -25,12 +27,17 @@ int pinState[3] = {0, 0, 0};
|
|
|
|
|
|
timer Int0Timer(&halInt0TimerHandler);
|
|
timer Int0Timer(&halInt0TimerHandler);
|
|
timer Int1Timer(&halInt1TimerHandler);
|
|
timer Int1Timer(&halInt1TimerHandler);
|
|
|
|
+timer idleTimer(&halIdleTimerHandler);
|
|
|
|
|
|
clock_t heatingCycle[2] = {0, 0};
|
|
clock_t heatingCycle[2] = {0, 0};
|
|
|
|
|
|
//delay of the debounce in milliseconds
|
|
//delay of the debounce in milliseconds
|
|
#define DELAY_DEBOUNCE 50
|
|
#define DELAY_DEBOUNCE 50
|
|
|
|
|
|
|
|
+//display turn off after idle time in min
|
|
|
|
+//minimal time is 2min
|
|
|
|
+#define IDLE_TIME 10
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Initializes HAL
|
|
* Initializes HAL
|
|
*/
|
|
*/
|
|
@@ -57,6 +64,11 @@ void halInit(void) {
|
|
Int0Time = 0;
|
|
Int0Time = 0;
|
|
Int1Time = 0;
|
|
Int1Time = 0;
|
|
|
|
|
|
|
|
+ idleTimer.setDivider(1200); //1 min
|
|
|
|
+ idleTimer.start();
|
|
|
|
+ idleCounter = 0;
|
|
|
|
+ idle = false;
|
|
|
|
+
|
|
flagIgnoreRlsInt0 = false;
|
|
flagIgnoreRlsInt0 = false;
|
|
flagIgnoreRlsInt1 = false;
|
|
flagIgnoreRlsInt1 = false;
|
|
|
|
|
|
@@ -183,6 +195,15 @@ void halInt0TimerHandler(void) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+void halIdleTimerHandler(void) {
|
|
|
|
+ if(++idleCounter == IDLE_TIME){
|
|
|
|
+ halEnterIdle();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Interrupt routine for Int1 (Bottom button)
|
|
* Interrupt routine for Int1 (Bottom button)
|
|
*/
|
|
*/
|
|
@@ -339,13 +360,28 @@ int halGetInt1(void) {
|
|
* @param val Integer value assigned to signal
|
|
* @param val Integer value assigned to signal
|
|
*/
|
|
*/
|
|
void halSendSignal(HalSig val) {
|
|
void halSendSignal(HalSig val) {
|
|
|
|
+ //catch if machine is idle and drop button event
|
|
|
|
+
|
|
|
|
+ switch (val) {
|
|
|
|
+ case SigInt0Psh:
|
|
|
|
+ case SigInt0Rls:
|
|
|
|
+ case SigInt0RlsLong:
|
|
|
|
+ case SigInt1Psh:
|
|
|
|
+ case SigInt1Rls:
|
|
|
|
+ case SigInt1RlsLong:
|
|
|
|
+ idleCounter = 0;
|
|
|
|
+ if (idle) {
|
|
|
|
+ halLeaveIdle();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
sigval value = { 0 };
|
|
sigval value = { 0 };
|
|
value.sival_int = (int) val;
|
|
value.sival_int = (int) val;
|
|
|
|
|
|
try {
|
|
try {
|
|
if (pthread_sigqueue(thread[THREAD_COFFEE], SIGUSR2, value)) {
|
|
if (pthread_sigqueue(thread[THREAD_COFFEE], SIGUSR2, value)) {
|
|
- logger_error("hal.cpp: Failed to queue signal %d %s\n", val,
|
|
|
|
- strerror(errno));
|
|
|
|
|
|
+ logger_error("hal.cpp: Failed to queue signal %d %s\n", val, strerror(errno));
|
|
//No Signals reach the state machine anymore...
|
|
//No Signals reach the state machine anymore...
|
|
exit(EXIT_FAILURE);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
@@ -374,3 +410,19 @@ void halMachineOff(void) {
|
|
halRelaisOff(RELAIS_POWER);
|
|
halRelaisOff(RELAIS_POWER);
|
|
logger(V_HAL, "Turning machine off\n");
|
|
logger(V_HAL, "Turning machine off\n");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+void halEnterIdle(void){
|
|
|
|
+ halDisplayOff();
|
|
|
|
+ idle = true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+void halLeaveIdle(void){
|
|
|
|
+ halDisplayOn();
|
|
|
|
+ idle = false;
|
|
|
|
+}
|