User:Kerio/calibratebq27200


 * 1) !/bin/sh

CHARGER_MODE="/sys/class/power_supply/bq24150a-0/mode"

if ! test -w ${CHARGER_MODE} || ! cd /sys/class/power_supply/bq27200-0 ; then echo "NOPE.jpg" >&2 exit 1 fi

vdq { return $(( 1 - ( ( $( grep 0x0a= registers | cut -d= -f2 ) & 4 ) / 4 ) )) }
 * 1) returns success if VDQ is set, otherwise returns fail

edv1 { return $(( 1 - ( ( $( grep 0x0a= registers | cut -d= -f2 ) & 2 ) / 2 ) )) }
 * 1) returns success if EDV1 is set, otherwise returns fail

lock_screen { /usr/bin/dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"locked" }
 * 1) lock the screen, as if the user pushed the lock slider
 * 2) taken from Phone_control

print_info { echo -n "$(( $( cat capacity ) ))%  " echo -n "VOLT: $(( $( cat voltage_now ) / 1000 )) mV  " echo "CUR: $(( $( cat current_now ) / 1000 )) mA" }

if ! vdq ; then echo "Waiting for VDQ, connect the charger."

while ! vdq ; do       print_info sleep 10 done fi

echo "VDQ set, stopping charging and waiting for EDV1." echo off > ${CHARGER_MODE}

while ! edv1 ; do   print_info sleep 10 done

echo "EDV1 set, restarting charging." echo auto > ${CHARGER_MODE}

lock_screen