File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
examples/Example3_AngleCalculations Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,8 @@ void loop()
5353 float angleCalculation = sensor.getAngleResult ();
5454
5555 Serial.print (" XYX: " );
56- Serial.print (angleCalculation);
57- Serial.println (" mT " );
56+ Serial.print (angleCalculation, 4 );
57+ Serial.println (" deg " );
5858
5959 }
6060 else
Original file line number Diff line number Diff line change @@ -2644,10 +2644,10 @@ float TMAG5273::getZData()
26442644// / @return Angle measurement result in degrees (float value)
26452645float TMAG5273::getAngleResult ()
26462646{
2647- int8_t angleLSB = 0 ;
2648- int8_t angleMSB = 0 ;
2647+ uint8_t angleLSB = 0 ;
2648+ uint8_t angleMSB = 0 ;
26492649
2650- angleLSB = readRegister (TMAG5273_REG_ANGLE_RESULT_LSB);
2650+ angleLSB = readRegister (TMAG5273_REG_ANGLE_RESULT_LSB) & 0b11111111 ;
26512651 angleMSB = readRegister (TMAG5273_REG_ANGLE_RESULT_MSB);
26522652
26532653 // Variable to hold the full angle MSB and LSB registers
@@ -2663,7 +2663,7 @@ float TMAG5273::getAngleResult()
26632663 angleReg = (angleMSB << 8 ) | angleLSB;
26642664
26652665 // Removing the uneeded bits for the fraction value
2666- decValue = (angleReg && ( 0b0000000000001111 ) ) / 16 ;
2666+ decValue = float (angleLSB & 0b1111 ) / 16 ;
26672667
26682668 // Shift off the decimal value (last 4 bits)
26692669 angleVal = angleReg >> 4 ;
You can’t perform that action at this time.
0 commit comments