From 87ef19a9de5c9463ff9427568d2222076c8102f6 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Mon, 4 Jul 2022 07:54:39 +0200 Subject: [PATCH] static: fix format warnings --- radio/src/thirdparty/libopenui/src/static.cpp | 72 +++++++++++++++++++ radio/src/thirdparty/libopenui/src/static.h | 15 +--- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/static.cpp b/radio/src/thirdparty/libopenui/src/static.cpp index 01cadec64..d64c6466a 100644 --- a/radio/src/thirdparty/libopenui/src/static.cpp +++ b/radio/src/thirdparty/libopenui/src/static.cpp @@ -74,3 +74,75 @@ void StaticText::setBackgroundColor(LcdFlags color) lv_color_t c = makeLvColor(bgColor); lv_obj_set_style_bg_color(lvobj, c, LV_PART_MAIN); } + +template <> +void DynamicNumber::updateText() +{ + if (lvobj) { + const char* p = prefix ? prefix : ""; + const char* s = suffix ? suffix : ""; + if ((textFlags & PREC2) == PREC2) { + lv_label_set_text_fmt(lvobj, "%s%" PRIu32 ".%02" PRIu32 "%s", p, + value / 100, value % 100, s); + } else if (textFlags & PREC1) { + lv_label_set_text_fmt(lvobj, "%s%" PRIu32 ".%01" PRIu32 "%s", p, + value / 10, value % 10, s); + } else { + lv_label_set_text_fmt(lvobj, "%s%" PRIu32 "%s", p, value, s); + } + } +} + +template <> +void DynamicNumber::updateText() +{ + if (lvobj) { + const char* p = prefix ? prefix : ""; + const char* s = suffix ? suffix : ""; + if ((textFlags & PREC2) == PREC2) { + lv_label_set_text_fmt(lvobj, "%s%" PRId32 ".%02" PRId32 "%s", p, + value / 100, value % 100, s); + } else if (textFlags & PREC1) { + lv_label_set_text_fmt(lvobj, "%s%" PRId32 ".%01" PRId32 "%s", p, + value / 10, value % 10, s); + } else { + lv_label_set_text_fmt(lvobj, "%s%" PRId32 "%s", p, value, s); + } + } +} + +template <> +void DynamicNumber::updateText() +{ + if (lvobj) { + const char* p = prefix ? prefix : ""; + const char* s = suffix ? suffix : ""; + if ((textFlags & PREC2) == PREC2) { + lv_label_set_text_fmt(lvobj, "%s%" PRIu16 ".%02" PRIu16 "%s", p, + value / 100, value % 100, s); + } else if (textFlags & PREC1) { + lv_label_set_text_fmt(lvobj, "%s%" PRIu16 ".%01" PRIu16 "%s", p, + value / 10, value % 10, s); + } else { + lv_label_set_text_fmt(lvobj, "%s%" PRIu16 "%s", p, value, s); + } + } +} + +template <> +void DynamicNumber::updateText() +{ + if (lvobj) { + const char* p = prefix ? prefix : ""; + const char* s = suffix ? suffix : ""; + if ((textFlags & PREC2) == PREC2) { + lv_label_set_text_fmt(lvobj, "%s%" PRId16 ".%02" PRId16 "%s", p, + value / 100, value % 100, s); + } else if (textFlags & PREC1) { + lv_label_set_text_fmt(lvobj, "%s%" PRId16 ".%01" PRId16 "%s", p, + value / 10, value % 10, s); + } else { + lv_label_set_text_fmt(lvobj, "%s%" PRId16 "%s", p, value, s); + } + } +} diff --git a/radio/src/thirdparty/libopenui/src/static.h b/radio/src/thirdparty/libopenui/src/static.h index b408d18af..18516fb34 100644 --- a/radio/src/thirdparty/libopenui/src/static.h +++ b/radio/src/thirdparty/libopenui/src/static.h @@ -181,18 +181,5 @@ class DynamicNumber : public StaticText const char *prefix; const char *suffix; - void updateText() - { - if (lvobj) { - const char *p = prefix ? prefix : ""; - const char *s = suffix ? suffix : ""; - if ((textFlags & PREC2) == PREC2) { - lv_label_set_text_fmt(lvobj, "%s%d.%02d%s", p, value / 100, value % 100, s); - } else if (textFlags & PREC1) { - lv_label_set_text_fmt(lvobj, "%s%d.%01d%s", p, value / 10, value % 10, s); - } else { - lv_label_set_text_fmt(lvobj, "%s%d%s", p, value, s); - } - } - } + void updateText(); };