Skip to content

Commit 724482b

Browse files
committed
* Map the battery precent from [0, 90] to [0, 100].
1 parent 257f206 commit 724482b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

components/ext_devs/ext_dev/src/maix_pmu.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ int PMU::get_bat_percent()
124124
auto f = fs::File("/sys/class/power_supply/cw2015-battery/capacity", "r");
125125
auto line = f.readline();
126126
ret = std::stoi(*line);
127+
128+
// Map the battery precent from [0, 90] to [0, 100].
129+
ret = ret * 100 / 90;
130+
ret = ret > 100 ? 100 : ret;
127131
delete line;
128132
}
129133
return ret;

0 commit comments

Comments
 (0)