mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +02:00
bugfix(temperature_sensor): Fix issue that get the value is negative
This commit is contained in:
@ -120,7 +120,7 @@ static void read_delta_t_from_efuse(void)
|
||||
ESP_LOGD(TAG, "s_deltaT = %f", s_deltaT);
|
||||
}
|
||||
|
||||
static float parse_temp_sensor_raw_value(uint32_t tsens_raw)
|
||||
static float parse_temp_sensor_raw_value(int16_t tsens_raw)
|
||||
{
|
||||
if (isnan(s_deltaT)) { //suggests that the value is not initialized
|
||||
read_delta_t_from_efuse();
|
||||
@ -135,7 +135,7 @@ esp_err_t temp_sensor_read_celsius(float *celsius)
|
||||
temp_sensor_config_t tsens;
|
||||
temp_sensor_get_config(&tsens);
|
||||
bool range_changed;
|
||||
uint16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
|
||||
int16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
|
||||
*celsius = parse_temp_sensor_raw_value(tsens_out);
|
||||
if (*celsius < TEMPERATURE_SENSOR_MEASURE_MIN || *celsius > TEMPERATURE_SENSOR_MEASURE_MAX) {
|
||||
ESP_LOGE(TAG, "Exceeding temperature measure range.");
|
||||
|
@ -142,7 +142,7 @@ static void read_delta_t_from_efuse(void)
|
||||
ESP_LOGD(TAG, "s_deltaT = %f\n", s_deltaT);
|
||||
}
|
||||
|
||||
static float parse_temp_sensor_raw_value(uint32_t tsens_raw)
|
||||
static float parse_temp_sensor_raw_value(int16_t tsens_raw)
|
||||
{
|
||||
if (isnan(s_deltaT)) { //suggests that the value is not initialized
|
||||
read_delta_t_from_efuse();
|
||||
@ -157,7 +157,7 @@ esp_err_t temp_sensor_read_celsius(float *celsius)
|
||||
temp_sensor_config_t tsens;
|
||||
temp_sensor_get_config(&tsens);
|
||||
bool range_changed;
|
||||
uint16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
|
||||
int16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
|
||||
*celsius = parse_temp_sensor_raw_value(tsens_out);
|
||||
if (*celsius < TEMPERATURE_SENSOR_MEASURE_MIN || *celsius > TEMPERATURE_SENSOR_MEASURE_MAX) {
|
||||
ESP_LOGE(TAG, "Exceeding temperature measure range.");
|
||||
|
Reference in New Issue
Block a user