|
|
@ -44,9 +44,15 @@ void Rotary::task(void *pvParameters) { |
|
|
|
uint32_t ulNotificationValue; |
|
|
|
while(true) { |
|
|
|
ulNotificationValue = ulTaskNotifyTake( pdFALSE, portMAX_DELAY ); |
|
|
|
int newPos = encoderPos/2; |
|
|
|
if (lastPos != newPos) |
|
|
|
if (callback) callback(newPos); |
|
|
|
debouncePulses++; |
|
|
|
if (debouncePulses > 3) { |
|
|
|
debouncePulses = 0; |
|
|
|
if (encoderPos > encoderPosOld+1) value++; |
|
|
|
else if (encoderPos < encoderPosOld-1) value--; |
|
|
|
else continue; |
|
|
|
encoderPosOld = encoderPos; |
|
|
|
if (callback) callback(value); |
|
|
|
} |
|
|
|
} |
|
|
|
vTaskDelete(NULL); |
|
|
|
} |
|
|
|