adding documentation file
[ixm-collector.git] / ixm-collector.org
bloba9fe021908f0d763ec7787a00e1c6034882c3ab1
1 #+TITLE: IXM collector
2 #+OPTIONS: num:nil ^:nil
3 #+LaTeX_CLASS: normal
5 The collector is a small utility which can be included in your
6 sketches to allow printing directly back to a central observer
7 (probably your laptop) through a virtual face.  The following example
8 sketch (included as =sketch.pde= in this repository) demonstrates it's
9 usage.
11 #+begin_src c++
12   /*                                             -*- mode:C++ -*-
13    *
14    * Sketch description: Simple demonstration of the collector
15    * 
16    * Sketch author: Eric Schulte
17    *
18    */
19   #include "collector.h"          // include the collector
20   int cface;                      // the virtual face assigned to the
21                                   //   collector
22   int ledPin = 13;                // LED connected to digital pin 13
23   int wait;                       // a variable for the delay time
24   
25   void setup() {
26     cface = collector_init();     // initialize the collector and assign
27                                   //   the virtual face
28   }
29   
30   void loop() {
31     wait = random(2000);          // set wait to a random number
32     delay(wait);                  // wait for the assigned time
33     digitalWrite(ledPin, LOW);    // sets the LED on
34     // print to the collector face and the result will be automatically
35     //   routed to your laptop
36     facePrintf(cface, "waited %d miliseconds\n", wait);   
37     delay(500);                   // wait for the assigned time 
38     digitalWrite(ledPin, HIGH);   // sets the LED off
39   }
40 #+end_src
42 Once this sketch has burned to your boards, you send a =c=-packet
43 (=c2= in the example below) telling your boards that you will be the
44 collector.  Each =c=-packet should contain a number -- boards keep
45 track of the highest =c=-number they have received and will ignore any
46 =c=-packets with lower numbers.  Once the boards receive this
47 =c=-packet their collector face will be connected to the sender of the
48 =c=-packet.  this is should in the following output of the above
49 example =sketch.pde=.
51 #+begin_example
52   Ln 11.602 [Sending checksum South for 0x10014+32748=AAD8E8E5-86FBCC66]
53   Ln 16.257 [Sending checksum North for 0x18000+12204=A3E9651E-194595F0]
54   Ln 17.953 [Sending checksum South for 0x18000+12204=A3E9651E-194595F0]
55   Ln 19.283 [North burned successfully!]
56   Ln 20.985 [South burned successfully!]
57   c2
58   (-1,1) waited 1349 miliseconds
59   (0,0) waited 3888 miliseconds
60   (1,-1) waited 2374 miliseconds
61   (1,0) waited 4205 miliseconds
62   (-1,-1) waited 2570 miliseconds
63   (1,1) waited 2540 miliseconds
64   (-1,0) waited 3334 miliseconds
65   (1,1) waited 1485 miliseconds
66   (0,0) waited 2455 miliseconds
67   (-1,1) waited 4452 miliseconds
68   (-1,-1) waited 3534 miliseconds
69   (1,0) waited 3948 miliseconds
70   (1,-1) waited 4650 miliseconds
71   (1,-1) waited 430 miliseconds
72   (-1,0) waited 4916 miliseconds
73   (1,-1) waited 464 miliseconds
74   (0,0) waited 3712 miliseconds
75 #+end_example