Browse Source

mic: Add comments to C++ example for Grove microphone/sound sensor

Signed-off-by: Sarah Knepper <sarah.knepper@intel.com>
Sarah Knepper 10 years ago
parent
commit
6e8b0dd038
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      examples/mic.cxx

+ 5
- 0
examples/mic.cxx View File

@@ -46,6 +46,7 @@ sig_handler(int signo)
46 46
 int
47 47
 main(int argc, char **argv)
48 48
 {
49
+    // Attach microphone to analog port A0
49 50
     sensor = new upm::Microphone(0);
50 51
     signal(SIGINT, sig_handler);
51 52
 
@@ -54,6 +55,10 @@ main(int argc, char **argv)
54 55
     ctx.runningAverage = 0;
55 56
     ctx.averagedOver   = 2;
56 57
 
58
+    // Infinite loop, ends when script is cancelled
59
+    // Repeatedly, take a sample every 2 microseconds;
60
+    // find the average of 128 samples; and
61
+    // print a running graph of the averages
57 62
     while (!is_running) {
58 63
         int len = sensor->getSampledWindow (2, 128, buffer);
59 64
         if (len) {