Register / Login | Desktop view |
Filename | Screenshot 2022-07-04 at 09.58.27.png |
Description | Example |
Filesize | 37 Kbytes |
Downloaded | 383 time(s) |
Download |
calcVal=abs(calcVal);
WholeAndFraction AnalogMenuItem::getWholeAndFraction() const {
WholeAndFraction wf;
int32_t calcVal = int32_t(getCurrentValue()) + int32_t(getOffset());
int32_t divisor = getDivisor();
wf.negative = (calcVal < 0);
calcVal=abs(calcVal);
if (divisor < 2) {
wf.whole = calcVal;
wf.fraction = 0;
}
else {
wf.whole = abs(calcVal) / int16_t(divisor);
int fractMax = getActualDecimalDivisor();
wf.fraction = abs((calcVal % divisor)) * (fractMax / divisor);
}
return wf;
}