Skip to content

Commit 1baba3c

Browse files
2 parents 1ac66db + 53af1d6 commit 1baba3c

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun TMAG5273 Arduino Library
2-
version=1.0.1
2+
version=1.0.3
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=A library to drive the Texas Instruments hall-effect sensor TMAG5273.

src/SparkFun_TMAG5273_Arduino_Library.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,25 +1186,16 @@ int8_t TMAG5273::setZThreshold(float zThreshold)
11861186
}
11871187

11881188
/// @brief Sets the temperature threshold code entered by the user. The
1189-
/// valid temperature threshold ranges are -41C to 170C with the
1190-
/// threshold codes for -41C = 0X1A, and 170C = 0X34. Resoltuion is
1191-
/// 8 degree C/LSB. Default 0x0 means no threshold comparison.
1189+
/// valid temperature threshold ranges are -41C to 170C.
1190+
/// Default 0x0 means no threshold comparison.
11921191
/// @param tempThresh 8-bit value to set the threshold for the temperature limit
11931192
/// TMAG5273_REG_T_CONFIG - bits 7-1
11941193
/// @return Error code (0 is success, negative is failure, positive is warning)
1195-
int8_t TMAG5273::setTemperatureThreshold(float tempThresh)
1194+
int8_t TMAG5273::setTemperatureThreshold(int8_t tempThresh)
11961195
{
1197-
uint8_t temp_reg = 0;
1198-
temp_reg = readRegister(TMAG5273_REG_T_CONFIG);
1199-
1200-
// Shift the value over by 1 to create the correct value to put into the regsiter
1201-
temp_reg = temp_reg | (uint8_t)tempThresh;
1202-
1203-
// Check if the value is within the range as described (-41C through 170C)
1204-
if ((tempThresh > 0X1A) && (tempThresh < 0X34))
1205-
{
1206-
writeRegister(TMAG5273_REG_T_CONFIG, temp_reg); // Write the correct value to the register
1207-
}
1196+
// Write the new address into the register and enable the temperature to be read
1197+
// NOTE: Temperature is set to be enabled here for temperatures readings.
1198+
writeRegister(TMAG5273_REG_T_CONFIG, (tempThresh << 1) | 0x01);
12081199

12091200
return getError();
12101201
}

src/SparkFun_TMAG5273_Arduino_Library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TMAG5273
6262
int8_t setXThreshold(float xThreshold); // Sets the X axis threshold code for limit check
6363
int8_t setYThreshold(float yThreshold); // Sets the Y axis threshold code for limit check
6464
int8_t setZThreshold(float zThresh); // Sets the Z axis threshold code for limit check
65-
int8_t setTemperatureThreshold(float tempThresh); // Sets the Temperature threshold code for limit check
65+
int8_t setTemperatureThreshold(int8_t tempThresh); // Sets the Temperature threshold code for limit check
6666
int8_t setTemperatureEn(
6767
bool temperatureEnable); // Sets the enable bit that determines the data acquisition of the temp channel
6868
int8_t setInterruptResult(bool interruptEnable); // Sets the enable interrupt response bit on conversion complete

0 commit comments

Comments
 (0)