- echo -ne "$time\t$date\t$(date '+%F%t%T')\t"
- test "$level" -gt "$tresh" && {
- echo -n "0 Nothing detected...";
+ test "$level" -gt "$tresh" && state=false || state=true
+ $state && statenum=1 || statenum=0;
+ $state && statename='MOTION!' || statename='Nothing';
+
+ echo -ne "$time\t$date $(date '+%F %T') $statenum"
+
+ #History
+ after=$(( $date - $lastdate))
+ test $historymax -gt 0 && {
+ history=$(echo -n "$(yes | tr '\ny' $laststate | head -c $after)$history" | head -c $historymax)
+ for len in $historylen; do
+ on="$(echo -n ${history::$len} | tr -d 0 | wc -c)"
+ on="$(echo "scale=2; $on/$len" | bc)"
+ LC_ALL=C printf " %.2f" "$on"
+ done
+ }
+
+ #Debug
+ echo -e "\t($statename $level After $after secs)";
+
+ #Fun with values
+ $state && {