diff --git a/install/acc.sh b/install/acc.sh index c83ec04..2674967 100644 --- a/install/acc.sh +++ b/install/acc.sh @@ -136,7 +136,9 @@ test_charging_switch() { chargingSwitch=($@) echo - echo "${chargingSwitch[@]}" + [ -n "${swCount-}" ] \ + && echo "$swCount/$swTotal: ${chargingSwitch[@]}" \ + || echo "${chargingSwitch[@]}" flip_sw off $blacklisted && { @@ -152,10 +154,16 @@ test_charging_switch() { if ! $failed && ! not_charging; then print_switch_works - echo " idleMode=$idleMode" + echo " battIdleMode=$idleMode" $idleMode && return 15 || return 0 else print_switch_fails + ! not_charging >/dev/null || { + print_resume + while not_charging; do #TODO + sleep 1 + done + } return 10 fi } @@ -523,11 +531,14 @@ case "${1-}" in exit fi } + swCount=1 + swTotal=$(wc -l ${1-$TMPDIR/ch-switches} | cut -d ' ' -f 1) while read _chargingSwitch; do echo "x$_chargingSwitch" | grep -Eq '^x$|^x#' && continue [ -f "$(echo "$_chargingSwitch" | cut -d ' ' -f 1)" ] && { { test_charging_switch $_chargingSwitch; echo $? > $TMPDIR/.exitCode; } \ | tee -a /sdcard/Download/acc-t_output-${device}.log + swCount=$((swCount + 1)) exitCode_=$(cat $TMPDIR/.exitCode) if [ -n "$parsed" ] && [ $exitCode_ -ne 10 ]; then grep -q "^$_chargingSwitch$" $_parsed 2>/dev/null \ @@ -551,6 +562,7 @@ case "${1-}" in esac print_acct_info + echo exit $exitCode ;; diff --git a/install/batt-info.sh b/install/batt-info.sh index 07851c4..3a42904 100644 --- a/install/batt-info.sh +++ b/install/batt-info.sh @@ -19,7 +19,7 @@ batt_info() { if [ -z "$factor" ]; then case $1 in 0) factor=1;; - *) [ $1 -le 15000 ] && factor=1000 || factor=1000000;; + *) [ $1 -lt 16000 ] && factor=1000 || factor=1000000;; esac fi } diff --git a/install/batt-interface.sh b/install/batt-interface.sh index 08dec28..5d9b68e 100644 --- a/install/batt-interface.sh +++ b/install/batt-interface.sh @@ -6,15 +6,13 @@ discharging() { idle() { - #grep -iq 'Not charging' $battStatus || { - [ $curThen != null ] && { - if $plusChgPolarity; then - [ $curNow -ge -$idleThresholdL ] && [ $curNow -le $idleThresholdH ] - else - [ $curNow -le $idleThresholdL ] && [ $curNow -ge -$idleThresholdH ] - fi - } || return 1 - #} + [ $curThen != null ] && { + if $_dischargePolarity; then + [ $curNow -ge -$idleThresholdL ] && [ $curNow -le $idleThresholdH ] + else + [ $curNow -le $idleThresholdL ] && [ $curNow -ge -$idleThresholdH ] + fi + } || return 1 _status=Idle } @@ -24,36 +22,34 @@ not_charging() { local i= local off=${flip-}; flip= local curThen=$(cat $curThen) - local plusChgPolarity=true - local seqCount=${seqCount:-16} ### + local seqCount=${seqCount:-16} + local battStatusOverride="${battStatusOverride-}" + local battStatusWorkaround=${battStatusWorkaround-} case "${dischargePolarity-}" in - +) plusChgPolarity=false;; - -) :;; - *) [ $curThen != null ] && [ $curThen -lt 0 ] && plusChgPolarity=false || :;; + +) _dischargePolarity=false;; + -) _dischargePolarity=true;; esac tt "${chargingSwitch[$*]-}" "*\ --" || battStatusOverride= - [ $currFile != $TMPDIR/.dummy-curr ] || battStatusWorkaround=false - if [ -z "${battStatusOverride-}" ] && [ -n "$off" ]; then - [ $off = off ] && off=true || off=false + if [ $currFile = $TMPDIR/.dummy-curr ] || [ -z "${_dischargePolarity-}" ]; then + battStatusWorkaround=false + fi + + if [ -z "${battStatusOverride-}" ] && [ "$off" = off ]; then for i in $(seq $seqCount); do - if $off; then - ! status ${1-} || return 0 - [ $i -lt 5 ] || { - if $plusChgPolarity; then - [ $(cat $currFile) -lt $((curThen / 100 * 90)) ] || return 1 - else - [ $(cat $currFile) -gt $((curThen / 100 * 90)) ] || return 1 - fi - } - else - status ${1-} || return 1 + ! status ${1-} || return 0 + if $battStatusWorkaround && [ $i -ge 5 ]; then + if $_dischargePolarity; then + [ $(cat $currFile) -lt $((curThen / 100 * 90)) ] || return 1 + else + [ $(cat $currFile) -gt $((curThen / 100 * 90)) ] || return 1 + fi fi [ $i = $seqCount ] || sleep 1 done - $off && return 1 || return 0 + return 1 else status ${1-} fi @@ -66,7 +62,7 @@ status() { local curNow=$(cat $currFile) _status=$(sed 's/Not charging/Idle/' $battStatus) - [ -z "${exitCode_-}" ] || echo " curr=$curThen,$curNow off=${off:-false} status=$_status" + [ -z "${exitCode_-}" ] || echo " curr:$curThen,$curNow switch:${off:-on} status:$_status" if [ -n "${battStatusOverride-}" ]; then if tt "$battStatusOverride" "Discharging|Idle"; then @@ -75,11 +71,9 @@ status() { _status=$(set -eu; eval '$battStatusOverride') || : fi elif $battStatusWorkaround; then - #idle || discharging || : - case $_status in - Charging) idle || discharging || :;; - Discharging) idle || :;; - esac + ! tt "$_status" "Charging|Discharging" || { + idle || discharging || : + } fi for i in Discharging DischargingDischarging Idle IdleIdle; do @@ -138,11 +132,18 @@ if ${init:-false}; then rm $curThen 2>/dev/null || : + case "$(cat $battStatus)$(cat $currFile)" in + Discharging-*|Charging[0-9]*) _dischargePolarity=true;; + Discharging[0-9]*|Charging-*) _dischargePolarity=false;; + esac + + echo " +_dischargePolarity=$_dischargePolarity ampFactor_=$ampFactor_ batt=$batt battCapacity=$batt/capacity -battStatus=\"$battStatus\" +battStatus=$battStatus currFile=$currFile curThen=$curThen idleThresholdL=$idleThresholdL diff --git a/install/misc-functions.sh b/install/misc-functions.sh index 3301e0c..2fc1ec6 100644 --- a/install/misc-functions.sh +++ b/install/misc-functions.sh @@ -270,16 +270,7 @@ flip_sw() { fi } - [ $flip = on ] || { - # cn=$(cat $currFile) - # ct=$(cat $curThen) - # case $ct in - # -*) [ $cn -lt $ct ] || ct=n;; - # [0-9]*) [ $cn -gt $ct ] || ct=n;; - # esac - # [ $ct = n ] || cat $currFile > $curThen - cat $currFile > $curThen - } + [ $flip = on ] || cat $currFile > $curThen write \$$flip $1 || return 1 diff --git a/install/strings.sh b/install/strings.sh index 78b6eb9..ed7916b 100644 --- a/install/strings.sh +++ b/install/strings.sh @@ -503,17 +503,17 @@ print_acct_info() { echo " 💡Notes/Tips: - - Some switches -- notably those that control current and voltage -- are prone to inconsistencies. If a switch works at least twice, assume it's functional. + Some switches -- notably those that control current and voltage -- are prone to inconsistencies. If a switch works at least twice, assume it's functional. - - Results may vary with different power supplies and conditions, as stated in \"readme > troubleshooting > charging switch\". + Results may vary with different power supplies and conditions, as stated in \"readme > troubleshooting > charging switch\". - - Want to test all potential switches? \"acc -t p\" parses them from the power supply log (as \"acc -p\"), tests all, and adds the working ones to the list of known switches. + Want to test all potential switches? \"acc -t p\" parses them from the power supply log (as \"acc -p\"), tests all, and adds the working ones to the list of known switches. - - To set charging switches, run acc -ss (wizard) or acc -s s=\"switches go here --\". + To set charging switches, run acc -ss (wizard) or acc -s s=\"switches go here --\". - - idleMode: whether the device can run directly off the charger. + battIdleMode: whether the device can run directly off the charger. - - The output of this command is saved to /sdcard/Download/acc-t_output-${device}.log." + The output of this command is saved to /sdcard/Download/acc-t_output-${device}.log." } @@ -523,3 +523,10 @@ Some problematic control files are blacklisted automatically, based on known pat Do you want to see/edit the list of potential switches before testing? a: abort operation | n: no | y: yes (default) " } + + +print_resume() { + echo " Waiting for charging to resume..." + echo " If it's not happening, try re-plugging the charger." + echo " In extreme cases, one shall comment out this switch in $dataDir/logs/write.log, reboot, and re-run the test." +} diff --git a/install/translations/tr/strings.sh b/install/translations/tr/strings.sh index d169942..817fc55 100644 --- a/install/translations/tr/strings.sh +++ b/install/translations/tr/strings.sh @@ -504,19 +504,19 @@ print_acct_info() { echo " 💡Notlar/Tavsiyeler: - - Bazı portlar -- özellikle akım ve voltaj kontrol edenlerde -- dengesizlikler kaçınılmaz. Eğer bir port en az iki kere çalıştıysa, iş gördüğünü + Bazı portlar -- özellikle akım ve voltaj kontrol edenlerde -- dengesizlikler kaçınılmaz. Eğer bir port en az iki kere çalıştıysa, iş gördüğünü varsayın. - - Sonuçlar farklı koşullara ve güç kaynaklarına göre değişebilir, \"readme > troubleshooting > charging switch\" kısmında da bahsedildiği gibi. + Sonuçlar farklı koşullara ve güç kaynaklarına göre değişebilir, \"readme > troubleshooting > charging switch\" kısmında da bahsedildiği gibi. - - Bütün portları test mi etmek istiyorsunuz? \"acc -t p\" güç kaynağı loglarından hepsini alıyor (as \"acc -p\"), test ediyor, ve çalışanları bilindik + Bütün portları test mi etmek istiyorsunuz? \"acc -t p\" güç kaynağı loglarından hepsini alıyor (as \"acc -p\"), test ediyor, ve çalışanları bilindik portlar listesine ekliyor. - - Şarj portlarını test etmek için, acc -ss (asistan) veya acc -s s=\"portlar buraya yazılıyor --\" kodlarını çalıştırın. + Şarj portlarını test etmek için, acc -ss (asistan) veya acc -s s=\"portlar buraya yazılıyor --\" kodlarını çalıştırın. - - idleMod: cihazın yalnızca şarjdan beslenerek çalışıp/çalışamayacağını ifade eder. + battIdleMode: cihazın yalnızca şarjdan beslenerek çalışıp/çalışamayacağını ifade eder. - - Bu komutun çıktısı /sdcard/Download/acc-t_output.txt dizinine kaydedilir." + Bu komutun çıktısı /sdcard/Download/acc-t_output.txt dizinine kaydedilir." }