Nathaniel Honka / Mbed 2 deprecated Data-Management-Honka

Dependencies:   ExoController MODSERIAL SDFileSystem_HelloWorld UI-Honka mbed

Fork of Data Management by HEL's Angels

main.cpp

Committer:
perr1940
Date:
2014-10-16
Revision:
1:78452728a306
Parent:
0:cbb61997e231
Child:
2:b87aaf1bc803

File content as of revision 1:78452728a306:

#include "mbed.h"
#include "MODSERIAL.h"
#include "initDatabed.h"
#include "UI.h"

Timer t_debug;

int main()
{
    int dataIn[2], dataOut[2];
    dataOut[0]=7;
    dataOut[1]=30;
    mainPower=0;//Don't turn on for initial testing
    initializeDatabed();
    comm.reply(dataOut[0]);//make this the first message
    pc.printf("DataBed On!\r\n");
    int counter=0;
    //float blah=1;
    //t_debug.start();
    while (1) { //Run these functions as fast as possible
        /*if(comm.receive()) {
            //t_debug.reset();
            dataIn[0] = comm.read();//Read the SPI buffer

            while(dataIn[0]==75) {
                if(comm.receive()) {
                    //comm.reply(dataOut[1]);// Make this the next reply
                    dataIn[1]=comm.read();//Read the SPI buffer
                    //pc.printf("T");
                    break;
                }
            }
            if(counter>=100) {
                UI=0;//set the UI to 0 unless it's changed in checkUI_Xbee()
                readBuffer();
                checkUI_XBee(); //check UI from Xbee
                counter=0;
            }
            //dataOut[0]=UI;
            comm.reply(dataOut[0]);//Set the communication for the next round
            pc.printf("Data: %d, %d,\r\n", dataIn[0], dataIn[1]);
            comm.reply(dataOut[1]);// Make this the next repl
            //counter++;
            //blah=t_debug.read_us();
            //pc.printf("UI: %d\r\n", UI);
            //pc.printf("T: %f \r\n ", blah);
            
        }*/
        if(comm.receive()) {
            dataIn[0] = comm.read();
            comm.reply(28);         // Make this the next reply
            while(dataIn[0]==7) {
                if(comm.receive()) {
                    dataIn[1]=comm.read();
                    comm.reply(5);
                    pc.printf("Data1: %u, Data2: %u\n\r", dataIn[0], dataIn[1]);
                    dataIn[0]=0;
                    break;
                }
            }
        }
    }
}