diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-03 09:52:30 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-03 09:52:30 +1100 |
| commit | f2bad894cdac88b94a358cebdb062f426b191d1b (patch) | |
| tree | 4458a1f306055a14bed33b7f81516c3c0c766c1a /src/ui | |
| parent | 3df4cc9e3de6af480d1ff78376a7d811c9270561 (diff) | |
| download | tangara-fw-f2bad894cdac88b94a358cebdb062f426b191d1b.tar.gz | |
Show battery voltage in top bar
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/widget_top_bar.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ui/widget_top_bar.cpp b/src/ui/widget_top_bar.cpp index ba9ee5cb..93cd32a4 100644 --- a/src/ui/widget_top_bar.cpp +++ b/src/ui/widget_top_bar.cpp @@ -82,11 +82,13 @@ TopBar::TopBar(lv_obj_t* parent, bindings_.push_back(model.battery_state.onChangedAndNow( [=](const battery::Battery::BatteryState& state) { + std::ostringstream voltage; + voltage << (state.millivolts / 1000) << "." + << (state.millivolts / 100 % 10) << "V"; if (state.is_charging) { - lv_label_set_text(charging, "+"); - } else { - lv_label_set_text(charging, ""); + voltage << "+"; } + lv_label_set_text(charging, voltage.str().c_str()); if (state.percent >= 95) { lv_img_set_src(battery, &kIconBatteryFull); |
