mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
tests/driver_bmx280: fix displayed temperature when negative
This commit is contained in:
parent
612d49db3e
commit
5f0eae18b3
@ -83,6 +83,10 @@ int main(void)
|
||||
|
||||
/* Get temperature in centi degrees Celsius */
|
||||
temperature = bmx280_read_temperature(&dev);
|
||||
bool negative = (temperature < 0);
|
||||
if (negative) {
|
||||
temperature = -temperature;
|
||||
}
|
||||
|
||||
/* Get pressure in Pa */
|
||||
pressure = bmx280_read_pressure(&dev);
|
||||
@ -92,12 +96,13 @@ int main(void)
|
||||
humidity = bme280_read_humidity(&dev);
|
||||
#endif
|
||||
|
||||
printf("Temperature [°C]: %d.%d\n"
|
||||
printf("Temperature [°C]:%c%d.%d\n"
|
||||
"Pressure [Pa]: %lu\n"
|
||||
#if defined(MODULE_BME280)
|
||||
"Humidity [%%rH]: %u.%02u\n"
|
||||
#endif
|
||||
"\n+-------------------------------------+\n",
|
||||
(negative) ? '-' : ' ',
|
||||
temperature / 100, (temperature % 100) / 10,
|
||||
#if defined(MODULE_BME280)
|
||||
(unsigned long)pressure,
|
||||
|
Loading…
Reference in New Issue
Block a user