mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-24 06:44:25 -04:00
battery display imp (#2327)
This commit is contained in:
parent
13e4f225ea
commit
c9863187d6
2 changed files with 16 additions and 4 deletions
|
@ -75,7 +75,19 @@ void BattinfoView::update_result() {
|
||||||
text_current.hidden(false);
|
text_current.hidden(false);
|
||||||
text_charge.hidden(false);
|
text_charge.hidden(false);
|
||||||
text_current.set(to_string_dec_int(current) + " mA");
|
text_current.set(to_string_dec_int(current) + " mA");
|
||||||
text_charge.set(current >= 0 ? "Charging" : "Discharging");
|
if (current >= 25) // when >25mA it is charging in any scenario
|
||||||
|
text_charge.set("Charging");
|
||||||
|
else {
|
||||||
|
if (current > -25) { // between -25 and 25
|
||||||
|
if (voltage > 4060 || percent == 100) { // the voltage is high enough, so it is full, that's why no mA
|
||||||
|
text_charge.set("Full");
|
||||||
|
} else {
|
||||||
|
text_charge.set("Holding"); // not enough voltage, so should charge. maybe the batttery is off, or USB power is not enough
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
text_charge.set("Discharging"); // less then -25mA, so it is discharging
|
||||||
|
}
|
||||||
|
}
|
||||||
labels_opt.hidden(false);
|
labels_opt.hidden(false);
|
||||||
|
|
||||||
text_ttef.hidden(false);
|
text_ttef.hidden(false);
|
||||||
|
@ -103,7 +115,7 @@ void BattinfoView::update_result() {
|
||||||
if ((valid_mask & battery::BatteryManagement::BATT_VALID_TTEF) == battery::BatteryManagement::BATT_VALID_TTEF) {
|
if ((valid_mask & battery::BatteryManagement::BATT_VALID_TTEF) == battery::BatteryManagement::BATT_VALID_TTEF) {
|
||||||
text_ttef.hidden(false);
|
text_ttef.hidden(false);
|
||||||
float ttef = 0;
|
float ttef = 0;
|
||||||
if (current <= 0) {
|
if (current <= 0) { // we keep this yet
|
||||||
ttef = battery::BatteryManagement::get_tte();
|
ttef = battery::BatteryManagement::get_tte();
|
||||||
} else {
|
} else {
|
||||||
ttef = battery::BatteryManagement::get_ttf();
|
ttef = battery::BatteryManagement::get_ttf();
|
||||||
|
@ -133,7 +145,7 @@ void BattinfoView::update_result() {
|
||||||
}
|
}
|
||||||
if (uichg) set_dirty();
|
if (uichg) set_dirty();
|
||||||
// to update status bar too, send message in behalf of batt manager
|
// to update status bar too, send message in behalf of batt manager
|
||||||
BatteryStateMessage msg{valid_mask, percent, current >= 0, voltage};
|
BatteryStateMessage msg{valid_mask, percent, current >= 25, voltage};
|
||||||
EventDispatcher::send_message(msg);
|
EventDispatcher::send_message(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ void I2cDev_MAX17055::update() {
|
||||||
getBatteryInfo(validity, batteryPercentage, voltage, current);
|
getBatteryInfo(validity, batteryPercentage, voltage, current);
|
||||||
|
|
||||||
// send local message
|
// send local message
|
||||||
BatteryStateMessage msg{validity, batteryPercentage, current >= 0, voltage};
|
BatteryStateMessage msg{validity, batteryPercentage, current >= 25, voltage};
|
||||||
EventDispatcher::send_message(msg);
|
EventDispatcher::send_message(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue