Eurobot2012_Primary
Dependencies: mbed Eurobot_2012_Primary
Diff: ui/ui.cpp
- Revision:
- 8:ffc7d8af2d5a
- Parent:
- 7:f9c59a3e4155
--- a/ui/ui.cpp Fri Apr 27 16:37:26 2012 +0000 +++ b/ui/ui.cpp Fri Apr 27 18:36:54 2012 +0000 @@ -4,7 +4,7 @@ #include "system.h" UI::UI() : - tUI(printtw,this,osPriorityNormal,1024) { + tUI(printtw,this,osPriorityNormal,2048) { newdataflags = 0; for (int i = 0; i < NUMIDS; i++) { idlist[i] = 0; @@ -25,15 +25,16 @@ } bool UI::updateval(char id, float* buffer, unsigned int length) { - + //check if the id is registered, and has buffer of correct length if (id < NUMIDS && idlist[id] == length && buffarr[id] && !(newdataflags & (1<<id))) { for (int i = 0; i < length; i++) buffarr[id][i] = buffer[i]; newdataflags |= (1<<id); return true; - } else + } else{ return false; + } } bool UI::updateval(char id, float value) { @@ -60,28 +61,36 @@ void UI::printloop() { - OLED4 = !OLED4; Thread::wait(1500); char* sync = "ABCD"; std::cout.write(sync, 4); - std::cout.flush(); - //std::cout << std::endl; + //std::cout.flush(); + std::cout << std::endl; //printf("\r\n"); - - OLED4 = !OLED4; while (1) { + + OLED3 = !OLED3; + + //send number of packets + char numtosend = 0; + for (int id = 0; id < NUMIDS; id++) + if (newdataflags & (1<<id)) + numtosend++; + + std::cout.put(numtosend); //send packets - for (int id = 0; id < NUMIDS; id++) { + for (char id = 0; id < NUMIDS; id++) { if (newdataflags & (1<<id)) { std::cout.put(id); - std::cout.write((char*)buffarr[id], 4*idlist[id]); + std::cout.write((char*)buffarr[id], idlist[id] * sizeof(float)); newdataflags &= ~(1<<id); } } - + + std::cout << std::endl; //std::cout.flush(); Thread::wait(200); }