Permalink
Browse files

added comments to examples

removed delay() functions from event_test
  • Loading branch information...
1 parent bca8cdb commit 57a64006ca66a2b294ee344a58a1ea69e75ab834 @jlamothe committed Jun 11, 2011
Showing with 31 additions and 5 deletions.
  1. +11 −5 examples/event_test/event_test.pde
  2. +6 −0 examples/serial_test/serial_test.pde
  3. +14 −0 examples/switch_test/switch_test.pde
View
16 examples/event_test/event_test.pde
@@ -19,11 +19,19 @@
// See license.txt for more details.
+// * * *
+
+// This program demonstrates the EventHandler class by creating an
+// event which will only evaluate true periodically and then run for a
+// while before waiting for the condition to evaluate true again. The
+// program reports what's going on over the serial console for the
+// demonstration.
+
#include <mthread.h>
#include <newdel.h>
#define COUNT 5
-#define WAIT_TIME 1000
+#define SLEEP_TIME 1
class MyEvent : public EventHandler
{
@@ -43,29 +51,27 @@ MyEvent::MyEvent()
bool MyEvent::condition()
{
+ sleep(SLEEP_TIME);
if(count < COUNT)
{
Serial.println("Event not triggered.");
count++;
- delay(WAIT_TIME);
return false;
}
Serial.println("Event triggered.");
- delay(WAIT_TIME);
return true;
}
bool MyEvent::on_event()
{
+ sleep(SLEEP_TIME);
if(count > 0)
{
Serial.println("Handler running.");
count--;
- delay(WAIT_TIME);
return true;
}
Serial.println("Handler completed.");
- delay(WAIT_TIME);
return false;
}
View
6 examples/serial_test/serial_test.pde
@@ -18,6 +18,12 @@
// along with this program. If not, see
// <http://www.gnu.org/licenses/>.
+// * * *
+
+// This program creates 5 seperate threads which report over serial
+// when they're called. It can be tested by running the program and
+// watching the serial console.
+
#include <newdel.h>
#include <mthread.h>
View
14 examples/switch_test/switch_test.pde
@@ -19,6 +19,20 @@
// See license.txt for more details.
+// * * *
+
+// This program demonstrates the SwitchInput class. It assumes three
+// switches are hooked up to pins 2, 3 and 4. The switch on pin 2
+// should be a dry contact to ground (the internal pull-up is used on
+// this switch). The switch on pin 3 should be a dry contact to
+// ground with an external pull-up resistor. The switch on pin 4
+// should connect to the device's power output, with a pull-down
+// resistor to ground. There shold also be an LED connected to pin 5
+// (with an appropriate resistor).
+
+// When any of these switches close, the LED will illuminate. When
+// any of the switches open, the LED will go out.
+
#include <mthread.h>
#include <newdel.h>

0 comments on commit 57a6400

Please sign in to comment.