Sleepmon gnuplot graphing
authorTomas Mudrunka <tomas@mudrunka.cz>
Thu, 2 Aug 2012 19:48:46 +0000 (21:48 +0200)
committerTomas Mudrunka <tomas@mudrunka.cz>
Thu, 2 Aug 2012 19:48:46 +0000 (21:48 +0200)
c/goertzel/README.md
c/goertzel/sleepmon.sh
c/goertzel/sleepplot.sh [new file with mode: 0755]

index a21b5ccb82b688b4df7f5a79b700f834ebe8884b..d32a00b0fdffab1840b531ee62afda421b0d3ac8 100644 (file)
@@ -18,6 +18,7 @@ Scriptable tone detection and audio analysis
   * **histogram.sh**: example using histogram.pl to draw realtime equalizer
   * **sleepmon.sh**: Generates frequency on soundcard output and detects it on input
      * Can be used to detect and log motion using soundcard and PIR sensor or NC switch
+  * **sleepplot.sh*: Generates gnuplot graph from sleeplog
   * TODO
      * Guitar tuner
      * Send me more...
index 4896e87327002696a3092d70f5ea4c3351ddf36e..87967dd9d86148714cc6776541ff5a7033c1e670 100755 (executable)
@@ -28,10 +28,10 @@ arecord | ./goertzel -n i -q -l c -t $tresh -d 4 | while read line; do
        level="$(echo "$line" | cut -f 2)"
        echo -ne "$time\t$date\t$(date '+%F%t%T')\t"
        test "$level" -gt "$tresh" && {
-               echo -n "Nothing detected...";
+               echo -n "Nothing detected...";
                $screen && xset dpms force off || true;
        } || {
-               echo -n "Motion detected!!!!";
+               echo -n "Motion detected!!!!";
                $screen && xset dpms force on;
        }
        test "$lastdate" != 0 && {
@@ -39,6 +39,7 @@ arecord | ./goertzel -n i -q -l c -t $tresh -d 4 | while read line; do
                echo -ne "\t$level After $after secs";
        }
        echo;
+       ./sleepplot.sh "$out" &>/dev/null;
        lastdate="$date";
 done | tee "$out"
 kill $!
diff --git a/c/goertzel/sleepplot.sh b/c/goertzel/sleepplot.sh
new file mode 100755 (executable)
index 0000000..09fd050
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+test -z "$1" && {
+       echo "Usage: $0 sleeplog.txt"
+       exit 23
+}
+
+size="$(tail -n 1 "$1" | cut -d . -f 1)"
+test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods
+size="$(( 200 + ($size * 2) ))"
+
+gnuplot << EOF
+set output "$1.png"
+set terminal png size $size,200
+
+set title "Sleep motions"
+set xlabel "time"
+set ylabel "motion"
+
+set yrange [-0.5:1.5]
+
+set xdata time
+set timefmt "%s"
+#set format x "%H:%M:%S"
+
+#set y2tics 300
+#set ytics 5
+
+set grid
+
+#set pointsize 0.5
+plot "$1" using 2:5 with histeps;
+
+EOF
+
+
+
+
This page took 0.11966 seconds and 4 git commands to generate.