Cast Ints to float in constrainf. What happens if we return an int on a function which returns a float? Just to be sure

This commit is contained in:
mdhsweden 2016-10-31 18:30:09 +01:00
parent 3039f3a394
commit 4b7fd40967

View File

@ -1,6 +1,6 @@
/**************************************************************************
* NAME: pid.c *
* AUTHOR: Johan Gärtner *
* AUTHOR: Johan G<EFBFBD>rtner *
*
* PURPOSE: This file contains pid functions *
* INFORMATION: pidUAV is the final pid controller which only takes *
@ -114,9 +114,9 @@ float convertData(int inputRange, int outputRange, int offset, float value)
float constrainf(float amt, int low, int high)
{
if (amt < low)
return low;
return (float)low;
else if (amt > high)
return high;
return (float)high;
else
return amt;
}
@ -469,7 +469,7 @@ void pidUAVInitBuff(pidProfileBuff_t *pidProfile, uint8_t ID)
case PID_ID_GYRO:
PidProfileBuff[ID].DOF = 3;
PidProfileBuff[ID].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //ÄNDRA TILL SEKUNDER inte ms
PidProfileBuff[ID].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //<EFBFBD>NDRA TILL SEKUNDER inte ms
break;
case PID_ID_ACCELEROMETER:
@ -631,7 +631,7 @@ void pidEproom(void)
PidProfile[PID_ID_ACCELEROMETER].PIDweight[PITCH] = 2;
PidProfile[PID_ID_ACCELEROMETER].PIDweight[YAW] = 100;
PidProfileBuff[PID_ID_GYRO].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //ÄNDRA TILL SEKUNDER inte ms
PidProfileBuff[PID_ID_GYRO].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //<EFBFBD>NDRA TILL SEKUNDER inte ms
PidProfileBuff[PID_ID_ACCELEROMETER].dT = SystemTasks[TASK_ACCELEROMETER].desiredPeriod/1000000;
PidProfileBuff[PID_ID_COMPASS].dT = SystemTasks[TASK_COMPASS].desiredPeriod/1000000;
PidProfileBuff[PID_ID_BAROMETER].dT = SystemTasks[TASK_BARO].desiredPeriod/1000000;