mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Show battery percentage in about menu (#69)
This commit is contained in:
@@ -100,6 +100,22 @@ bool AboutController::handleEvent(Ion::Events::Event event) {
|
||||
|
||||
return true;
|
||||
}
|
||||
if(childLabel == I18n::Message::Battery){
|
||||
MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)m_selectableTableView.selectedCell();
|
||||
char batteryLevel[15];
|
||||
if(strchr(myCell->accessoryText(), '%') == NULL){
|
||||
int batteryLen = Poincare::Integer((int) ((Ion::Battery::voltage() - 3.6) * 166)).serialize(batteryLevel, 15);
|
||||
batteryLevel[batteryLen] = '%';
|
||||
batteryLevel[batteryLen+1] = '\0';
|
||||
}else{
|
||||
int batteryLen = Poincare::Number::FloatNumber(Ion::Battery::voltage()).serialize(batteryLevel, 15, Poincare::Preferences::PrintFloatMode::Decimal, 3);
|
||||
batteryLevel[batteryLen] = 'V';
|
||||
batteryLevel[batteryLen+1] = '\0';
|
||||
}
|
||||
|
||||
myCell->setAccessoryText(batteryLevel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user