@@ -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}
0 commit comments