Small additions to rpm

master
Lukas Bachschwell 5 years ago
parent a17572fa1a
commit 0c3d258bd0

@ -61,8 +61,8 @@ void initRPMPins() {
void measureRpm(void * parameter) {
while(true) {
if(millis()-rpmTimer>250) {
rpmRight = counter[false]*4;
rpmLeft = counter[true]*4;
rpmRight = constrain(counter[0], 0, 350)*4;
rpmLeft = constrain(counter[1], 0, 350)*4;
kmh = (wheelCircumference/100) * (rpmRight+rpmLeft)/2 * 60/1000;
sendSpeed = abs(floor(kmh));
@ -73,16 +73,16 @@ void measureRpm(void * parameter) {
rpmTimer = millis();
}
int state = getState(false);
if(lastState[false] != state) {
counter[false] = counter[false] + relativeLookup[lastState[false]-1][state-1];
lastState[false] = state;
int state = getState(0);
if(lastState[0] != state) {
counter[0] = counter[0] + relativeLookup[lastState[0]-1][state-1];
lastState[0] = state;
}
state = getState(true);
if(lastState[true] != state) {
counter[true] = counter[true] + relativeLookup[lastState[true]-1][state-1];
lastState[true] = state;
state = getState(1);
if(lastState[1] != state) {
counter[1] = counter[1] + relativeLookup[lastState[1]-1][state-1];
lastState[1] = state;
}
vTaskDelay(pdMS_TO_TICKS(1));

Loading…
Cancel
Save