Skip to content

Commit

Permalink
Fix & optimize cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
VR-25 committed Jul 20, 2022
1 parent 66fc662 commit 6cf01cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ tempLevel=0
# cooldownRatio=(cooldown_charge cooldown_pause) SECONDS,NULLABLE
# cooldownCustom=cooldown_custom=(FILE RAW_VALUE CHARGE_SECONDS PAUSE_SECONDS) NULLABLE
# cooldownCustom=cooldown_custom=(FILE THRESHOLD CHARGE_SECONDS PAUSE_SECONDS) NULLABLE
# cooldownCurrent=cooldown_current=MILLIAMPS NULLABLE
Expand Down Expand Up @@ -987,7 +987,7 @@ Most of the lines are either unnecessary (e.g., type: everyone knows that alread

Here's what one should focus on:

BATT_HEALTH=92.00% # Estimated battery health, based on data provided by the kernel (not available on all systems)
HEALTH=Good # Battery health
CAPACITY=50 # Battery level, 0-100
CURRENT_NOW=0 # Charging current (Amps)
POWER_NOW=0 # (CURRENT_NOW * VOLTAGE_NOW) (Watts)
Expand Down
25 changes: 12 additions & 13 deletions install/accd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,26 @@ if ! $init; then
fi

# cooldown cycle
while [ -n "${cooldownRatio[0]-}${cooldownCustom[0]-}" ] \
while [ -n "${cooldownCurrent-}${cooldownRatio[0]-}${cooldownCustom[0]-}" ] \
&& _lt_pause_cap && is_charging
do
$[ $(sed s/-// ${cooldownCustom[0]:-cooldownCustom} 2>/dev/null || echo 0) -ge ${cooldownCustom[1]:-1} ] \
&& cooldownCustom_=true \
|| cooldownCustom_=false
if [ $(cat $temp) -ge $(( ${temperature[0]} * 10 )) ] \
|| _ge_cooldown_cap \
|| [ $(sed s/-// ${cooldownCustom[0]:-cooldownCustom} 2>/dev/null || echo 0) -ge ${cooldownCustom[1]:-1} ]
|| $cooldownCustom_
then
cooldown=true
if [ -n "${cooldownCurrent-}" ] && grep -q / $TMPDIR/ch-curr-ctrl-files 2>/dev/null; then
# cooldown by limiting current
maxChargingCurrent0=${maxChargingCurrent[0]-}
set_ch_curr ${cooldownCurrent:-500} || :
sleep ${cooldownRatio[1]:-1}
sleep ${cooldownRatio[1]:-${loopDelay[1]}}
[ ${cooldownRatio[0]:-0} -eq 0 ] || {
set_ch_curr ${maxChargingCurrent0:--} || :
count=0
while [ $count -lt ${cooldownRatio[0]:-1} ]; do
while [ $count -lt ${cooldownRatio[0]:-${loopDelay[0]}} ]; do
sleep ${loopDelay[0]}
_lt_pause_cap && count=$(( count + ${loopDelay[0]} )) || break
done
Expand All @@ -277,19 +280,15 @@ if ! $init; then
# regular cooldown
cmd_batt set status $chgStatusCode
disable_charging
[ $(sed s/-// ${cooldownCustom[0]:-cooldownCustom} 2>/dev/null || echo 0) -ge ${cooldownCustom[1]:-1} ] \
&& sleep ${cooldownCustom[3]:-1} \
|| sleep ${cooldownRatio[1]:-1}
$cooldownCustom_ && sleep ${cooldownCustom[3]:-${loopDelay[1]}} \
|| sleep ${cooldownRatio[1]:-${loopDelay[1]}}
enable_charging
$capacitySync || cmd_batt reset
[ ! $(sed s/-// ${cooldownCustom[0]:-cooldownCustom} 2>/dev/null || echo 0) -ge ${cooldownCustom[1]:-1} ] \
|| cooldownRatio[0]=${cooldownCustom[2]-}
! $cooldownCustom_ || cooldownRatio[0]=${cooldownCustom[2]:-${loopDelay[0]}}
count=0
while ! not_charging && [ $count -lt ${cooldownRatio[0]:-1} ]; do
while [ $count -lt ${cooldownRatio[0]:-${loopDelay[0]}} ]; do
sleep ${loopDelay[0]}
_lt_pause_cap \
&& count=$(( count + ${loopDelay[0]} )) \
|| break
_lt_pause_cap && count=$(( count + ${loopDelay[0]} )) || break
done
fi
else
Expand Down
2 changes: 1 addition & 1 deletion install/default-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ tempLevel=0

# cooldownRatio=(cooldown_charge cooldown_pause) SECONDS,NULLABLE

# cooldownCustom=cooldown_custom=(FILE RAW_VALUE CHARGE_SECONDS PAUSE_SECONDS) NULLABLE
# cooldownCustom=cooldown_custom=(FILE THRESHOLD CHARGE_SECONDS PAUSE_SECONDS) NULLABLE

# cooldownCurrent=cooldown_current=MILLIAMPS NULLABLE

Expand Down

0 comments on commit 6cf01cd

Please sign in to comment.