/** Get amplitude for given frequency multiplied with given percentage */
uint32_t MotorVoltage::GetAmpPerc(u32fp frq, uint32_t perc)
{
   uint32_t amp = (perc * (FP_TOINT(FP_MUL(fac, frq)) + boost)) / 100;
   if (frq < minFrq)
   {
      amp = 0;
   }
   if (amp > maxAmp)
   {
      amp = maxAmp;
   }
   if (frq > (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;
}
/**
* Set a parameter
*
* @param[in] ParamNum Parameter index
* @param[in] ParamVal New value of parameter
* @return 0 if set ok, -1 if ParamVal outside of allowed range
*/
char parm_Set(PARAM_NUM ParamNum, s32fp ParamVal)
{
    char res = -1;

    if (ParamVal >= attribs[ParamNum].min && ParamVal <= attribs[ParamNum].max)
    {
        values[ParamNum] = FP_MUL((ParamVal + attribs[ParamNum].ofs), attribs[ParamNum].fac);
        parm_Change(ParamNum);
        res = 0;
    }
    return res;
}
/** Get amplitude for given frequency multiplied with given percentage */
uint32_t MotorVoltage::GetAmpPerc(u32fp frq, uint32_t perc)
{
   uint32_t amp = (perc * (FP_TOINT(FP_MUL(fac, frq)) + boost)) / 100;
   if (frq < minFrq)
   {
      amp = 0;
   }
   if (amp > maxAmp)
   {
      amp = maxAmp;
   }
   return amp;
}