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

Merge pull request #8140 from bergzand/pr/jc42test-neg

test/driver_jc42: fix displayed temperature when negative
This commit is contained in:
Alexandre Abadie 2017-11-25 12:42:17 +01:00 committed by GitHub
commit fd1ff458dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,8 +71,16 @@ int main(void)
puts("[Failed]");
return 1;
}
bool negative = (temperature < 0);
if (negative) {
temperature = -temperature;
}
/* display results */
printf("temperature: %d.%02d C\n", temperature / 100, temperature % 100);
printf("temperature: %c%d.%02d C\n",
(negative) ? '-' : ' ',
temperature / 100, temperature % 100);
/* sleep between measurements */
xtimer_usleep(1000 * US_PER_MS);