Skip to content

Commit

Permalink
Revert "Replace: isinf -> isinff, isnan -> isnanf"
Browse files Browse the repository at this point in the history
This reverts commit 119bca2.
  • Loading branch information
TheSomeMan committed Jul 15, 2024
1 parent 119bca2 commit 7baaa7c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
14 changes: 7 additions & 7 deletions src/ruuvi_endpoint_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ static re_float re_3_encode_check_invalid (const re_float data,
{
re_float result;

if (isnanf (invalid))
if (isnan (invalid))
{
if (!isnanf (data))
if (!isnan (data))
{
result = RE_3_ENCODE_INVALID_PRECISION;
}
Expand Down Expand Up @@ -55,7 +55,7 @@ static re_float re_3_encode_check_invalid (const re_float data,
static void re_3_encode_acceleration (uint8_t * const buffer,
const re_float acceleration, const re_float invalid)
{
if (!isnanf (re_3_encode_check_invalid (acceleration, invalid)))
if (!isnan (re_3_encode_check_invalid (acceleration, invalid)))
{
int16_t decimal = (int16_t) roundf (acceleration * RE_3_ENCODE_ACC_CONVERT_RATIO);
buffer[0] = ( (uint16_t) decimal) >> RE_3_BYTE_OFFSET;
Expand All @@ -74,7 +74,7 @@ static void re_3_encode_data (uint8_t * const buffer,
buffer[RE_3_OFFSET_HEADER] = RE_3_DESTINATION;

// HUMIDITY
if (!isnanf (re_3_encode_check_invalid (data->humidity_rh, invalid)))
if (!isnan (re_3_encode_check_invalid (data->humidity_rh, invalid)))
{
//Humidity (one lsb is 0.5%, e.g. 128 is 64%). Round the value
buffer[RE_3_OFFSET_HUMIDITY] = (uint8_t) roundf (data->humidity_rh *
Expand All @@ -87,7 +87,7 @@ static void re_3_encode_data (uint8_t * const buffer,

// Temperature

if (!isnanf (re_3_encode_check_invalid (data->temperature_c, invalid)))
if (!isnan (re_3_encode_check_invalid (data->temperature_c, invalid)))
{
//Temperature (MSB is sign, next 7 bits are decimal value)
re_float temperature = data->temperature_c;
Expand Down Expand Up @@ -126,7 +126,7 @@ static void re_3_encode_data (uint8_t * const buffer,

// Pressure

if (!isnanf (re_3_encode_check_invalid (data->pressure_pa, invalid)))
if (!isnan (re_3_encode_check_invalid (data->pressure_pa, invalid)))
{
uint32_t pressure = (uint32_t) data->pressure_pa;
pressure -= RE_3_ENCODE_PRESSURE_INIT_OFFSET;
Expand All @@ -148,7 +148,7 @@ static void re_3_encode_data (uint8_t * const buffer,
data->accelerationz_g, invalid);
// voltage

if (!isnanf (re_3_encode_check_invalid (data->battery_v, invalid)))
if (!isnan (re_3_encode_check_invalid (data->battery_v, invalid)))
{
uint32_t voltage = 0;
re_float voltage_in_mv = (data->battery_v *
Expand Down
10 changes: 5 additions & 5 deletions src/ruuvi_endpoint_5.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void re_5_encode_acceleration (uint8_t * const acceleration_slot,
{
uint16_t coded_acceleration = RE_5_INVALID_ACCELERATION;

if (!isnanf (acceleration))
if (!isnan (acceleration))
{
re_clip (&acceleration, RE_5_ACC_MIN, RE_5_ACC_MAX);
int16_t rounded_acceleration = (int16_t) roundf (acceleration * RE_5_ACC_RATIO);
Expand Down Expand Up @@ -149,7 +149,7 @@ static void re_5_encode_humidity (uint8_t * const buffer, const re_5_data_t * da
uint16_t coded_humidity = RE_5_INVALID_HUMIDITY;
re_float humidity = data->humidity_rh;

if (!isnanf (humidity))
if (!isnan (humidity))
{
re_clip (&humidity, RE_5_HUMI_MIN, RE_5_HUMI_MAX);
coded_humidity = (uint16_t) roundf (humidity * RE_5_HUMI_RATIO);
Expand Down Expand Up @@ -179,7 +179,7 @@ static void re_5_encode_temperature (uint8_t * const buffer, const re_5_data_t *
uint16_t coded_temperature = RE_5_INVALID_TEMPERATURE;
re_float temperature = data->temperature_c;

if (!isnanf (temperature))
if (!isnan (temperature))
{
re_clip (&temperature, RE_5_TEMP_MIN, RE_5_TEMP_MAX);
int16_t rounded_temperature = (int16_t) roundf (temperature * RE_5_TEMP_RATIO);
Expand Down Expand Up @@ -211,7 +211,7 @@ static void re_5_encode_pressure (uint8_t * const buffer, const re_5_data_t * da
uint16_t coded_pressure = RE_5_INVALID_PRESSURE;
re_float pressure = data->pressure_pa;

if (!isnanf (pressure))
if (!isnan (pressure))
{
re_clip (&pressure, RE_5_PRES_MIN, RE_5_PRES_MAX);
pressure += RE_5_PRES_OFFSET;
Expand Down Expand Up @@ -244,7 +244,7 @@ static void re_5_encode_pwr (uint8_t * const buffer, const re_5_data_t * data)
uint16_t coded_tx_power = RE_5_INVALID_POWER;
re_float tx_power = (re_float) data->tx_power;

if (!isnanf (voltage))
if (!isnan (voltage))
{
re_clip (&voltage, RE_5_VOLTAGE_MIN, RE_5_VOLTAGE_MAX);
coded_voltage = (uint16_t) roundf ( (voltage * RE_5_BATT_RATIO)
Expand Down
12 changes: 6 additions & 6 deletions src/ruuvi_endpoint_6.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void re_6_encode_pm (uint8_t * const p_slot, re_float val, const uint32_t
{
uint16_t coded_val = RE_6_INVALID_PM;

if (!isnanf (val))
if (!isnan (val))
{
re_clip (&val, RE_6_PM_MIN, RE_6_PM_MAX);
coded_val = (uint16_t) lrintf (val * RE_6_PM_RATIO);
Expand Down Expand Up @@ -91,7 +91,7 @@ static void re_6_encode_co2 (uint8_t * const p_slot, re_float val)
{
uint16_t coded_val = RE_6_INVALID_CO2;

if (!isnanf (val))
if (!isnan (val))
{
re_clip (&val, RE_6_CO2_MIN, RE_6_CO2_MAX);
coded_val = (uint16_t) lrintf (val * RE_6_CO2_RATIO);
Expand Down Expand Up @@ -123,7 +123,7 @@ static void re_6_encode_humidity (uint8_t * const p_slot, re_float val)
{
uint16_t coded_val = RE_6_INVALID_HUMIDITY;

if (!isnanf (val))
if (!isnan (val))
{
re_clip (&val, RE_6_HUMIDITY_MIN, RE_6_HUMIDITY_MAX);
coded_val = (uint16_t) lrintf (val * RE_6_HUMIDITY_RATIO);
Expand Down Expand Up @@ -155,7 +155,7 @@ static void re_6_encode_voc (uint8_t * const p_slot, re_float val)
{
uint16_t coded_val = RE_6_INVALID_VOC_INDEX;

if ( (!isnanf (val)) && (val >= RE_6_VOC_INDEX_MIN) && (val <= RE_6_VOC_INDEX_MAX))
if ( (!isnan (val)) && (val >= RE_6_VOC_INDEX_MIN) && (val <= RE_6_VOC_INDEX_MAX))
{
coded_val = (uint16_t) lrintf (val * RE_6_VOC_RATIO);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ static void re_6_encode_nox (uint8_t * const p_slot, re_float val)
{
uint16_t coded_val = RE_6_INVALID_NOX_INDEX;

if ( (!isnanf (val)) && (val >= RE_6_NOX_INDEX_MIN) && (val <= RE_6_NOX_INDEX_MAX))
if ( (!isnan (val)) && (val >= RE_6_NOX_INDEX_MIN) && (val <= RE_6_NOX_INDEX_MAX))
{
coded_val = (uint16_t) lrintf (val * RE_6_NOX_RATIO);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ static void re_6_encode_temperature (uint8_t * const p_slot, re_float val)
{
uint16_t coded_val = RE_6_INVALID_TEMPERATURE;

if (!isnanf (val))
if (!isnan (val))
{
re_clip (&val, RE_6_TEMPERATURE_MIN, RE_6_TEMPERATURE_MAX);
coded_val = (uint16_t) lrintf (val * RE_6_TEMPERATURE_RATIO);
Expand Down
8 changes: 4 additions & 4 deletions src/ruuvi_endpoint_8.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void re_8_encode_humidity (uint8_t * const buffer, const re_8_data_t * da
uint16_t coded_humidity = RE_8_INVALID_HUMIDITY;
float humidity = data->humidity_rh;

if (!isnanf (humidity))
if (!isnan (humidity))
{
re_clip (&humidity, RE_8_HUMI_MIN, RE_8_HUMI_MAX);
coded_humidity = (uint16_t) roundf (humidity * RE_8_HUMI_RATIO);
Expand All @@ -56,7 +56,7 @@ static void re_8_encode_temperature (uint8_t * const buffer, const re_8_data_t *
uint16_t coded_temperature = RE_8_INVALID_TEMPERATURE;
float temperature = data->temperature_c;

if (!isnanf (temperature))
if (!isnan (temperature))
{
re_clip (&temperature, RE_8_TEMP_MIN, RE_8_TEMP_MAX);
coded_temperature = (uint16_t) roundf (temperature * RE_8_TEMP_RATIO);
Expand All @@ -71,7 +71,7 @@ static void re_8_encode_pressure (uint8_t * const buffer, const re_8_data_t * da
uint16_t coded_pressure = RE_8_INVALID_PRESSURE;
float pressure = data->pressure_pa;

if (!isnanf (pressure))
if (!isnan (pressure))
{
re_clip (&pressure, RE_8_PRES_MIN, RE_8_PRES_MAX);
pressure += RE_8_PRES_OFFSET;
Expand All @@ -89,7 +89,7 @@ static void re_8_encode_pwr (uint8_t * const buffer, const re_8_data_t * data)
uint16_t coded_tx_power = RE_8_INVALID_POWER;
float tx_power = (float) data->tx_power;

if (!isnanf (voltage))
if (!isnan (voltage))
{
re_clip (&voltage, RE_8_VOLTAGE_MIN, RE_8_VOLTAGE_MAX);
coded_voltage = (uint16_t) roundf ( (voltage * RE_8_BATT_RATIO)
Expand Down
8 changes: 4 additions & 4 deletions src/ruuvi_endpoint_c5.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void re_c5_encode_humidity (uint8_t * const buffer, const re_c5_data_t *
uint16_t coded_humidity = RE_C5_INVALID_HUMIDITY;
re_float humidity = data->humidity_rh;

if (!isnanf (humidity))
if (!isnan (humidity))
{
re_clip (&humidity, RE_C5_HUMI_MIN, RE_C5_HUMI_MAX);
coded_humidity = (uint16_t) roundf (humidity * RE_C5_HUMI_RATIO);
Expand All @@ -94,7 +94,7 @@ static void re_c5_encode_temperature (uint8_t * const buffer, const re_c5_data_t
uint16_t coded_temperature = RE_C5_INVALID_TEMPERATURE;
re_float temperature = data->temperature_c;

if (!isnanf (temperature))
if (!isnan (temperature))
{
re_clip (&temperature, RE_C5_TEMP_MIN, RE_C5_TEMP_MAX);
int16_t rounded_temperature = (int16_t) roundf (temperature * RE_C5_TEMP_RATIO);
Expand All @@ -111,7 +111,7 @@ static void re_c5_encode_pressure (uint8_t * const buffer, const re_c5_data_t *
uint16_t coded_pressure = RE_C5_INVALID_PRESSURE;
re_float pressure = data->pressure_pa;

if (!isnanf (pressure))
if (!isnan (pressure))
{
re_clip (&pressure, RE_C5_PRES_MIN, RE_C5_PRES_MAX);
pressure += RE_C5_PRES_OFFSET;
Expand All @@ -130,7 +130,7 @@ static void re_c5_encode_pwr (uint8_t * const buffer, const re_c5_data_t * data)
uint16_t coded_tx_power = RE_C5_INVALID_POWER;
re_float tx_power = (re_float) data->tx_power;

if (!isnanf (voltage))
if (!isnan (voltage))
{
re_clip (&voltage, RE_C5_VOLTAGE_MIN, RE_C5_VOLTAGE_MAX);
coded_voltage = (uint16_t) roundf ( (voltage * RE_C5_BATT_RATIO)
Expand Down
2 changes: 1 addition & 1 deletion src/ruuvi_endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ re_status_t re_log_write_data (uint8_t * const buffer, const re_float data,
{
err_code |= RE_ERROR_NULL;
}
else if (isnanf (data) || isinff (data))
else if (isnan (data) || isinf (data))
{
err_code |= RE_ERROR_INVALID_PARAM;
}
Expand Down

0 comments on commit 7baaa7c

Please sign in to comment.