drivers/sensors/hdc1008: fix formatting after decimal point
Modulo operation used to calculate digits after decimal point, but if that result is <10, a leading zero wasn't added, giving a wrong value.
This commit is contained in:
parent
1fe41381d5
commit
34c7bec0dc
@ -632,7 +632,7 @@ static ssize_t hdc1008_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
|
|
||||||
if (priv->mode == HDC1008_MEAS_TEMPERATURE)
|
if (priv->mode == HDC1008_MEAS_TEMPERATURE)
|
||||||
{
|
{
|
||||||
len = snprintf(buffer, buflen, "%d.%d", data.temperature / 100,
|
len = snprintf(buffer, buflen, "%d.%02d", data.temperature / 100,
|
||||||
data.temperature % 100);
|
data.temperature % 100);
|
||||||
}
|
}
|
||||||
else if (priv->mode == HDC1008_MEAS_HUMIDITY)
|
else if (priv->mode == HDC1008_MEAS_HUMIDITY)
|
||||||
@ -642,7 +642,7 @@ static ssize_t hdc1008_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
}
|
}
|
||||||
else if (priv->mode == HDC1008_MEAS_T_AND_RH)
|
else if (priv->mode == HDC1008_MEAS_T_AND_RH)
|
||||||
{
|
{
|
||||||
len = snprintf(buffer, buflen, "%d.%d %d.%d",
|
len = snprintf(buffer, buflen, "%d.%02d %d.%d",
|
||||||
data.temperature / 100, data.temperature % 100,
|
data.temperature / 100, data.temperature % 100,
|
||||||
data.humidity / 10, data.humidity % 10);
|
data.humidity / 10, data.humidity % 10);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user