I've been stuck with a bug that I don't know how to fix and no idea where to start with.
bool test(spinDirection direction){
// If fan's max speed spinning in either direction is less than the expected speed - 80
// Then the fan is blocked
if (direction == CLOCKWISE){
if ((fan.Speed < (2310 + (power.voltage - 10.61)* 158.4 - 80)) && fan.Speed != 0){
return true;
}
}
if (direction == ANTICLOCKWISE){
if ((fan.Speed < (2520 + (power.voltage - 10.61)* 169.5 - 80)) && fan.Speed != 0){
return true;
}
}
return false;
}
I'm calling the function this way:
void blockedornot(){
if (test(CW) || test(ACW)){
error = "blocked";
return;
}
error = ".......";}
I've been testing it and strangely enough it keeps failing the anticlockwise test even though the current fan.Speed is larger than (2520 + (power.voltage - 10.61)* 169.5 - 80). I'm unsure if it's because of the && vs < operator precedence or if it's because of fan.speed is volatile int32_t.
Any help will be appreciated!
Edit: Added the closing braces properly Edit 2: Indenting
Aucun commentaire:
Enregistrer un commentaire