answered
2015-03-05 15:11:48 +0200
Hei,
Update for SailfishX
I was afraid this hack won't work on SailfishX. But, hey! SailfishX has a better way to do it:
/sys/class/power_supply/battery/baterry_charge_enable
If '0' is written in it, battery charging stops immediately. And the discharging is way less than JP1301 had. I believe, in that case, the external power supply was logically cut and the phone went on battery only. But this in case, USB power supply is used and the battery is only there for buffering.
I just wanted to share my experiences.
/Update for SailfishX
I refined my method over time. I am leaving the original script as well, but I am posting the way I currently use it.
Here it goes:
I created two short scripts, one for starting, one for stopping charging.
All the timeing and battery checking is done by Situations App via the script 'What'.
I figured that this leaves the least amount of over-head.
Situations created:
'Start charging':
'When': Accessory = Charger && Battery !> 70% remaining
'What': Command: /the/path/to/charging_start.sh
'Stop charging':
'When': Accessory = Charger && Battery !< 80% remaining
'What': Command = /the/path/to/charging_stop.sh
'Charging':
'When': Accessory = Charger
'What': Command (at end) = /the/path/to/charging_start.sh
Contents of 'charging_start.sh':
#!/bin/sh
# We need to take control over this, every time after reboot.
chmod 777 /sys/class/power_supply/usb/charger_disable
# Set it to allow charging.
echo 0 > /sys/class/power_supply/usb/charger_disable
Contents of 'charging_stop.sh':
#!/bin/sh
# We need to take control over this, every time after reboot.
chmod 777 /sys/class/power_supply/usb/charger_disable
# Set it to stop charging.
echo 1 > /sys/class/power_supply/usb/charger_disable
Start of the original post:
I managed to patch together a shell script that handles the charging on the Jolla phone.
It limits charging at around 80% of SoC and (if charger was not disconnected) starts charging at around 40% of SoC.
To make full use of it, I installed Situations
app from Jolla Store
and created a situation that is triggered when charger accessory is connected and runs my script.
The contents of charging_control.sh
script:
#!/bin/sh
# We need to take control over this, every time after reboot.
chmod 777 /sys/class/power_supply/usb/charger_disable
# Set it to allow charging.
echo 0 > /sys/class/power_supply/usb/charger_disable
#Set the variables.
soc=$(cat /sys/class/power_supply/battery/energy_now)
present=$(cat /sys/class/power_supply/usb/present)
state=$(cat /sys/class/power_supply/usb/charger_disable)
#Start the loop and keep cycling while the charger is present.
while (($present > 0))
do
present=$(cat /sys/class/power_supply/usb/present)
soc=$(cat /sys/class/power_supply/battery/energy_now)
#If SoC is over around 80%, charging is disabled.
if (($soc > 5400000 && $state == 0)); then
echo 1 > /sys/class/power_supply/usb/charger_disable
state=1
fi
#If the SoC drops below around 40% and the charger is still connected, charging is enabled.
if (($soc < 2500000 && $state == 1)); then
echo 0 > /sys/class/power_supply/usb/charger_disable
state=0
fi
#Sleep for a while before re-checking the situations.
sleep 120
done
#Re-enable charging when the charger is removed. Preparing for the next time.
if (($present < 1)); then
echo 0 > /sys/class/power_supply/usb/charger_disable
fi
The contents of the charging_control.desktop
file:
[Desktop Entry]
Type=Application
Name=Charging Control
#The location of my script:
Exec=/home/nemo/.scripts/charging_control.sh
Icon=icon-l-terminal
The .desktop file can be put into any of the two folders:
/home/nemo/.local/share/applications
/usr/share/applications
Limitations:
With Situations
app (by Pastilli Labs) currently only the second location works.
The script can only be run as root.
Disclaimer: As always, proceed at your own risk. I will be sorry if you happen to brick you device, but it won't be my fault. This script is working for me, though.
I know that this script is not at all professional. It might have limitations or defects. If you notice one, please let me know, so I can update my post.
PS.: If somebody feels to create a daemon out of the above, please do it. But send me a copy.
LVPVS out.
I found web site, which seems to have valid information about the charging and cylic usage of the lithium battery.
http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries
Kari ( 2014-09-13 09:56:11 +0200 )editI closed my question as a duplicate of this; however, I would like to get answers for these questions:
I would like my Jolla to stop charging the battery at some percentage of the full charge. Let's say it be 80%.
First question: Does Jolla stop charging the phone when at 100%?
Second question: Is there a way to limit it by setting 80% as the "Designed Maximum" Voltage by modifying data in here:
/sys/class/power_supply/battery/
?Third question: If not here, where can I change it? 8D
LVPVS ( 2014-10-14 13:55:45 +0200 )editequally so we would like a power save mode, like N9 has, that will automatically turn off power consuming operations when the battery level drops e.g. 30%
pmelas ( 2014-10-14 14:06:05 +0200 )edit