08-28-2024, 03:19 PM | #1396 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2024
Device: Kobo Libra Colour
|
Quote:
|
|
08-28-2024, 07:30 PM | #1397 |
Wizard
Posts: 1,333
Karma: 16297052
Join Date: Sep 2022
Device: Kobo Libra 2
|
I've made another update to my battery statistics calculation script. Version 1.2 brings a few improvements:
I had hoped to use bc to do proper floating-point arithmetic, but it seems that Kobo's version of BusyBox doesn't have it, so instead I've resorted to manipulating v_now, v_min, and v_max as strings, which avoids doing any actual arithmetic for the units conversion. Remember that if you have the Libra Colour, you must replace: /sys/class/power_supply/battery/ with /sys/class/power_supply/bd71827_bat/ in order for the script to work. Other Kobo models may require greater changes, as some statistics may not be available. Code:
# Battery Statistics Calculator 1.2 (2024-08-28) by Aleron Ives # # This script calculates battery statistics for the Kobo Libra 2. # Check the contents of /sys/class/power_supply/ if you use a different # model to ensure that the statistics you want to track are available. # # You can use NickelMenu to invoke this script like so: # menu_item :main :Battery :cmd_output :500 :/mnt/onboard/.adds/battcalc.sh # Gather the necessary statistics meter=$(cat /sys/class/power_supply/battery/capacity) v_now=$(cat /sys/class/power_supply/battery/voltage_now) v_min=$(cat /sys/class/power_supply/battery/voltage_min) v_max=$(cat /sys/class/power_supply/battery/voltage_max) c_now=$(cat /sys/class/power_supply/battery/charge_now) c_full=$(cat /sys/class/power_supply/battery/charge_full) c_dfull=$(cat /sys/class/power_supply/battery/charge_full_design) # Format the statistics let c_now/=1000; let c_full/=1000; let c_dfull/=1000 # Convert to mAh let charge=$c_now*100/$c_full # Calculate charge percentage from mAh let c_health=$c_full*100/$c_dfull # Calculate health percentage from mAh let v_div=$v_max-$v_min; let v_div/=100 # Calculate charge percentage from V let v_pct=$v_max-$v_now; let v_pct/=$v_div # " let v_pct=100-$v_pct # " v_nowr=$(echo $v_now | cut -b 2-4) # Simulate floating-point arithmetic v_now=$(echo $v_now | cut -b 1) # " v_minr=$(echo $v_min | cut -b 2-3) # " v_min=$(echo $v_min | cut -b 1) # " v_maxr=$(echo $v_max | cut -b 2-3) # " v_max=$(echo $v_max | cut -b 1) # " # Display the results echo Capacity: $c_now mAh / $charge% / $meter% echo Voltage: $v_min.$v_minr V / $v_now.$v_nowr V / $v_max.$v_maxr V / $v_pct% echo Health: $c_full mAh / $c_dfull mAh / $c_health% Last edited by Aleron Ives; 08-28-2024 at 07:40 PM. |
Yesterday, 08:17 AM | #1398 |
Member
Posts: 18
Karma: 10
Join Date: Sep 2018
Device: Libra 2
|
|
Tags |
kobo, launcher, ldpreload, nickel |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kobo eReaders and Heat | PeterT | Kobo Reader | 13 | 08-02-2014 04:35 AM |
kobo arc launcher not working | lana loves books | Kobo Tablets | 8 | 03-21-2014 06:40 AM |
Orginization on kobo ereaders | crochetgeek2010 | Kobo Reader | 7 | 09-03-2013 02:13 PM |
Kobo Announces eReaders Available for Purchase on Kobo.com in Canada and US | markemark | News | 1 | 04-02-2013 01:46 PM |
Ereaders with Integrated Dictionary | poohbear_nc | Which one should I buy? | 4 | 04-08-2010 06:42 AM |