diff --git a/imagegen/drawing.go b/imagegen/drawing.go index a0e152e..c1a5b88 100644 --- a/imagegen/drawing.go +++ b/imagegen/drawing.go @@ -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 diff --git a/on-device/install.sh b/on-device/install.sh new file mode 100644 index 0000000..40fdf57 --- /dev/null +++ b/on-device/install.sh @@ -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 diff --git a/on-device/life-dashboard-init b/on-device/life-dashboard-init new file mode 100644 index 0000000..eab182e --- /dev/null +++ b/on-device/life-dashboard-init @@ -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 diff --git a/on-device/start.sh b/on-device/start.sh new file mode 100644 index 0000000..e202e80 --- /dev/null +++ b/on-device/start.sh @@ -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 \ No newline at end of file