SDK 2.7.0 -- implicit double promotion warnings fix
In [018dbcfd6679c273842084ce34c167295bc6f354](018dbcfd66),
Zephyr introduced the -Wdouble-promotion compiler flag.
We have some debugging logs that implicitly promote floats to double,
and it generates a lot of warnings. This commit fixes it.
This commit is contained in:
parent
5214f904f1
commit
3ef4464b65
4 changed files with 12 additions and 9 deletions
|
|
@ -21,4 +21,6 @@
|
|||
|
||||
#define UNUSED_OK(expr) (void)expr;
|
||||
|
||||
#define DOUBLE_PROMO_OK(expr) (double)(expr)
|
||||
|
||||
#endif // _PRST_MACROS_H_
|
||||
|
|
@ -97,7 +97,8 @@ static inline float get_soil_moisture_percent(float battery_voltage,
|
|||
const float wet = eval_poly(wet_coeffs, x);
|
||||
const float percent = (raw_adc_output - dry) / (wet - dry);
|
||||
LOG_DBG("Read soil moisture 2: %.2f | Raw %u | Batt: %.2f | Dry: %.2f | Wet: %.2f",
|
||||
100.0f * percent, raw_adc_output, x, dry, wet);
|
||||
DOUBLE_PROMO_OK(100 * percent),
|
||||
raw_adc_output, DOUBLE_PROMO_OK(x), DOUBLE_PROMO_OK(dry), DOUBLE_PROMO_OK(wet));
|
||||
return percent;
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +178,7 @@ int prst_adc_photo_read(float battery_voltage, prst_adc_photo_sensor_t* out) {
|
|||
const float current_sun = 3.59e-3f;
|
||||
const float current = out->adc_read.voltage / phototransistor_resistor;
|
||||
out->brightness = MAX(0, MIN(lux_sun * current / current_sun, UINT16_MAX));
|
||||
LOG_DBG("Read phototransistor: %u lx | %.2f V", out->brightness, out->adc_read.voltage);
|
||||
LOG_DBG("Read phototransistor: %u lx | %.2f V", out->brightness, DOUBLE_PROMO_OK(out->adc_read.voltage));
|
||||
|
||||
#elif DT_NODE_EXISTS(DT_NODELABEL(ldr))
|
||||
RET_IF_ERR(gpio_pin_set_dt(&ldr_enable_dt, 1));
|
||||
|
|
@ -201,7 +202,7 @@ int prst_adc_photo_read(float battery_voltage, prst_adc_photo_sensor_t* out) {
|
|||
const float pow_value = 1.5832f;
|
||||
out->brightness =
|
||||
MAX(0, MIN(mult_value / powf(photo_resistance, pow_value), UINT16_MAX));
|
||||
LOG_DBG("Read LDR: %u lx | %.2f V", out->brightness, out->adc_read.voltage);
|
||||
LOG_DBG("Read LDR: %u lx | %.2f V", out->brightness, DOUBLE_PROMO_OK(out->adc_read.voltage));
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ int prst_sensors_read_all(prst_sensors_t *sensors) {
|
|||
RET_IF_ERR(prst_shtc3_read(&sensors->shtc3))
|
||||
|
||||
LOG_DBG("Batt: %d mV (%.2f%%)", sensors->batt.adc_read.millivolts,
|
||||
100 * sensors->batt.percentage);
|
||||
LOG_DBG("Soil: %.0f %%", 100 * sensors->soil.percentage);
|
||||
DOUBLE_PROMO_OK(100 * sensors->batt.percentage));
|
||||
LOG_DBG("Soil: %.0f %%", DOUBLE_PROMO_OK(100 * sensors->soil.percentage));
|
||||
LOG_DBG("Photo: %u lx (%d mV)", sensors->photo.brightness,
|
||||
sensors->photo.adc_read.millivolts);
|
||||
LOG_DBG("Temp: %f oC", sensors->shtc3.temp_c);
|
||||
LOG_DBG("Humi: %.0f %%", 100 * sensors->shtc3.rel_humi);
|
||||
LOG_DBG("Temp: %f oC", DOUBLE_PROMO_OK(sensors->shtc3.temp_c));
|
||||
LOG_DBG("Humi: %.0f %%", DOUBLE_PROMO_OK(100 * sensors->shtc3.rel_humi));
|
||||
LOG_DBG("--------------------------------------------------");
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ int prst_shtc3_read(prst_shtc3_read_t *out) {
|
|||
out->temp_c = -45 + 175 * ((float)((buff[0] << 8) | buff[1])) / (1 << 16);
|
||||
out->rel_humi = ((float)((buff[3] << 8) | buff[4])) / UINT16_MAX;
|
||||
|
||||
LOG_DBG("Read temp: %f oC (%d)", out->temp_c, (int)out->temp_c);
|
||||
LOG_DBG("Read humi: %.0f %%", 100.0 * out->rel_humi);
|
||||
LOG_DBG("Read temp: %f oC (%d)", DOUBLE_PROMO_OK(out->temp_c), (int)out->temp_c);
|
||||
LOG_DBG("Read humi: %.0f %%", DOUBLE_PROMO_OK(100.0f * out->rel_humi));
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue