From 5de95d4d162633f370072e48c75f46bf310ea1cb Mon Sep 17 00:00:00 2001 From: shakemid Date: Fri, 15 Sep 2017 19:14:30 +0900 Subject: [PATCH] Change printf --- pcsensor.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pcsensor.c b/pcsensor.c index 6e9656a..dd83ffd 100644 --- a/pcsensor.c +++ b/pcsensor.c @@ -428,18 +428,19 @@ int main(int argc, char **argv) { devices[i].type->decode_func(answer, tempd, calibration); // print temperature - if (formato==2) { - // in Fahrenheit - printf("%s\t%d\tinternal\t%.2f F\n", strdate, i, (9.0 / 5.0 * tempd[0] + 32.0)); - if (devices[i].type->has_sensor == 2) { - printf("%s\t%d\texternal\t%.2f F\n", strdate, i, (9.0 / 5.0 * tempd[1] + 32.0)); - } - } else { - // in Celsius - printf("%s\t%d\tinternal\t%.2f C\n", strdate, i, tempd[0]); - if (devices[i].type->has_sensor == 2) { - printf("%s\t%d\texternal\t%.2f C\n", strdate, i, tempd[1]); - } + printf("%s\t%d\t%s\t%.2f %s\n", + strdate, + i, + devices[i].type->has_sensor == 2 ? "internal" : "temperature", + formato == 2 ? 9.0 / 5.0 * tempd[0] + 32.0 : tempd[0], + formato == 2 ? "F" : "C"); + + if (devices[i].type->has_sensor == 2) { + printf("%s\t%d\texternal\t%.2f %s\n", + strdate, + i, + formato == 2 ? 9.0 / 5.0 * tempd[1] + 32.0 : tempd[1], + formato == 2 ? "F" : "C"); } // print humidity