Skip to content

Commit

Permalink
refresh at midnight
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhampgonsalves committed Feb 5, 2023
1 parent 10ba406 commit de45983
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ ssh [email protected] << EOF
chmod 777 main
chmod 777 /etc/init.d/life-dashboard-init
echo "Install complete, start script with: `/etc/init.d/life-dashboard-init start`."
echo "Install complete, start script with: `/etc/init.d/life-dashboard-init start` and let it run till the ssh session hangs"
EOF
19 changes: 11 additions & 8 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh

# RUn via /etc/init.d/life-dashboard-init start
# Run via /etc/init.d/life-dashboard-init start

enable_wifi() {
lipc-set-prop com.lab126.cmd wirelessEnable 1
Expand Down Expand Up @@ -38,13 +37,17 @@ while true; do
echo "drawing image"
eips -f -g /image.png

sleep 1
echo "drawing battery level"
batteryLevel=$(lipc-get-prop com.lab126.powerd battLevel)
eips 46 38 "$batteryLevel"

echo "writing stats"
let max_sleep=24*60*60
let next_refresh=$((`date +%s` % 86400 - (4*60*60) )) # seconds till midnight
if [ $next_refresh -le 0 ] || [ $next_refresh -ge $max_sleep ]; then next_refresh=$max_sleep; fi
battery_level=$(lipc-get-prop com.lab126.powerd battLevel)
let next_refresh_minutes=$next_refresh/60
eips 2 37 "m.$next_refresh_minutes b.$battery_level"
eips 2 38 "$(TZ=UTC+4 date -R "+%a %l:%M")"

echo "entering rtc sleep"
sleep 5
echo 86400 > /sys/devices/platform/mxc_rtc.0/wakeup_enable
echo $next_refresh > /sys/devices/platform/mxc_rtc.0/wakeup_enable
echo "mem" > /sys/power/state
done

0 comments on commit de45983

Please sign in to comment.