From aaea4c0353e2a406a98d6f92bce8fabce2c49d80 Mon Sep 17 00:00:00 2001 From: starcalc Date: Tue, 2 Jul 2019 20:28:38 +0200 Subject: [PATCH] Tool: showgfx.h, viel hardcoded und ruckelt --- tools/showgfx.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 tools/showgfx.sh diff --git a/tools/showgfx.sh b/tools/showgfx.sh new file mode 100755 index 0000000..d982770 --- /dev/null +++ b/tools/showgfx.sh @@ -0,0 +1,35 @@ +#!/bin/bash +echo "Identified $1 with ${width} width and ${height} height." +size=32 +convert -rotate 90 -resize 32x32 "$1" 64.png +filename="64.png" +width=$(identify 64.png | cut -d' ' -f 3 | cut -d 'x' -f 1) +width=$(echo 10*${width}-8 | bc) +height=$(identify 64.png | cut -d' ' -f 3 | cut -d 'x' -f 2) +height=$(echo 10*${height}-8 | bc) +curx=0 +cury=0 +chx=5 +chy=7 + +while true; do + let curx=curx+chx + let cury=cury+chy + if [[ ${curx} -gt ${width} || ${curx} -lt 0 ]]; then + let chx=-1*chx + let curx=curx+2*chx + fi + if [[ ${cury} -gt ${height} || ${cury} -lt 0 ]]; then + let chy=-1*chy + let cury=cury+2*chy + fi + echo "${curx} ${chx} ${cury} ${chy}" + actx=$(echo ${curx}/10 | bc) + acty=$(echo ${cury}/10 | bc) + pixelstring=$(convert -crop 8x8+${actx}+${acty} "${filename}" rgb:- | xxd -ps | sed 's/\(......\)/#\1/g' | tr '[:lower:]' '[:upper:]' | tr -d '\n') + mosquitto_pub -h raum.ctdo.de -t 'homie/pixelbox/pixel/pixels/set' -m "${pixelstring}" + sleep 0.1 +done + + +