This is some awesome robot code

Dependencies:   mbed-rtos mbed QEI

Fork of ICRSEurobot13 by Thomas Branch

Revision:
21:167dacfe0b14
Parent:
20:70d651156779
Child:
31:ada943ecaceb
--- a/Processes/Printing/Printing.cpp	Tue Apr 09 15:33:36 2013 +0000
+++ b/Processes/Printing/Printing.cpp	Tue Apr 09 19:24:31 2013 +0000
@@ -1,17 +1,21 @@
 #include "Printing.h"
+#include <iostream>
+
+namespace Printing {
+
 #ifdef PRINTINGOFF
-void printingThread(void const*){Thread::wait(osWaitForever);}
+void printingloop(void const*){Thread::wait(osWaitForever);}
 bool registerID(char, size_t){return true;}
 bool unregisterID(char) {return true;}
 bool updateval(char, float*, size_t){return true;}
 bool updateval(char id, float value){return true;}
 #else
-#include <iostream>
+
 using namespace std;
 
-size_t idlist[NUMIDS]; // Stores length of buffer 0 => unassigned
-float* buffarr[NUMIDS];
-volatile unsigned int newdataflags;
+size_t idlist[NUMIDS] = {0}; // Stores length of buffer 0 => unassigned
+float* buffarr[NUMIDS] = {0};
+volatile unsigned int newdataflags = 0;
 
 bool registerID(char id, size_t length) {   
     if (id < NUMIDS && !idlist[id]) {//check if the id is already taken
@@ -52,16 +56,16 @@
         return false;
 }
 
-void printingThread(void const*){
-    newdataflags = 0;
-    for (int i = 0; i < NUMIDS; i++) {
-        idlist[i] = 0;
-        buffarr[i] = 0;
-    }
+void printingloop(void const*){
 
-
-    Thread::wait(3500);
-    while(true){   
+    Serial pc(USBTX, USBRX);
+    pc.baud(115200);
+    
+    char sync[] = "ABCD";
+    cout.write(sync, 4);
+    cout << std::endl;
+    
+    while(true){
         // Send number of packets
         char numtosend = 0;
         for (unsigned int v = newdataflags; v; numtosend++){v &= v - 1;}        
@@ -79,7 +83,9 @@
         Thread::wait(200);
     }
 }
-#endif
 
 
+#endif //end PRINTINGOFF
+
+} //end namespace