Skip to content

Instantly share code, notes, and snippets.

@Tasssadar
Created December 27, 2011 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tasssadar/1523480 to your computer and use it in GitHub Desktop.
Save Tasssadar/1523480 to your computer and use it in GitHub Desktop.
This script will change between two eink modes - normal and fast-redraw with ungly font on predefined key sequence. Currently it is 2x back 2x home.
#!/bin/sh
# This script will change between two eink modes - normal and fast-redraw with ungly font
# on predefined key sequence. Currently it is 2x back 2x home.
# It also can show battery level in % - that is 2x home, look at the bottom of the screen
# It is for Kindle 4
#
# Key codes
# 158 1 - back
# 29 1 - keyboard
# 102 1 - home
# 139 1 - options
# 103 1 - up
# 105 1 - left
on=false
itr=0
found=false
mode=0
while :; do
k=`waitforkey`
#skip key release
if [ $(expr "$k" : ".* 0") != 0 ]; then
continue
fi
found=false
case $itr in
0|1)
if [ "$k" == "103 1" ]; then
mode=2
itr=1
found=true
elif [ $itr == 1 ] && [ "$k" == "105 1" ] && [ $mode == 2 ]; then
let "itr += 1"
found=true
elif [ "$k" == "158 1" ]; then
mode=0
let "itr += 1"
found=true
elif [ "$k" == "102 1" ]; then
mode=1
let "itr += 1"
found=true
fi
;;
2|3)
if [ "$k" == "102 1" ]; then
let "itr += 1"
found=true
elif [ "$k" == "139 1" ]; then
let "itr += 1"
found=true
fi
;;
esac
if [ $found == false ]; then
itr=0
continue
fi
if [ $mode == 0 ] && [ $itr == 4 ]; then
itr=0
if $on ; then
echo "Turned off"
echo 19 0 > /proc/eink_fb/update_display
echo 0 > /sys/devices/platform/eink_fb.0/override_upd_mode
on=false
else
echo "Turned on"
echo 19 7 > /proc/eink_fb/update_display
echo 1 > /sys/devices/platform/eink_fb.0/override_upd_mode
on=true
fi
elif [ $mode == 1 ] && [ $itr == 2 ]; then
usleep 500000 # wait for display to redraw
let "TEMP=(($(cat /sys/devices/system/yoshi_battery/yoshi_battery0/battery_temperature)-32)*5555)/10000"
PCT=$(cat /sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity | sed 's/[\%]//g')
eips 17 39 "Pct: $PCT Temp: $TEMP"
itr=0
elif [ $mode == 2 ] && [ $itr == 3 ]; then
usleep 500000
eips -g /mnt/us/rozvrh.jpg
itr=0
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment