1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests/driver_hts221: cleanup temperature display logic

This saves 12 bytes when building for samr21-xpro
This commit is contained in:
Alexandre Abadie 2019-09-03 21:19:44 +02:00
parent 0bf2be43eb
commit f750c3a474
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405

View File

@ -18,6 +18,7 @@
* @}
*/
#include <stdlib.h>
#include <stdio.h>
#include "hts221.h"
@ -52,12 +53,8 @@ int main(void)
if (hts221_read_temperature(&dev, &temp) != HTS221_OK) {
puts(" -- failed to read temperature!");
}
bool negative = (temp < 0);
if (negative) {
temp = -temp;
}
printf("H: %u.%u%%, T:%c%u.%u°C\n", (hum / 10), (hum % 10),
(negative ? '-' : ' '), (temp / 10), (temp % 10));
printf("H: %d.%d%%, T: %d.%d°C\n", (hum / 10), (hum % 10),
(temp / 10), abs(temp % 10));
xtimer_sleep(SLEEP_S);
}
return 0;