]>
git.zerfleddert.de Git - fhem-stuff/blob - COC/init-coc
8 #BATTERY=0: trickle charger for supercap enabled
9 #BATTERY=1: trickle charger for supercap disabled
12 if [ "`id -u`" != "0" ]; then
13 exec sudo
"${0}" "${@}"
16 if [ "${BUS}" = "-1" ]; then
17 rev="0x`awk '{if ($1 == "Revision
") {print $NF};}' /proc/cpuinfo`"
19 if [ "${rev}" -ge "4" ]; then
20 echo "RPi version 2 detected"
23 echo "RPi version 1 detected"
28 if [ ! -e "/dev/i2c-${BUS}" ]; then
32 if [ ! -e "/sys/bus/i2c/devices/${BUS}-0068" ]; then
37 tchargertext
="enabling"
38 if [ "${BATTERY}" = "1" ]; then
40 tchargertext
="disabling"
43 if [ "`i2cget -y "${BUS}" 0x68 0x10`" != "${tcharger}" ]; then
44 echo "${tchargertext} trickle-charger for supercap"
45 i2cset
-y "${BUS}" 0x68 0x10 "${tcharger}"
47 echo "ds1339 0x68" >"/sys/class/i2c-adapter/i2c-${BUS}/new_device"
50 if [ ! -e "/sys/bus/i2c/devices/${BUS}-0018" ]; then
53 echo "ds2482 0x18" >"/sys/class/i2c-adapter/i2c-${BUS}/new_device"
56 echo "resetting 868MHz extension..."
57 if test ! -d /sys
/class
/gpio
/gpio17
; then echo 17 > /sys
/class
/gpio
/export; fi
58 if test ! -d /sys
/class
/gpio
/gpio18
; then echo 18 > /sys
/class
/gpio
/export; fi
59 echo out
> /sys
/class
/gpio
/gpio17
/direction
60 echo out
> /sys
/class
/gpio
/gpio18
/direction
61 echo 1 > /sys
/class
/gpio
/gpio18
/value
62 echo 0 > /sys
/class
/gpio
/gpio17
/value
64 echo 1 > /sys
/class
/gpio
/gpio17
/value