sooperior Posted November 13, 2016 Share Posted November 13, 2016 Hi I have a suggestion to modify update-mot.d script 30-sysinfo. It reports battery chargin or not depending on percentage (if <100% then is charging): # Battery info for Allwinner # kernel 4.4+ axp_dir="/sys/power/axp_pmu" if [[ -e "$axp_dir" ]]; then status_battery_connected=$(cat $axp_dir/battery/connected) if [[ "$status_battery_connected" == "1" ]]; then status_battery_charging=$(cat $axp_dir/charger/charging) status_ac_connect=$(cat $axp_dir/ac/connected) battery_percent=$(cat $axp_dir/battery/capacity) # dispay charging / percentage if [[ "$status_ac_connect" == "1" && "$battery_percent" -lt "100" ]]; then status_battery_text=" charging" elif [[ "$status_ac_connect" == "1" && "$battery_percent" -eq "100" ]]; then status_battery_text=" charged" else status_battery_text=" discharging" fi fi fi However, at least on banana pi M1 (A20) it can be below 100% and not charging, Seems that the PMU doesn't charge just for 1-2%. So we can just use driver info to check if it is really charging, like this: # Battery info for Allwinner kernel 4.4+ axp_dir="/sys/power/axp_pmu" if [[ -e "$axp_dir" ]]; then status_battery_connected=$(cat $axp_dir/battery/connected) if [[ "$status_battery_connected" == "1" ]]; then status_battery_charging=$(cat $axp_dir/charger/charging) status_ac_connect=$(cat $axp_dir/ac/connected) battery_percent=$(cat $axp_dir/battery/capacity) # dispay charging / percentage if [[ "$status_ac_connect" == "1" && "$status_battery_charging" == "1" ]]; then status_battery_text=" charging" elif [[ "$status_ac_connect" == "1" && "$status_battery_charging" == "0" ]]; then status_battery_text=" charged" else status_battery_text=" discharging" fi fi fi Hope someone else finds it useful 1 Link to comment Share on other sites More sharing options...
PaceyIV Posted November 14, 2016 Share Posted November 14, 2016 Thanks. This thing was in my todo list. Link to comment Share on other sites More sharing options...
Igor Posted November 14, 2016 Share Posted November 14, 2016 Hmm, I have: status_battery_charging = 0 ... charging or not, on Linux lime2 4.8.7-sunxi. Link to comment Share on other sites More sharing options...
PaceyIV Posted November 14, 2016 Share Posted November 14, 2016 According to the template of rpimonitor that I found at this forum in some topic we have to check this if (/sys/power/axp_pmu/battery/amperage > 0) "Battery Discharging" else if (/sys/power/axp_pmu/battery/charging == 1) "Battery Charging" else "Battery Charged" This works at every combination of power source - Board powered through battery only - Board powered through DC-IN - Board powered through USB OTG # Battery info for Allwinner # kernel 4.4+ axp_dir="/sys/power/axp_pmu" if [[ -e "$axp_dir" ]]; then status_battery_connected=$(cat $axp_dir/battery/connected) if [[ "$status_battery_connected" == "1" ]]; then battery_current=$(cat $axp_dir/battery/amperage) status_battery_charging=$(cat $axp_dir/charger/charging) status_battery_charge=$(cat $axp_dir/battery/charge) battery_percent=$(cat $axp_dir/battery/capacity) # dispay charging / percentage if [[ "$battery_current" -gt "0" ]]; then status_battery_text=" discharging" elif [[ "$status_battery_charging" -eq "1" ]]; then status_battery_text=" charging" else status_battery_text=" charged" fi fi fi I've tested it with 4.8.4-sunxi Link to comment Share on other sites More sharing options...
Recommended Posts