Months ago, i wanted to build a movement sensor using my mouse as main device. The main idea was do a device that allow detect displacements < 1mm, if function of the time. In mechanical, it's common to do stress-strain curves as a function of time to characterize materials. The project is now on stand-by, but this script allows you to do a lot of things.
Code: Select all
#!/bin/bash
rm /tmp/raw2 &> /dev/null
rm /tmp/result &> /dev/null
hexcat /dev/psaux > /tmp/raw2 &
basetime=$(date +%s%N)
value(){
r=($(tail -1 /tmp/result | cut -d\ -f1\ 2))
case "$(tail -1 /tmp/raw2 | cut -b 12-19)" in
"08 00 01")
x=$((${r[0]}+0))
y=$((${r[1]}+1))
state="↑"
;;
"28 00 ff")
x=$((${r[0]}+0))
y=$((${r[1]}-1))
state="↓"
;;
"18 ff 00")
x=$((${r[0]}-1))
y=$((${r[1]}+0))
state="