Skip to content

Instantly share code, notes, and snippets.

@kimmoli
Last active August 29, 2015 14:23
Show Gist options
  • Save kimmoli/aaf9112dc16885695ad6 to your computer and use it in GitHub Desktop.
Save kimmoli/aaf9112dc16885695ad6 to your computer and use it in GitHub Desktop.
toholed dbus interface helper
# params: filename x y
# x y are coordinates of top-left corner
# e.g. drawpic.sh kissa.png 0 0
# recommneded file: png, mono 128x64
FILENAME="$1"
if [ -e "$FILENAME" ]; then
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.drawPicture \
int32:"$2" int32:"$3" array:byte:0x`xxd -c 1 -ps "$FILENAME" \
| sed 's/$/,0x/' | tr -d "\n" | rev | cut -c 4- | rev`
fi
#!/bin/bash
# thanks to mdxth et.al.
# clear screen
function clear () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"clear"
}
# lock screen for drawing (does not update clock/status)
function lock () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"lock" boolean:true
}
# release screen
function unlock () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"lock" boolean:false
}
# draw pixel
function pixel () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"pixel" int32:"$1" int32:"$2"
}
# draw circle at x0,y0 with radius r
function circle () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"circle" int32:"$1" int32:"$2" int32:"$3"
}
# draw line from x0,y0 to x1,y1
function line () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"line" int32:"$1" int32:"$2" int32:"$3" int32:"$4"
}
# draw black circle at x0,y0 with radius r
function circleb () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"circle" int32:"$1" int32:"$2" int32:"$3" int32:0
}
# draw black line from x0,y0 to x1,y1
function lineb () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"line" int32:"$1" int32:"$2" int32:"$3" int32:"$4" int32:0
}
# draw time
function dtime () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"time" int32:0 int32:0 string:"$1"
}
# draw time to x,y
function dtimexy () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"time" int32:"$1" int32:"$2" string:"$3"
}
# draw smalltext
function smalltext () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"smalltext" int32:"$1" int32:"$2" string:"$3"
}
# draw analog clock
function aclock () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"clock" int32:"$1" int32:"$2" boolean:true
}
# invert
function invert () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"invert" boolean:$1
}
# derp
function derp () {
dbus-send --system --print-reply --dest=com.kimmoli.toholed / com.kimmoli.toholed.draw \
string:"derp"
}
#!/bin/bash
source helpers.sh
function test () {
lock
clear
pixel 64 32
pixel 66 32
pixel 62 32
pixel 64 30
pixel 64 34
sleep 1
circle 64 32 20
circle 64 32 21
circle 64 32 22
circle 64 32 23
circle 64 32 30
circle 10 10 5
circle 118 54 5
sleep 1
circleb 64 32 20
circleb 64 32 21
circleb 64 32 22
circleb 64 32 23
circleb 64 32 30
circleb 10 10 5
circleb 118 54 5
sleep 1
line 0 32 127 32
line 64 0 64 63
line 0 0 127 63
line 0 63 127 0
sleep 1
lineb 0 32 127 32
lineb 64 0 64 63
lineb 0 0 127 63
lineb 0 63 127 0
sleep 1
circle 64 32 20
circle 64 32 21
circle 64 32 22
circle 64 32 23
circle 64 32 30
circle 10 10 5
circle 118 54 5
circle 118 10 5
circle 10 54 5
line 0 32 127 32
line 64 0 64 63
line 0 0 127 63
line 0 63 127 0
invert true
sleep 1
invert false
sleep 1
for st in 1 2 3 4 5 6 7 8 9
do
clear
dtimexy 56 $st $st
sleep 0.2
done
for st in "::1" "1234" "56:78" "00:00"
do
clear
dtime $st
sleep 0.2
done
let x=0
for st in "1" "2" "3" "4" "5" "6" "7" "8" "9" "0"
do
clear
smalltext $x 25 $st
let x=$x+10
sleep 0.2
done
sleep 0.8
clear
smalltext 0 10 "1234567890%*!"
smalltext 0 42 "wWbBgGuUlL"
sleep 1
clear
derp
sleep 1
invert true
sleep 1
invert false
sleep 1
clear
unlock
}
function smalltest () {
lock
clear
smalltext 0 0 "1234567890%*!"
smalltext 20 20 "wW bB"
smalltext 20 40 "gGuUlL"
sleep 5
clear
unlock
}
function aclocktest () {
lock
clear
for h in 0 1 2 3 4 5 6 7 8 9 10 11
do
let m=0
while [ $m -lt 60 ]
do
aclock $h $m
let m=$m+1
done
done
sleep 1
clear
unlock
}
test
smalltest
aclocktest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment