To fix it, in the src/generic/fu.cpp file, I have added a (s32fp) casting to the line marked with **. I tested it and seems to be working, but we need Johannes' opinions on this.
Code: Select all
uint32_t MotorVoltage::GetAmpPerc(u32fp frq, u32fp perc)
{
uint32_t amp = FP_MUL(perc, (FP_TOINT(FP_MUL(fac, frq)) + boost)) / 100;
if (frq < minFrq)
{
amp = 0;
}
if (amp > maxAmp)
{
amp = maxAmp;
}
if ((s32fp)frq > (s32fp)(maxFrq - FRQ_DRT_STR)) // **
{
s32fp diff = maxFrq - frq;
diff = diff < 0 ? 0 : diff;
amp = FP_TOINT(FP_MUL(FP_FROMINT(amp), FP_DIV(diff, FRQ_DRT_STR)));
}
return amp;
}