Skip to content

Commit 07d5867

Browse files
committed
clean up changes for init from PRs - add some comments also
1 parent 320ad48 commit 07d5867

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/SparkFun_TMAG5273_Arduino_Library.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ int8_t TMAG5273::begin(uint8_t sensorAddress, TwoWire &wirePort)
4949
setOperatingMode(TMAG5273_CONTINUOUS_MEASURE_MODE);
5050

5151
// 12/2025 - add as part of update -- from a PR pending on the repo
52+
// When the device is reset, these settings must also be reset or init can fail
53+
54+
// No angle calculation
5255
setAngleEn(TMAG5273_NO_ANGLE_CALCULATION);
56+
57+
// Set to low active current mode
5358
setLowPower(TMAG5273_LOW_ACTIVE_CURRENT_MODE);
5459

5560
// Set the axis ranges for the device to be the largest
@@ -76,10 +81,9 @@ int8_t TMAG5273::begin(uint8_t sensorAddress, TwoWire &wirePort)
7681
if (getTemperatureEN() != TMAG5273_TEMPERATURE_ENABLE)
7782
return 0;
7883

79-
// 12/2025 - removed as part of update -- from a PR pending on the repo
80-
// // Check that X and Y angle calculation is disabled
81-
// if (getAngleEn() != TMAG5273_NO_ANGLE_CALCULATION)
82-
// return 0;
84+
// Check that X and Y angle calculation is disabled
85+
if (getAngleEn() != TMAG5273_NO_ANGLE_CALCULATION)
86+
return 0;
8387

8488
// returns true if all the checks pass
8589
return 1;
@@ -1022,24 +1026,24 @@ int8_t TMAG5273::setAngleEn(uint8_t angleEnable)
10221026
return -1;
10231027

10241028
// If-Else statement for writing values to the register, bit by bit
1025-
if (angleEnable == 0X0) // 0b00
1029+
if (angleEnable == 0X0) // 0b00 - no angle
10261030
{
10271031
// Write 0 to bit 2 of the register value
10281032
bitWrite(mode, 2, 0);
10291033
// Write 0 to bit 3 of the register value
10301034
bitWrite(mode, 3, 0);
10311035
}
1032-
else if (angleEnable == 0X1) // 0b01
1036+
else if (angleEnable == 0X1) // 0b01 1 = X 1st, Y 2nd
10331037
{
10341038
bitWrite(mode, 2, 1);
10351039
bitWrite(mode, 3, 0);
10361040
}
1037-
else if (angleEnable == 0X2) // 0b10
1041+
else if (angleEnable == 0X2) // 0b10 2 = Y 1st, Z 2nd
10381042
{
10391043
bitWrite(mode, 2, 0);
10401044
bitWrite(mode, 3, 1);
10411045
}
1042-
else if (angleEnable == 0X3) // 0b11
1046+
else if (angleEnable == 0X3) // 0b11 3 = X 1st, Z 2nd
10431047
{
10441048
bitWrite(mode, 2, 1);
10451049
bitWrite(mode, 3, 1);

0 commit comments

Comments
 (0)