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