summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battery/battery.cpp1
-rw-r--r--src/battery/include/battery.hpp1
-rw-r--r--src/ui/widget_top_bar.cpp8
3 files changed, 7 insertions, 3 deletions
diff --git a/src/battery/battery.cpp b/src/battery/battery.cpp
index 92185db7..aea99654 100644
--- a/src/battery/battery.cpp
+++ b/src/battery/battery.cpp
@@ -84,6 +84,7 @@ auto Battery::Update() -> void {
state_ = BatteryState{
.percent = percent,
+ .millivolts = mV,
.is_charging = is_charging,
};
EmitEvent();
diff --git a/src/battery/include/battery.hpp b/src/battery/include/battery.hpp
index 32e02347..314cd373 100644
--- a/src/battery/include/battery.hpp
+++ b/src/battery/include/battery.hpp
@@ -25,6 +25,7 @@ class Battery {
struct BatteryState {
uint_fast8_t percent;
+ uint32_t millivolts;
bool is_charging;
bool operator==(const BatteryState& other) const {
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);