Pacemaker code Implementation for SFWRENG 3K04
Dependencies: FXOS8700Q Queue mbed-rtos mbed
Fork of Pacemaker by
Revision 30:0cb4890910cd, committed 2016-11-29
- Comitter:
- FiveDollar
- Date:
- Tue Nov 29 21:30:19 2016 +0000
- Parent:
- 29:c0d63940b0c7
- Commit message:
- this is the messed up code that i tried to fix
Changed in this revision
--- a/dataStruct.cpp Tue Nov 29 21:03:33 2016 +0000 +++ b/dataStruct.cpp Tue Nov 29 21:30:19 2016 +0000 @@ -3,23 +3,22 @@ #include "rtos.h" #include "mbed.h" -dataStruct::dataStruct(hardware* hWare): myQueue(1,N){//,thread(&dataStruct::threadStarter){ +void dataStruct(hardware* hWare){ + //,thread(&dataStruct::threadStarter){ myHardware = hWare; // thread.signal_set(START_THREAD); } - -dataStruct::~dataStruct(){ - } + -void dataStruct::threadStarter(void const *p){ - dataStruct *instance = (dataStruct*)p; - instance->storeData(); - } +//void threadStarter(void const *p){ +// dataStruct *instance = (dataStruct*)p; +// instance->storeData(); +// } -void dataStruct::storeData(){ +void storeData(){ // thread.signal_wait(START_THREAD); while(true){ - streamValue = myHardware->getSense(); + streamValue = io->getSense(); if(myQueue.GetNumberOfItems() <= N){ myQueue.Put(&streamValue); } @@ -27,7 +26,7 @@ } } -queue dataStruct::getData(){ +queue getData(){ queue temp = myQueue; myQueue.Flush(); return temp;
--- a/dataStruct.h Tue Nov 29 21:03:33 2016 +0000 +++ b/dataStruct.h Tue Nov 29 21:30:19 2016 +0000 @@ -6,20 +6,16 @@ #define START_THREAD 1 -class dataStruct{ -public: - dataStruct(hardware*); - ~dataStruct(); + + void dataStruct(hardware*); queue getData(); - -private: + extern hardware* io; static const int N = 13; double k_streamPeriod; hardware* myHardware; double streamValue; - queue myQueue; + queue myQueue(1,N); static void threadStarter(void const *p); void storeData(); Thread thread; - -}; \ No newline at end of file + \ No newline at end of file
--- a/interface.cpp Tue Nov 29 21:03:33 2016 +0000 +++ b/interface.cpp Tue Nov 29 21:30:19 2016 +0000 @@ -303,7 +303,7 @@ // } void interface::getEgram(){ - myDataStruct = new dataStruct(myHardware); + //myDataStruct = new dataStruct(myHardware); isEgram = true; pc->printf("\nPress 1 to stop streaming egram data"); while(isEgram){ @@ -315,7 +315,7 @@ } Thread::wait(40); - myQueue = myDataStruct->getData(); + myQueue = getData(); //I know below doesn't look neat, but it just will print values to the screen for now. One day we may do a graph. myQueue.Get( &nTemp ); pc->printf( "Item 1 = %d\r", nTemp ); @@ -338,7 +338,7 @@ myQueue.Get( &nTemp ); pc->printf( "Item 10 = %d\r", nTemp ); } - delete myDataStruct; + // delete myDataStruct; }
--- a/interface.h Tue Nov 29 21:03:33 2016 +0000 +++ b/interface.h Tue Nov 29 21:30:19 2016 +0000 @@ -40,7 +40,8 @@ genData* generalData; chamberData* atrData; chamberData* ventData; - dataStruct* myDataStruct; + //dataStruct* myDataStruct; + extern getData(); hardware* myHardware; queue myQueue; unsigned char nTemp;
--- a/main.cpp Tue Nov 29 21:03:33 2016 +0000 +++ b/main.cpp Tue Nov 29 21:30:19 2016 +0000 @@ -22,6 +22,7 @@ motion_set_chamber(0, ventricle); motionThread.start(motion_thread); + queue myQueue Thread egramThread(osPriorityNormal); egramThread.start(storeData);