From 38f40034b0a200586429a3d8329479ad13d84d94 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 2 Jul 2021 18:30:32 +0300 Subject: Float voltage to int (#444) * Change voltage float to millivolt integer * Explain the ADC to milliVolts conversion --- src/displayapp/screens/SystemInfo.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/displayapp/screens/SystemInfo.cpp') diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index 1e90bf40..5ae3a595 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -104,8 +104,6 @@ std::unique_ptr SystemInfo::CreateScreen1() { std::unique_ptr SystemInfo::CreateScreen2() { auto batteryPercent = static_cast(batteryController.PercentRemaining()); - float batteryVoltage = batteryController.Voltage(); - auto resetReason = [this]() { switch (watchdog.ResetReason()) { case Drivers::Watchdog::ResetReasons::Watchdog: @@ -144,18 +142,13 @@ std::unique_ptr SystemInfo::CreateScreen2() { uptimeSeconds = uptimeSeconds % secondsInAMinute; // TODO handle more than 100 days of uptime - // hack to not use the flot functions from printf - uint8_t batteryVoltageBytes[2]; - batteryVoltageBytes[1] = static_cast(batteryVoltage); // truncate whole numbers - batteryVoltageBytes[0] = static_cast((batteryVoltage - batteryVoltageBytes[1]) * 100); // remove whole part of flt and shift 2 places over - lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(label, true); lv_label_set_text_fmt(label, "#444444 Date# %02d/%02d/%04d\n" "#444444 Time# %02d:%02d:%02d\n" "#444444 Uptime#\n %02lud %02lu:%02lu:%02lu\n" - "#444444 Battery# %d%%/%1i.%02iv\n" + "#444444 Battery# %d%%/%03imV\n" "#444444 Backlight# %s\n" "#444444 Last reset# %s\n" "#444444 Accel.# %s\n", @@ -170,8 +163,7 @@ std::unique_ptr SystemInfo::CreateScreen2() { uptimeMinutes, uptimeSeconds, batteryPercent, - batteryVoltageBytes[1], - batteryVoltageBytes[0], + batteryController.Voltage(), brightnessController.ToString(), resetReason, ToString(motionController.DeviceType())); -- cgit v1.2.3