Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MadisonC-SparkFun committed Nov 29, 2023
2 parents 1ac66db + 53af1d6 commit 1baba3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun TMAG5273 Arduino Library
version=1.0.1
version=1.0.3
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=A library to drive the Texas Instruments hall-effect sensor TMAG5273.
Expand Down
21 changes: 6 additions & 15 deletions src/SparkFun_TMAG5273_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,25 +1186,16 @@ int8_t TMAG5273::setZThreshold(float zThreshold)
}

/// @brief Sets the temperature threshold code entered by the user. The
/// valid temperature threshold ranges are -41C to 170C with the
/// threshold codes for -41C = 0X1A, and 170C = 0X34. Resoltuion is
/// 8 degree C/LSB. Default 0x0 means no threshold comparison.
/// valid temperature threshold ranges are -41C to 170C.
/// Default 0x0 means no threshold comparison.
/// @param tempThresh 8-bit value to set the threshold for the temperature limit
/// TMAG5273_REG_T_CONFIG - bits 7-1
/// @return Error code (0 is success, negative is failure, positive is warning)
int8_t TMAG5273::setTemperatureThreshold(float tempThresh)
int8_t TMAG5273::setTemperatureThreshold(int8_t tempThresh)
{
uint8_t temp_reg = 0;
temp_reg = readRegister(TMAG5273_REG_T_CONFIG);

// Shift the value over by 1 to create the correct value to put into the regsiter
temp_reg = temp_reg | (uint8_t)tempThresh;

// Check if the value is within the range as described (-41C through 170C)
if ((tempThresh > 0X1A) && (tempThresh < 0X34))
{
writeRegister(TMAG5273_REG_T_CONFIG, temp_reg); // Write the correct value to the register
}
// Write the new address into the register and enable the temperature to be read
// NOTE: Temperature is set to be enabled here for temperatures readings.
writeRegister(TMAG5273_REG_T_CONFIG, (tempThresh << 1) | 0x01);

return getError();
}
Expand Down
2 changes: 1 addition & 1 deletion src/SparkFun_TMAG5273_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TMAG5273
int8_t setXThreshold(float xThreshold); // Sets the X axis threshold code for limit check
int8_t setYThreshold(float yThreshold); // Sets the Y axis threshold code for limit check
int8_t setZThreshold(float zThresh); // Sets the Z axis threshold code for limit check
int8_t setTemperatureThreshold(float tempThresh); // Sets the Temperature threshold code for limit check
int8_t setTemperatureThreshold(int8_t tempThresh); // Sets the Temperature threshold code for limit check
int8_t setTemperatureEn(
bool temperatureEnable); // Sets the enable bit that determines the data acquisition of the temp channel
int8_t setInterruptResult(bool interruptEnable); // Sets the enable interrupt response bit on conversion complete
Expand Down

0 comments on commit 1baba3c

Please sign in to comment.