Pacemaker code Implementation for SFWRENG 3K04

Dependencies:   mbed Queue mbed-rtos FXOS8700Q

Fork of Pacemaker by Eric dollar

SWFRENG 3K04 Project to design, develop, and document a functional pacemaker.

The project uses the Freescale K64F Microcontroller and C++ mbed library.

Files at this revision

API Documentation at this revision

Comitter:
noahzwiep
Date:
Thu Nov 24 04:53:30 2016 +0000
Parent:
24:4af25128cedf
Child:
26:3b49e8c3793f
Commit message:
Added getEgram() functionality in interface. ; * Note * Not sure how to use button press to exit while loop

Changed in this revision

interface.cpp Show annotated file Show diff for this revision Revisions of this file
interface.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/interface.cpp	Thu Nov 24 03:51:30 2016 +0000
+++ b/interface.cpp	Thu Nov 24 04:53:30 2016 +0000
@@ -1,4 +1,4 @@
-    #pragma once
+#pragma once
 #include "mbed.h"
 #include "interface.h"
 #include "hardware.h"
@@ -7,26 +7,28 @@
 #include "pulse.h"
 #include "voor.h"
 #include "rtos.h"
+#include "queue.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string>
 
 //CONSTRUCTORS*****************************
-interface::interface(){
+interface::interface(): myQueue(1,N){
     }
 
 interface::~interface(){};
 
-interface::interface(Serial* inputPC){
+interface::interface(Serial* inputPC): myQueue(1,N){
     pc = inputPC;
     }
 
-interface::interface(Serial* inputPC , pulse* p ,genData* genData, chamberData* atrium , chamberData* ventricle){
+interface::interface(Serial* inputPC , pulse* p ,genData* genData, chamberData* atrium , chamberData* ventricle, hardware* hardw): myQueue(1,N) {
     generalData = genData;
     pc = inputPC;
     interfacePulse = p;
     atrData = atrium;
-    ventData = ventricle;
+    ventData = ventricle; 
+    myHardware = hardw; 
     }
 //********************************************
 
@@ -80,7 +82,7 @@
         case '3':
             interface::genDataScreen();
         case '4':
-            pc->printf("\nNot setup yet");
+            interface::getEgram();
             break;
         case '5':
             interface::startScreen();  
@@ -299,6 +301,43 @@
             interface::getData(chamber);
     }  
  }
+ 
+void interface::getEgram(){
+    myDataStruct = new dataStruct(myHardware);
+    while(true){
+        Thread::wait(52);
+        myQueue = myDataStruct->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 );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 2 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 3 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 4 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 5 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 6 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 7 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 8 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 9 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 10 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 11 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 12 = %d\r", nTemp );
+        myQueue.Get( &nTemp );
+        pc->printf( "Item 13 = %d\r", nTemp );
+    }
+    delete myDataStruct;
+}
+ 
 char* interface::getInput(){
     char buffer[5];
     fgets (buffer,5,stdin);
--- a/interface.h	Thu Nov 24 03:51:30 2016 +0000
+++ b/interface.h	Thu Nov 24 04:53:30 2016 +0000
@@ -5,6 +5,7 @@
 #include "genData.h"
 #include "pulse.h"
 #include "dataStruct.h"
+#include "queue.h"
 
 class interface{
 
@@ -12,7 +13,7 @@
     interface();
     ~interface();
     interface(Serial*);
-    interface(Serial* , pulse* , genData*, chamberData* , chamberData*);
+    interface(Serial* , pulse* , genData*, chamberData* , chamberData*, hardware*);
     void startScreen();
 
 //    void setAtrium(AnalogOut&);
@@ -38,4 +39,9 @@
     genData* generalData;
     chamberData* atrData;
     chamberData* ventData;
+    dataStruct* myDataStruct;
+    hardware* myHardware;
+    queue myQueue;
+    unsigned char nTemp;
+    static const int N = 13;
 };
\ No newline at end of file
--- a/main.cpp	Thu Nov 24 03:51:30 2016 +0000
+++ b/main.cpp	Thu Nov 24 04:53:30 2016 +0000
@@ -22,7 +22,7 @@
     motion_set_chamber(0, ventricle);
     motionThread.start(motion_thread);
     
-    interface a(io->getSerial() , ventPulse , generalData, atrium , ventricle); 
+    interface a(io->getSerial() , ventPulse , generalData, atrium , ventricle,io); 
     
     a.startScreen();