From 93e01000492a9ae0478c90971a055c667a6ec3a0 Mon Sep 17 00:00:00 2001 From: Sarah Knepper Date: Mon, 19 Jan 2015 11:22:39 -0800 Subject: [PATCH] mq2: Add comments to C++ example for mq2 gas sensor Signed-off-by: Sarah Knepper --- examples/mq2.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/mq2.cxx b/examples/mq2.cxx index defdf7a6..f3bd9ca9 100644 --- a/examples/mq2.cxx +++ b/examples/mq2.cxx @@ -46,6 +46,7 @@ sig_handler(int signo) int main(int argc, char **argv) { + // Attach gas sensor to A0 sensor = new upm::MQ2(0); signal(SIGINT, sig_handler); @@ -54,6 +55,10 @@ main(int argc, char **argv) ctx.runningAverage = 0; ctx.averagedOver = 2; + // Infinite loop, ends when script is cancelled + // Repeatedly, take a sample every 2 milliseconds; + // find the average of 128 samples; and + // print a running graph of the averages using a resolution of 5 while (!is_running) { int len = sensor->getSampledWindow (2, 128, buffer); if (len) {