Skip to content

Commit

Permalink
Fix double promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
xioTechnologies authored Apr 29, 2024
1 parent cc373cb commit 8b5fc82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Fusion/FusionAhrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <float.h> // FLT_MAX
#include "FusionAhrs.h"
#include <math.h> // atan2f, cosf, powf, sinf
#include <math.h> // atan2f, cosf, fabsf, powf, sinf

//------------------------------------------------------------------------------
// Definitions
Expand Down Expand Up @@ -117,7 +117,7 @@ void FusionAhrsUpdate(FusionAhrs *const ahrs, const FusionVector gyroscope, cons
ahrs->accelerometer = accelerometer;

// Reinitialise if gyroscope range exceeded
if ((fabs(gyroscope.axis.x) > ahrs->settings.gyroscopeRange) || (fabs(gyroscope.axis.y) > ahrs->settings.gyroscopeRange) || (fabs(gyroscope.axis.z) > ahrs->settings.gyroscopeRange)) {
if ((fabsf(gyroscope.axis.x) > ahrs->settings.gyroscopeRange) || (fabsf(gyroscope.axis.y) > ahrs->settings.gyroscopeRange) || (fabsf(gyroscope.axis.z) > ahrs->settings.gyroscopeRange)) {
const FusionQuaternion quaternion = ahrs->quaternion;
FusionAhrsReset(ahrs);
ahrs->quaternion = quaternion;
Expand Down
4 changes: 2 additions & 2 deletions Fusion/FusionOffset.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Includes

#include "FusionOffset.h"
#include <math.h> // fabs
#include <math.h> // fabsf

//------------------------------------------------------------------------------
// Definitions
Expand Down Expand Up @@ -57,7 +57,7 @@ FusionVector FusionOffsetUpdate(FusionOffset *const offset, FusionVector gyrosco
gyroscope = FusionVectorSubtract(gyroscope, offset->gyroscopeOffset);

// Reset timer if gyroscope not stationary
if ((fabs(gyroscope.axis.x) > THRESHOLD) || (fabs(gyroscope.axis.y) > THRESHOLD) || (fabs(gyroscope.axis.z) > THRESHOLD)) {
if ((fabsf(gyroscope.axis.x) > THRESHOLD) || (fabsf(gyroscope.axis.y) > THRESHOLD) || (fabsf(gyroscope.axis.z) > THRESHOLD)) {
offset->timer = 0;
return gyroscope;
}
Expand Down

0 comments on commit 8b5fc82

Please sign in to comment.