Alter 4 files
Update `drawing.go` Add `install.sh` Add `life-dashboard-init` Add `start.sh`
This commit is contained in:
parent
e988d0b978
commit
322b5d5d55
4 changed files with 99 additions and 1 deletions
|
@ -257,7 +257,7 @@ func drawTrains(ctx *canvas.Context, startFrom float64, location string, service
|
|||
titleBaseline := startFrom + (bounds.H * 2) + 5
|
||||
|
||||
if len(services) == 0 {
|
||||
services = []string{"*** No services in the next 30 mins ***"}
|
||||
services = []string{"* * * No services in the next 60 mins * * *"}
|
||||
}
|
||||
|
||||
var lh float64
|
||||
|
|
16
on-device/install.sh
Normal file
16
on-device/install.sh
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
ssh kindle "/usr/sbin/mntroot rw"
|
||||
|
||||
scp start.sh kindle:/start.sh
|
||||
scp life-dashboard-init kindle:/etc/init.d/life-dashboard-init
|
||||
|
||||
ssh kindle << EOF
|
||||
cd /
|
||||
chmod 777 start.sh
|
||||
chmod 777 /etc/init.d/life-dashboard-init
|
||||
|
||||
echo "Install complete, start script with: `/etc/init.d/life-dashboard-init start` and let it run till the ssh session hangs"
|
||||
EOF
|
15
on-device/life-dashboard-init
Normal file
15
on-device/life-dashboard-init
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
. /start.sh &
|
||||
;;
|
||||
stop)
|
||||
echo "I can't let you do that (just restart)"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/life-dashboard-init {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit 0
|
67
on-device/start.sh
Normal file
67
on-device/start.sh
Normal file
|
@ -0,0 +1,67 @@
|
|||
#!/bin/sh
|
||||
# Run via /etc/init.d/life-dashboard-init start
|
||||
|
||||
enable_wifi() {
|
||||
lipc-set-prop com.lab126.cmd wirelessEnable 1
|
||||
while ! lipc-get-prop com.lab126.wifid cmState | grep -q CONNECTED; do sleep 1; done
|
||||
}
|
||||
disable_wifi() { lipc-set-prop com.lab126.cmd wirelessEnable 0; }
|
||||
|
||||
cd /
|
||||
/usr/sbin/mntroot rw
|
||||
|
||||
echo "Setting up low power usage"
|
||||
/etc/init.d/framework stop
|
||||
echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||
lipc-set-prop com.lab126.powerd preventScreenSaver 1
|
||||
|
||||
eips -c 12 19 "Starting polling / sleep" && eips 15 20 "Beginning in 30 seconds."
|
||||
sleep 30
|
||||
|
||||
FILE="/kindle-dashboard.png"
|
||||
echo -n "" > /last-etag
|
||||
|
||||
while true; do
|
||||
echo "enabling wifi"
|
||||
enable_wifi
|
||||
echo "requesting image"
|
||||
|
||||
/usr/sbin/eips 0 39 "refreshing... "
|
||||
|
||||
RESP=$(/neocurl -s -H "If-None-Match: $(cat /last-etag)" -o $FILE -w '%{http_code} %header{etag}' 'http://kindle.platform.tdpain.net/image')
|
||||
STATUS=$(echo $RESP | awk '{print $1}')
|
||||
echo "Status is $STATUS"
|
||||
ETAG=$(echo $RESP | awk '{print $2}')
|
||||
echo "ETag header is $ETAG"
|
||||
|
||||
if [ "$STATUS" = "200" ] ; then
|
||||
echo "image downloaded"
|
||||
/usr/sbin/eips -c
|
||||
/bin/fbink -g file=$FILE
|
||||
echo -n "$ETAG" > /last-etag
|
||||
elif [ "$STATUS" = "304" ] ; then
|
||||
echo "no change"
|
||||
else
|
||||
/bin/fbink -pmM -y -8 "Endpoint request failed, exiting"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "disabling wifi"
|
||||
disable_wifi
|
||||
|
||||
echo "writing stats"
|
||||
|
||||
let MAX_SLEEP=10*60
|
||||
BATTERY_LEVEL=$(lipc-get-prop com.lab126.powerd battLevel)
|
||||
|
||||
let NEXT_REFRESH=$(($(date -d 23:59:59 +%s) - $(date +%s))) # seconds till midnight
|
||||
if [ $NEXT_REFRESH -le 0 ] || [ $NEXT_REFRESH -ge $MAX_SLEEP ] ; then NEXT_REFRESH=$MAX_SLEEP; fi
|
||||
|
||||
let NEXT_REFRESH_minutes=$NEXT_REFRESH/60
|
||||
/usr/sbin/eips 0 39 "r.$(date '+%F %H:%M') n.$NEXT_REFRESH_minutes b.$BATTERY_LEVEL"
|
||||
|
||||
echo "entering rtc sleep"
|
||||
sleep 5
|
||||
echo $NEXT_REFRESH > /sys/devices/platform/mxc_rtc.0/wakeup_enable
|
||||
echo "mem" > /sys/power/state
|
||||
done
|
Reference in a new issue