3 if [ "$TMPFS" == "" ]; then
13 BATT_20MIN=$(( 0x3b )) # about 35-40 min
14 BATT_10MIN=$(( 0x3a ))
26 if i2cdetect -y 1 | grep " $devHEXNum " > /dev/null; then
28 i2cset -y 1 0x48 0x01 0x42E0 w
33 battHEX=$(i2cget -y 1 0x$devHEXNum 0x00 w)
35 batt=$(( 0x$(echo $battHEX | awk '{print substr($0,5)}') ))
37 echo "battery: $battHEX, $batt" | myLog
39 if [ "$batt" == "$prevBatt" ]; then battCnt=$(( $battCnt + 1 )); else battCnt=0; fi
43 echo "battCnt: $battCnt"
45 if [ "$battCnt" == "3" ]; then
50 # ------ compare -----------
52 if [ "$currentBat" -le "$BATT_20MIN" ] && [ "$currentBat" -gt "$BATT_10MIN" ] && [ "$battMessage" != "$BATTERY_20" ]; then
53 battMessage=$BATTERY_20
56 if [ "$currentBat" -le "$BATT_10MIN" ] && [ "$currentBat" -gt "$BATT_5MIN" ] && [ "$battMessage" != "$BATTERY_10" ]; then
57 battMessage=$BATTERY_10
60 if [ "$currentBat" -le "$BATT_5MIN" ] && [ "$currentBat" -gt "$BATT_0MIN" ] && [ "$battMessage" != "$BATTERY_5" ]; then
61 battMessage=$BATTERY_5
64 if [ "$currentBat" -le "$BATT_0MIN" ] && [ "$battMessage" != "$BATTERY_0" ]; then
65 battMessage=$BATTERY_0
66 shutdownDevice $BATTERY_SHUTDOWN_DELAY "$DEV_JINGLE" "$BATTERY_0"
69 # ------ send message ------
71 if [ "$prevBattMessage" != "$battMessage" ]; then
72 echo "battMessage: $battMessage" | myLog
74 echo "$DEV_JINGLE|$battMessage|$DEV_JINGLE_OUT" > $TMPFS/$message
76 prevBattMessage=$battMessage
83 echo "ADC module not detected" | myLog