Skip to content

Commit

Permalink
Add support for cooldown_charge=0 (to be used with cooldown_current)
Browse files Browse the repository at this point in the history
  • Loading branch information
VR-25 committed Jul 18, 2022
1 parent 6286223 commit deb4736
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ In interactive mode, it also asks the user whether they want to download and ins
```
#DC#
configVerCode=202207170
configVerCode=202207180
capacity=(-1 60 70 75 false false)
Expand Down Expand Up @@ -423,7 +423,7 @@ tempLevel=0
# cooldown_capacity (cc) #
# Capacity/voltage_now_millivolts at which the cooldown cycle starts.
# Cooldown reduces battery stress induced by prolonged exposure to high temperature and high charging voltage.
# It does so through periodically pausing charging for a few seconds (more details below).
# It does so through periodically pausing charging for a few seconds (cooldown_pause, more details below).
# resume_capacity (rc) #
# Capacity or voltage_now_millivolts at which charging should resume.
Expand Down Expand Up @@ -471,7 +471,8 @@ tempLevel=0
# It takes precedence over the regular cooldown settings.
# cooldown_current (cdc) #
# Instead of pausing charging periodically during the cooldown phase, limit the max charging current (e.g., to 500 mA)
# Instead of pausing charging for cooldown_pause seconds, limit the max charging current (e.g., to 500 mA).
# cooldown_charge can be 0.
# reset_batt_stats_on_pause (rbsp) #
# Reset battery stats after pausing charging.
Expand Down
30 changes: 12 additions & 18 deletions install/accd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,33 +253,26 @@ if ! $init; then

# cooldown cycle
while [ -n "${cooldownRatio[0]-}${cooldownCustom[0]-}" ] \
&& _lt_pause_cap \
&& is_charging
&& _lt_pause_cap && is_charging
do
if [ $(cat $temp) -ge $(( ${temperature[0]} * 10 )) ] \
|| _ge_cooldown_cap \
|| [ $(sed s/-// ${cooldownCustom[0]:-cooldownCustom} 2>/dev/null || echo 0) -ge ${cooldownCustom[1]:-1} ]
then
cooldown=true
if [ -n "${cooldownCurrent-}" ] && grep -q / $TMPDIR/ch-curr-ctrl-files 2>/dev/null
then
if [ -n "${cooldownCurrent-}" ] && grep -q / $TMPDIR/ch-curr-ctrl-files 2>/dev/null; then
# cooldown by limiting current
cmd_batt set status $chgStatusCode # to prevent unwanted display wakeups
set +e
maxChargingCurrent0=${maxChargingCurrent[0]-}
set_ch_curr ${cooldownCurrent:-0}
set_ch_curr ${cooldownCurrent:-500} || :
sleep ${cooldownRatio[1]:-1}
set_ch_curr ${maxChargingCurrent0:--}
set -e
$capacitySync || cmd_batt reset
count=0
while [ $count -lt ${cooldownRatio[0]:-1} ]
do
sleep ${loopDelay[0]}
_lt_pause_cap \
&& count=$(( count + ${loopDelay[0]} )) \
|| break
done
[ ${cooldownRatio[0]:-0} -eq 0 ] || {
set_ch_curr ${maxChargingCurrent0:--} || :
count=0
while [ $count -lt ${cooldownRatio[0]:-1} ]; do
sleep ${loopDelay[0]}
_lt_pause_cap && count=$(( count + ${loopDelay[0]} )) || break
done
}
else
# regular cooldown
cmd_batt set status $chgStatusCode
Expand All @@ -304,6 +297,7 @@ if ! $init; then
fi
done

$cooldown && set_ch_curr ${maxChargingCurrent0:--} || :
cooldown=false
sleep ${loopDelay[0]}

Expand Down
9 changes: 5 additions & 4 deletions install/default-config.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configVerCode=202207170
configVerCode=202207180

capacity=(-1 60 70 75 false false)

Expand Down Expand Up @@ -178,13 +178,13 @@ tempLevel=0
# This is checked during updates to determine whether config should be patched. Do NOT modify.

# shutdown_capacity (sc) #
# When the battery is discharging and its capacity/voltage_now_millivolts <= sc and phone has been running for 15 minutes or more, acc daemon turns the phone off to reduce the discharge rate and protect the battery from potential damage induced by voltage below the operating range.
# When the battery is discharging and its capacity/voltage_now_millivolts <= sc and device has been running for 15 minutes or more, acc daemon turns the device off to reduce the discharge rate and protect the battery from potential damage induced by voltage below the operating range.
# sc=-1 disables it.

# cooldown_capacity (cc) #
# Capacity/voltage_now_millivolts at which the cooldown cycle starts.
# Cooldown reduces battery stress induced by prolonged exposure to high temperature and high charging voltage.
# It does so through periodically pausing charging for a few seconds (more details below).
# It does so through periodically pausing charging for a few seconds (cooldown_pause, more details below).

# resume_capacity (rc) #
# Capacity or voltage_now_millivolts at which charging should resume.
Expand Down Expand Up @@ -232,7 +232,8 @@ tempLevel=0
# It takes precedence over the regular cooldown settings.

# cooldown_current (cdc) #
# Instead of pausing charging periodically during the cooldown phase, limit the max charging current (e.g., to 500 mA)
# Instead of pausing charging for cooldown_pause seconds, limit the max charging current (e.g., to 500 mA).
# cooldown_charge can be 0.

# reset_batt_stats_on_pause (rbsp) #
# Reset battery stats after pausing charging.
Expand Down

0 comments on commit deb4736

Please sign in to comment.