From ac56bb6ee031c8f2df6455382d26adbfa70617ac Mon Sep 17 00:00:00 2001 From: Brendan Haines Date: Sun, 28 Apr 2024 00:49:05 -0600 Subject: [PATCH] floats are nice --- app/prj.conf | 3 ++- app/src/main.c | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/prj.conf b/app/prj.conf index 55461d3..5a9a618 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -15,4 +15,5 @@ CONFIG_DISPLAY=y CONFIG_LOG=y CONFIG_CFB_LOG_LEVEL_DBG=y -CONFIG_CHARACTER_FRAMEBUFFER=y \ No newline at end of file +CONFIG_CHARACTER_FRAMEBUFFER=y +CONFIG_CBPRINTF_FP_SUPPORT=y \ No newline at end of file diff --git a/app/src/main.c b/app/src/main.c index 1b939ee..5b5d644 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -218,37 +218,37 @@ int main(void) // return 0; // } - sprintf(str_v, "V:%01d.%06d", voltage.val1, voltage.val2); - sprintf(str_i, "I:%01d.%06d", current.val1, current.val2); - sprintf(str_p, "P:%03d.%04d", pressure.val1, pressure.val2 / 100); - sprintf(str_t, "T:%03d.%04d", temperature.val1, temperature.val2 / 100); - sprintf(str_az, "Z:%03d.%04d", accel_z.val1, accel_z.val2 / 100); - sprintf(str_az_ref, "Z:%03d.%04d", accel_z_ref.val1, accel_z_ref.val2 / 100); - sprintf(str_h, "H:%05d.%06d", humidity.val1, humidity.val2); + sprintf(str_v, "V :%7.5f", voltage.val1 + voltage.val2 * 1e-6); + sprintf(str_i, "I :%7.5f", current.val1 + current.val2 * 1e-6); + sprintf(str_p, "P :%7.4f", pressure.val1 + pressure.val2 * 1e-6); + sprintf(str_t, "T :%7.4f", temperature.val1 + temperature.val2 * 1e-6); + sprintf(str_az, "Z :%7.4f", accel_z.val1 + accel_z.val2 * 1e-6); + sprintf(str_az_ref, "Zr:%7.4f", accel_z_ref.val1 + accel_z_ref.val2 * 1e-6); + sprintf(str_h, "H :%7.5f", humidity.val1 + humidity.val2 * 1e-6); // printf("%s\t%s\t%s\t%s\n", str_v, str_i, str_p, str_t); cfb_framebuffer_clear(dev, false); - if (cfb_print(dev, str_v, 0, 0)) + if (cfb_print(dev, str_az, 0, 0)) { printf("Failed to print a string\n"); continue; } - if (cfb_print(dev, str_i, 0, 16)) - { - printf("Failed to print a string\n"); - continue; - } - if (cfb_print(dev, str_az, 0, 16 * 2)) - { - printf("Failed to print a string\n"); - continue; - } - if (cfb_print(dev, str_az_ref, 0, 16 * 3)) + if (cfb_print(dev, str_az_ref, 0, 16)) { printf("Failed to print a string\n"); continue; } + // if (cfb_print(dev, str_az, 0, 16 * 2)) + // { + // printf("Failed to print a string\n"); + // continue; + // } + // if (cfb_print(dev, str_az_ref, 0, 16 * 3)) + // { + // printf("Failed to print a string\n"); + // continue; + // } cfb_framebuffer_finalize(dev); #if defined(CONFIG_ARCH_POSIX)