|
@@ -32,6 +32,12 @@ bool flagIgnoreRlsInt0, flagIgnoreRlsInt1;
|
|
|
|
|
|
//storage for the last state of the buttons, the proximity sensor and the pressure sensor
|
|
|
int pinState[4] = {1, 1, 1, 0};
|
|
|
+//state of the rotary encoder
|
|
|
+//0: rotary1 state at t-1
|
|
|
+//1: rotary2 state at t-1
|
|
|
+//2: rotary1 state at t
|
|
|
+//3: rotary2 state at t
|
|
|
+int rotaryState[4] = {1, 0, 0, 1};
|
|
|
|
|
|
//sweep counter to log every brew
|
|
|
uint16_t logcycle = 1;
|
|
@@ -49,6 +55,8 @@ timespec pumpCycle[] = {{0,0},{0,0}};
|
|
|
|
|
|
//delay of the debounce in milliseconds
|
|
|
#define DELAY_DEBOUNCE 50
|
|
|
+#define DELAY_MICRODEB 2
|
|
|
+
|
|
|
|
|
|
//display turn off after idle time in min
|
|
|
//minimal time is 2min
|
|
@@ -119,7 +127,7 @@ void halInit(void) {
|
|
|
logger_error("Unable to setup ISRProximity: %s\n", strerror(errno));
|
|
|
return;
|
|
|
}
|
|
|
- if (wiringPiISR(PIN_ROTARY1, INT_EDGE_RISING, &halIntRotary) < 0) {
|
|
|
+ if (wiringPiISR(PIN_ROTARY1, INT_EDGE_BOTH, &halIntRotary) < 0) {
|
|
|
logger_error("Unable to setup ISRRotary2: %s\n", strerror(errno));
|
|
|
return;
|
|
|
}
|
|
@@ -197,30 +205,40 @@ int halGetRelaisState(int relais) {
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
-void halIntRotary(void){
|
|
|
- //check for the status of the other pin
|
|
|
- if(digitalRead(PIN_ROTARY2)) {
|
|
|
- //clockwise rotation
|
|
|
- tickCounter++;
|
|
|
-
|
|
|
- if(!(tickCounter % ROTARY_STEPSIZE)) {
|
|
|
- logger(V_HAL, "rotary encoder CW");
|
|
|
- halSendSignal(SigRotCW);
|
|
|
- tickCounter = 0;
|
|
|
+void halIntRotary(void) {
|
|
|
+ //delay(DELAY_MICRODEB);
|
|
|
+ rotaryState[2] = digitalRead(PIN_ROTARY1);
|
|
|
+ rotaryState[3] = digitalRead(PIN_ROTARY2);
|
|
|
+
|
|
|
+ if (rotaryState[0] != rotaryState[2]) {
|
|
|
+ //check for the status of the other pin
|
|
|
+ if (rotaryState[1] != rotaryState[3]) {
|
|
|
+ if ((rotaryState[2] == HIGH && rotaryState[3] == LOW) || (rotaryState[2] == LOW && rotaryState[3] == HIGH)) {
|
|
|
+ //clockwise rotation
|
|
|
+ tickCounter++;
|
|
|
+ if (!(abs(tickCounter) % ROTARY_STEPSIZE)) {
|
|
|
+ //logger(V_HAL, "rotary encoder CW \n");
|
|
|
+ halSendSignal(SigRotCW);
|
|
|
+ tickCounter = 0;
|
|
|
+ }
|
|
|
+ } else if ((rotaryState[2] == HIGH && rotaryState[3] == HIGH) || (rotaryState[2] == LOW && rotaryState[3] == LOW)) {
|
|
|
+ //counterclockwise rotation
|
|
|
+ tickCounter--;
|
|
|
+ if (!(abs(tickCounter) % ROTARY_STEPSIZE)) {
|
|
|
+ //logger(V_HAL, "rotary encoder CCW \n");
|
|
|
+ halSendSignal(SigRotCCW);
|
|
|
+ tickCounter = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rotaryState[1] = rotaryState[3];
|
|
|
}
|
|
|
+ rotaryState[0] = rotaryState[2];
|
|
|
}
|
|
|
- else {
|
|
|
- //counterclockwise rotation
|
|
|
- tickCounter--;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- if(!(abs(tickCounter) % ROTARY_STEPSIZE)) {
|
|
|
- logger(V_HAL, "rotary encoder CCW");
|
|
|
- halSendSignal(SigRotCCW);
|
|
|
- tickCounter = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -547,7 +565,7 @@ void halPumpOn(){
|
|
|
*/
|
|
|
|
|
|
void halIncreaseLogCycleCounter(void){
|
|
|
- logcycle++;
|
|
|
+ logcycle = logcycle + 1;
|
|
|
}
|
|
|
|
|
|
/**
|