Ultrawipf / OpenFFBoard

OpenFFBoard is a universal force feedback interface for DIY simulation devices
https://hackaday.io/project/163904-open-ffboard
MIT License
558 stars 117 forks source link

Bugfix: modify return type of getIntV() and getExtV() to int32_t #111

Closed TDA-2030 closed 1 month ago

TDA-2030 commented 1 month ago

As shown in the following code, since the range of the data type uint16_t cannot express numbers greater than 78000, there is a comparison that is always true.

bool TMC4671::hasPower(){
    uint16_t intV = getIntV();
    return (intV > 10000) && (getExtV() > 10000) && (intV < 78000);
}

Therefore, the return type of getExtV() and getIntV() has been changed to int32_t

Ultrawipf commented 1 month ago

Thank you for finding this. As the limit should be 65v it should usually not affect anything at the moment but it seems reasonable to change the type to 32b in case higher voltages are measured at some point.

Have to check if there is anything else that might be affected so i am going to merge into the dev branch first for the next release as it didn't seem to have caused issues yet.