Small additions to rpm
This commit is contained in:
parent
a17572fa1a
commit
0c3d258bd0
20
src/rpm.h
20
src/rpm.h
@ -61,8 +61,8 @@ void initRPMPins() {
|
|||||||
void measureRpm(void * parameter) {
|
void measureRpm(void * parameter) {
|
||||||
while(true) {
|
while(true) {
|
||||||
if(millis()-rpmTimer>250) {
|
if(millis()-rpmTimer>250) {
|
||||||
rpmRight = counter[false]*4;
|
rpmRight = constrain(counter[0], 0, 350)*4;
|
||||||
rpmLeft = counter[true]*4;
|
rpmLeft = constrain(counter[1], 0, 350)*4;
|
||||||
kmh = (wheelCircumference/100) * (rpmRight+rpmLeft)/2 * 60/1000;
|
kmh = (wheelCircumference/100) * (rpmRight+rpmLeft)/2 * 60/1000;
|
||||||
|
|
||||||
sendSpeed = abs(floor(kmh));
|
sendSpeed = abs(floor(kmh));
|
||||||
@ -73,16 +73,16 @@ void measureRpm(void * parameter) {
|
|||||||
rpmTimer = millis();
|
rpmTimer = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
int state = getState(false);
|
int state = getState(0);
|
||||||
if(lastState[false] != state) {
|
if(lastState[0] != state) {
|
||||||
counter[false] = counter[false] + relativeLookup[lastState[false]-1][state-1];
|
counter[0] = counter[0] + relativeLookup[lastState[0]-1][state-1];
|
||||||
lastState[false] = state;
|
lastState[0] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = getState(true);
|
state = getState(1);
|
||||||
if(lastState[true] != state) {
|
if(lastState[1] != state) {
|
||||||
counter[true] = counter[true] + relativeLookup[lastState[true]-1][state-1];
|
counter[1] = counter[1] + relativeLookup[lastState[1]-1][state-1];
|
||||||
lastState[true] = state;
|
lastState[1] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
Loading…
Reference in New Issue
Block a user