Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void loop()
float angleCalculation = sensor.getAngleResult();

Serial.print("XYX: ");
Serial.print(angleCalculation);
Serial.println(" mT");
Serial.print(angleCalculation, 4);
Serial.println("°");

}
else
Expand Down
8 changes: 4 additions & 4 deletions src/SparkFun_TMAG5273_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2644,10 +2644,10 @@ float TMAG5273::getZData()
/// @return Angle measurement result in degrees (float value)
float TMAG5273::getAngleResult()
{
int8_t angleLSB = 0;
int8_t angleMSB = 0;
uint8_t angleLSB = 0;
uint8_t angleMSB = 0;

angleLSB = readRegister(TMAG5273_REG_ANGLE_RESULT_LSB);
angleLSB = readRegister(TMAG5273_REG_ANGLE_RESULT_LSB) & 0b11111111;
angleMSB = readRegister(TMAG5273_REG_ANGLE_RESULT_MSB);

// Variable to hold the full angle MSB and LSB registers
Expand All @@ -2663,7 +2663,7 @@ float TMAG5273::getAngleResult()
angleReg = (angleMSB << 8) | angleLSB;

// Removing the uneeded bits for the fraction value
decValue = (angleReg && (0b0000000000001111)) / 16;
decValue = float(angleLSB & 0b1111) / 16;

// Shift off the decimal value (last 4 bits)
angleVal = angleReg >> 4;
Expand Down