From 38975648d25f4729586e7b088853092361713e18 Mon Sep 17 00:00:00 2001 From: Alex Pedenko Date: Tue, 14 May 2019 09:51:46 -0500 Subject: [PATCH] Add word size to integer literals The ATMega2560 appears to be treating the integer literals in MPU9250_DMP::qToFloat as int16_t instead of longs. Add `L` modifier to fix that. --- src/SparkFunMPU9250-DMP.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SparkFunMPU9250-DMP.cpp b/src/SparkFunMPU9250-DMP.cpp index db57b8f..58af134 100644 --- a/src/SparkFunMPU9250-DMP.cpp +++ b/src/SparkFunMPU9250-DMP.cpp @@ -615,9 +615,9 @@ float MPU9250_DMP::qToFloat(long number, unsigned char q) unsigned long mask = 0; for (int i=0; i> q) + ((number & mask) / (float) (2<<(q-1))); + return (number >> q) + ((number & mask) / (float) (2L<<(q-1))); } void MPU9250_DMP::computeEulerAngles(bool degrees) @@ -700,4 +700,4 @@ static void tap_cb(unsigned char direction, unsigned char count) static void orient_cb(unsigned char orient) { mpu9250_orientation = orient; -} \ No newline at end of file +}