|
@@ -43,7 +43,7 @@ timer idleTimer(&halIdleTimerHandler);
|
|
|
time_t heatingCycle[] = {0, 0};
|
|
|
timespec flowTimestep[] = {{0,0},{0,0}};
|
|
|
uint8_t flowIndex = 0;
|
|
|
-uint16_t rotaryIndex = 0;
|
|
|
+int16_t tickCounter = 0;
|
|
|
|
|
|
timespec pumpCycle[] = {{0,0},{0,0}};
|
|
|
|
|
@@ -119,8 +119,6 @@ void halInit(void) {
|
|
|
logger_error("Unable to setup ISRProximity: %s\n", strerror(errno));
|
|
|
return;
|
|
|
}
|
|
|
- //there are some issues with the serial port so interrupts get triggered without an external source and the program
|
|
|
- //crashes
|
|
|
if (wiringPiISR(PIN_ROTARY1, INT_EDGE_RISING, &halIntRotary) < 0) {
|
|
|
logger_error("Unable to setup ISRRotary2: %s\n", strerror(errno));
|
|
|
return;
|
|
@@ -203,33 +201,27 @@ void halIntRotary(void){
|
|
|
//check for the status of the other pin
|
|
|
if(digitalRead(PIN_ROTARY2)) {
|
|
|
//clockwise rotation
|
|
|
- rotaryIndex = (rotaryIndex + 1) % ROTARY_RESOLUTION;
|
|
|
+ tickCounter++;
|
|
|
|
|
|
- if(!(rotaryIndex % ROTARY_STEPSIZE)) {
|
|
|
- logger(V_HAL, "rotary encoder CW, now at %d\n", rotaryIndex);
|
|
|
+ if(!(tickCounter % ROTARY_STEPSIZE)) {
|
|
|
+ logger(V_HAL, "rotary encoder CW");
|
|
|
halSendSignal(SigRotCW);
|
|
|
+ tickCounter = 0;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
//counterclockwise rotation
|
|
|
- if(rotaryIndex) rotaryIndex--;
|
|
|
- else rotaryIndex = ROTARY_RESOLUTION - 1;
|
|
|
+ tickCounter--;
|
|
|
|
|
|
- if(!(rotaryIndex % ROTARY_STEPSIZE)) {
|
|
|
- logger(V_HAL, "rotary encoder CCW, now at %d\n", rotaryIndex);
|
|
|
+ if(!(abs(tickCounter) % ROTARY_STEPSIZE)) {
|
|
|
+ logger(V_HAL, "rotary encoder CCW");
|
|
|
halSendSignal(SigRotCCW);
|
|
|
+ tickCounter = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- *
|
|
|
- */
|
|
|
-uint16_t halGetRotaryIndex (void){
|
|
|
- return rotaryIndex;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* Interrupt routine for Int0 (Top button)
|