- Добавлен процесс для чтения iio-датчиков
[weathermon.git] / bin / weather-init
diff --git a/bin/weather-init b/bin/weather-init
new file mode 100755 (executable)
index 0000000..d009c67
--- /dev/null
@@ -0,0 +1,33 @@
+# Put your custom commands here that should be executed once
+# the system init finished. By default this file does nothing.
+
+I2C_BUS=0
+DS3221=68
+
+echo heartbeat > /sys/class/leds/linkit-smart-7688:orange\:wifi/trigger
+
+if [ ! -e /dev/lcdi2c ]; then
+  insmod lcdi2c busno=0 address=0x27 cursor=0 blink=0 topo=1
+fi
+
+echo 1 > /sys/class/alphalcd/lcdi2c/clear 
+echo \00\00 > /sys/class/alphalcd/lcdi2c/position
+
+if [ ! -e /dev/rtc0 ]; then
+
+  modprobe rtc-ds1307
+  echo ds1307 0x$DS3221 > /sys/class/i2c-dev/i2c-$I2C_BUS/device/new_device
+  sleep 1
+  if [ -e /dev/rtc0 ]; then
+    ln -sf /dev/rtc0 /dev/rtc
+    logger -t hardware RTC initialized
+  fi  
+
+fi
+
+if [ -e /dev/rtc0 ]; then
+  /sbin/hwclock -u --rtc=/dev/rtc0 --hctosys
+  echo "Hardware RTC OK" > /dev/lcdi2c
+else
+  echo "Hardware RTC FAIL" > /dev/lcdi2c
+fi