perf: Adjust battery capacity readings for differnt batteries

This commit is contained in:
robshape 2023-04-23 14:36:58 +02:00
parent 2c9d7642ae
commit 77957493ca
4 changed files with 34 additions and 18 deletions

View file

@ -39,6 +39,7 @@ You can [grab the latest version here](https://github.com/shauninman/union-minui
- Add to Favorites
- Clear Recently Played
- Adjusted battery readings for 2100, 2600 and 3500 mAh batteries
- All extras included in default installation
- Improved developer onboarding
@ -121,13 +122,13 @@ Run `./start-toolchain.sh` and then `make all` in the Docker container shell.
- ~~Add Clear Recent setting~~
- ~~Refactor Tools to Settings~~
- ~~Add to Favorites~~
- Improve battery capacity readings (2100 mAh, 2600 mAh, 3500 mAh)
- Adjust overclocking and CPU usage (to maximize battery life)
- Update Installation instructions for microSD cards of all sizes
- ~~Adjust battery capacity readings (2100 mAh, 2600 mAh, 3500 mAh)~~
- Automate installation and update
- Update visible MinUI strings and boot logo (show that it is the FinUI fork)
- Release using GitHub Actions
- [...Things in the old todo?...](./todo.txt)
- Adjust overclocking and CPU usage (to maximize battery life)
- Improve battery capacity reading accuracy
- [...things in the old todo?...](./todo.txt)
## Disclaimer
@ -140,4 +141,4 @@ Use at your own risk.
## Contributors
robshape, guiburi
@robshape @guiburi

View file

@ -39,7 +39,7 @@ cd $(dirname "$0")
#######################################
keymon.elf & # &> $LOGS_PATH/keymon.txt &
./batmon.sh &> /mnt/sdcard/batmon.txt &
# ./batmon.sh &> /mnt/sdcard/batmon.txt &
#######################################

View file

@ -1388,21 +1388,35 @@ static void POW_quitOverlay(void) {
ioctl(gfx.fd_fb, OWLFB_OVERLAY_DISABLE, &pow.oargs);
}
static int POW_readBatteryStatus(void) {
#define BATTERY_2100MAH 1
#define BATTERY_2600MAH 2
#define BATTERY_3500MAH 3
int battery = BATTERY_2600MAH; // Default
int battery_txt = getInt(BATTERY_PATH);
if (battery_txt > 0) {
battery = battery_txt;
}
int voltage_now = getInt("/sys/class/power_supply/battery/voltage_now");
if (battery == BATTERY_2100MAH) {
return ((voltage_now / 10000) - 310); // 310-410
} else if (battery == BATTERY_2600MAH) {
return ((voltage_now / 10000) - 308); // 308-413? Seems incorrect...
} else if (battery == BATTERY_3500MAH) {
// ???-???
}
// Fallback
return getInt("/sys/class/power_supply/battery/capacity");
}
static void POW_updateBatteryStatus(void) {
pow.is_charging = getInt("/sys/class/power_supply/battery/charger_online");
// TODO: newer batteries have a different range, ???-???
// int i = getInt("/sys/class/power_supply/battery/voltage_now") / 10000; // 310-410
// i -= 310; // ~0-100
// Battery ramp is wrong for bigger batteries. Need to log drain for 2600 mAh, 3500 mAh, and
// update range. Reading /capacity seems more accurate for 2600 mAh.
int i = getInt("/sys/class/power_supply/battery/capacity");
if (i == 0) { // Initial reading is incorrect...
pow.charge = 100;
return;
}
int i = POW_readBatteryStatus();
// worry less about battery and more about the game you're playing
if (i>80) pow.charge = 100;

View file

@ -59,6 +59,7 @@
#define FAVORITE_PATH USERDATA_PATH "/.minui/favorite.txt"
#define FAUX_FAVORITE_PATH SDCARD_PATH "/Favorites"
#define COLLECTIONS_PATH SDCARD_PATH "/Collections"
#define BATTERY_PATH SDCARD_PATH "/battery.txt"
#define LAST_PATH "/tmp/last.txt" // transient
#define CHANGE_DISC_PATH "/tmp/change_disc.txt"