battery info temperature shown in C or F based on settings (#2360)

* battery Info temperature displays C or F
* PowerSettings: add locale module to dependencies

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Round-Pi 2023-02-06 22:05:52 -05:00 committed by GitHub
parent 147f42a2b7
commit 1ff5843ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@ App(
requires=[
"gui",
"power",
"locale",
],
flags=["InsomniaSafe"],
stack_size=1 * 1024,

View File

@ -2,6 +2,7 @@
#include <furi.h>
#include <gui/elements.h>
#include <assets_icons.h>
#include <locale/locale.h>
#define LOW_CHARGE_THRESHOLD 10
#define HIGH_DRAIN_CURRENT_THRESHOLD 100
@ -101,7 +102,15 @@ static void battery_info_draw_callback(Canvas* canvas, void* context) {
char health[10];
snprintf(batt_level, sizeof(batt_level), "%lu%%", (uint32_t)model->charge);
if(locale_get_measurement_unit() == LocaleMeasurementUnitsMetric) {
snprintf(temperature, sizeof(temperature), "%lu C", (uint32_t)model->gauge_temperature);
} else {
snprintf(
temperature,
sizeof(temperature),
"%lu F",
(uint32_t)locale_celsius_to_fahrenheit(model->gauge_temperature));
}
snprintf(
voltage,
sizeof(voltage),