Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added comments to examples

removed delay() functions from event_test
  • Loading branch information...
commit 57a64006ca66a2b294ee344a58a1ea69e75ab834 1 parent bca8cdb
Jonathan Lamothe authored
16 examples/event_test/event_test.pde
@@ -19,11 +19,19 @@
19 19
20 20 // See license.txt for more details.
21 21
  22 +// * * *
  23 +
  24 +// This program demonstrates the EventHandler class by creating an
  25 +// event which will only evaluate true periodically and then run for a
  26 +// while before waiting for the condition to evaluate true again. The
  27 +// program reports what's going on over the serial console for the
  28 +// demonstration.
  29 +
22 30 #include <mthread.h>
23 31 #include <newdel.h>
24 32
25 33 #define COUNT 5
26   -#define WAIT_TIME 1000
  34 +#define SLEEP_TIME 1
27 35
28 36 class MyEvent : public EventHandler
29 37 {
@@ -43,29 +51,27 @@ MyEvent::MyEvent()
43 51
44 52 bool MyEvent::condition()
45 53 {
  54 + sleep(SLEEP_TIME);
46 55 if(count < COUNT)
47 56 {
48 57 Serial.println("Event not triggered.");
49 58 count++;
50   - delay(WAIT_TIME);
51 59 return false;
52 60 }
53 61 Serial.println("Event triggered.");
54   - delay(WAIT_TIME);
55 62 return true;
56 63 }
57 64
58 65 bool MyEvent::on_event()
59 66 {
  67 + sleep(SLEEP_TIME);
60 68 if(count > 0)
61 69 {
62 70 Serial.println("Handler running.");
63 71 count--;
64   - delay(WAIT_TIME);
65 72 return true;
66 73 }
67 74 Serial.println("Handler completed.");
68   - delay(WAIT_TIME);
69 75 return false;
70 76 }
71 77
6 examples/serial_test/serial_test.pde
@@ -18,6 +18,12 @@
18 18 // along with this program. If not, see
19 19 // <http://www.gnu.org/licenses/>.
20 20
  21 +// * * *
  22 +
  23 +// This program creates 5 seperate threads which report over serial
  24 +// when they're called. It can be tested by running the program and
  25 +// watching the serial console.
  26 +
21 27 #include <newdel.h>
22 28 #include <mthread.h>
23 29
14 examples/switch_test/switch_test.pde
@@ -19,6 +19,20 @@
19 19
20 20 // See license.txt for more details.
21 21
  22 +// * * *
  23 +
  24 +// This program demonstrates the SwitchInput class. It assumes three
  25 +// switches are hooked up to pins 2, 3 and 4. The switch on pin 2
  26 +// should be a dry contact to ground (the internal pull-up is used on
  27 +// this switch). The switch on pin 3 should be a dry contact to
  28 +// ground with an external pull-up resistor. The switch on pin 4
  29 +// should connect to the device's power output, with a pull-down
  30 +// resistor to ground. There shold also be an LED connected to pin 5
  31 +// (with an appropriate resistor).
  32 +
  33 +// When any of these switches close, the LED will illuminate. When
  34 +// any of the switches open, the LED will go out.
  35 +
22 36 #include <mthread.h>
23 37 #include <newdel.h>
24 38

0 comments on commit 57a6400

Please sign in to comment.
Something went wrong with that request. Please try again.