mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
2 corrections of bugs about the battery level in the settings (#148)
* added battery level handler for simulator * added battery level > 100% when charging * corrected version * laury version but with float type * Update apps/settings/sub_menu/about_controller.cpp * Update apps/settings/sub_menu/about_controller.cpp Co-authored-by: = <=> Co-authored-by: Lauryy06 <80424145+Lauryy06@users.noreply.github.com>
This commit is contained in:
@@ -112,11 +112,21 @@ bool AboutController::handleEvent(Ion::Events::Event event) {
|
||||
if(childLabel == I18n::Message::Battery){
|
||||
MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)m_selectableTableView.selectedCell();
|
||||
char batteryLevel[5];
|
||||
if(strchr(myCell->accessoryText(), '%') == NULL){
|
||||
int batteryLen = Poincare::Integer((int) ((Ion::Battery::voltage() - 3.6) * 166)).serialize(batteryLevel, 5);
|
||||
batteryLevel[batteryLen] = '%';
|
||||
batteryLevel[batteryLen+1] = '\0';
|
||||
}else{
|
||||
if(strchr(myCell->accessoryText(), '%') == NULL) {
|
||||
float voltage = (Ion::Battery::voltage() - 3.6) * 166;
|
||||
if(voltage < 0.0) {
|
||||
myCell->setAccessoryText("1%"); // We cheat...
|
||||
return true;
|
||||
} else if (voltage >= 100.0) {
|
||||
myCell->setAccessoryText("100%");
|
||||
return true;
|
||||
} else {
|
||||
int batteryLen = Poincare::Integer((int) voltage).serialize(batteryLevel, 5);
|
||||
batteryLevel[batteryLen] = '%';
|
||||
batteryLevel[batteryLen+1] = '\0';
|
||||
}
|
||||
}
|
||||
else {
|
||||
int batteryLen = Poincare::Number::FloatNumber(Ion::Battery::voltage()).serialize(batteryLevel, 5, Poincare::Preferences::PrintFloatMode::Decimal, 3);
|
||||
batteryLevel[batteryLen] = 'V';
|
||||
batteryLevel[batteryLen+1] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user