mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-09-11 06:09:42 -05:00
* Map the battery precent from [0, 90] to [0, 100].
This commit is contained in:
@@ -124,6 +124,10 @@ int PMU::get_bat_percent()
|
||||
auto f = fs::File("/sys/class/power_supply/cw2015-battery/capacity", "r");
|
||||
auto line = f.readline();
|
||||
ret = std::stoi(*line);
|
||||
|
||||
// Map the battery precent from [0, 90] to [0, 100].
|
||||
ret = ret * 100 / 90;
|
||||
ret = ret > 100 ? 100 : ret;
|
||||
delete line;
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user