reeeeeeeeeeeeeee

Dependencies:   MotionSensor mbed

Fork of Assignment2_ver3 by weeb grammers

Files at this revision

API Documentation at this revision

Comitter:
oopakhooo
Date:
Wed Oct 26 21:17:17 2016 +0000
Parent:
2:e2ae43e8acab
Child:
4:f0a11480f39f
Commit message:
hk;

Changed in this revision

Hardware.cpp Show annotated file Show diff for this revision Revisions of this file
Hardware.h Show annotated file Show diff for this revision Revisions of this file
PaceHeart.cpp Show annotated file Show diff for this revision Revisions of this file
PaceHeart.h Show annotated file Show diff for this revision Revisions of this file
interface.cpp 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/Hardware.cpp	Mon Oct 24 01:11:37 2016 +0000
+++ b/Hardware.cpp	Wed Oct 26 21:17:17 2016 +0000
@@ -1,1 +1,5 @@
-#include "Hardware.h"
\ No newline at end of file
+#include "Hardware.h"
+#include "mbed.h"
+
+DigitalOut output_pin_A(LED1);
+DigitalOut output_pin_V(LED2);
\ No newline at end of file
--- a/Hardware.h	Mon Oct 24 01:11:37 2016 +0000
+++ b/Hardware.h	Wed Oct 26 21:17:17 2016 +0000
@@ -1,9 +1,12 @@
 #include <string>
 using namespace std;
+#include "mbed.h"
 
-#ifndef PACEHEART_H
-#define PACEHEART_H
+#ifndef HARDWARE_H
+#define HARDWARE_H
 
 int get_();
 
+extern DigitalOut output_pin_A;
+extern DigitalOut output_pin_V;
 #endif
\ No newline at end of file
--- a/PaceHeart.cpp	Mon Oct 24 01:11:37 2016 +0000
+++ b/PaceHeart.cpp	Wed Oct 26 21:17:17 2016 +0000
@@ -1,76 +1,186 @@
 #include "PaceHeart.h"
+#include "mbed.h"
+#include "Hardware.h"
+using namespace std;
+
+
 
-int p_pacingState = 0;
-int p_pacingMode = 0;
-int p_hysteresis = 0;
-int p_hysterwaiaInterval = 300;
-int lowrateInterval = 1000;
-double p_vPacwAmp = 3500.0;
-double p_vPaceWidth = 0.4;
-int p_VRP = 320;
+PaceHeart::PaceHeart(){
+    p_pacingState = 0;
+    p_pacingMode = 0;
+    int p_hysteresis = 0;
+    int p_hysteresisInterval = 300;
+    int lowrateInterval = 1000;
+    int uprateInterval = 500; //upper rate limit
+//Ventricle
+    double p_vPaceAmp = 3500.0;
+    double p_vPaceWidth = 0.4;
+    int p_VRP = 320;
+//Atrium (change defaults)
+    double p_aPaceAmp = 3500.0;
+    double p_aPaceWidth = 0.4;
+    int p_ARP = 320;
+}
 
-int get_p_pacingState()
+int PaceHeart::get_p_pacingState()
 {
     return p_pacingState;
 }
-int get_p_pacingMode()
+int PaceHeart::get_p_pacingMode()
 {
     return p_pacingMode;
 }
-int get_p_hysteresis()
+int PaceHeart::get_p_hysteresis()
 {
-    return hysteresis;
+    return p_hysteresis;
 }
-void set_p_hysteresis(int x)
+void PaceHeart::set_p_hysteresis(int x)
 {
     p_hysteresis = x;
     return;
 }
-int get_p_hysterwaiaInterval()
+int PaceHeart::get_p_hysteresisInterval()
 {
-    return p_hysterwaiaInterval;
+    return p_hysteresisInterval;
 }
-void set_p_hysterwaiaInterval(int x)
+void PaceHeart::set_p_hysteresisInterval(int x)
 {
-    p_hysterwaiaInterval = x;
+    p_hysteresisInterval = x;
     return;
 }
-int get_lowrateInterval()
+int PaceHeart::get_lowrateInterval()
 {
     return lowrateInterval;
 }
-void set_lowrateInterval(int x)
+void PaceHeart::set_lowrateInterval(int x)
 {
     lowrateInterval = x;
     return;
 }
-
-double get_p_vPacwAmp()
+int PaceHeart::get_uprateInterval()
 {
-    return p_vPacwAmp;
+    return uprateInterval;
 }
-void set_p_vPacwAmp(double x)
+void PaceHeart::set_uprateInterval(int x)
 {
-    p_vPacwAmp = x;
+    uprateInterval = x;
     return;
 }
-
-double get_p_vPaceWidth()
+//Ventricle
+double PaceHeart::get_p_vPaceAmp()
+{
+    return p_vPaceAmp;
+}
+void PaceHeart::set_p_vPaceAmp(double x)
+{
+    p_vPaceAmp = x;
+    return;
+}
+ 
+double PaceHeart::get_p_vPaceWidth()
 {
     return p_vPaceWidth;
 }
-void set_p_vPaceWidth(double x)
+void PaceHeart::set_p_vPaceWidth(double x)
 {
     p_vPaceWidth = x;
     return;
 }
-
-int get_p_VRP()
+ 
+int PaceHeart::get_p_VRP()
 {
     return p_VRP;
 }
-void set_p_VRP(int x)
+void PaceHeart::set_p_VRP(int x)
 {
     p_VRP = x;
     return;
-}
\ No newline at end of file
+}
+//Atrium
+double PaceHeart::get_p_aPaceAmp()
+{
+    return p_aPaceAmp;
+}
+void PaceHeart::set_p_aPaceAmp(double x)
+{
+    p_aPaceAmp = x;
+    return;
+}
+ 
+double PaceHeart::get_p_aPaceWidth()
+{
+    return p_aPaceWidth;
+}
+void PaceHeart::set_p_aPaceWidth(double x)
+{
+    p_aPaceWidth = x;
+    return;
+}
+ 
+int PaceHeart::get_p_ARP()
+{
+    return p_ARP;
+}
+void PaceHeart::set_p_ARP(int x)
+{
+    p_ARP = x;
+    return;
+}
+
+
+
+void PaceHeart::pace_A(double amp, double wid,int pin)
+{   
+    output_pin_A = !output_pin_A ;
+    wait(1);
+   
+    
+   
+    return;
+}
+
+void PaceHeart::pace_A()
+{
+    double amplitude = get_p_aPaceAmp();
+    double width = get_p_aPaceWidth();
+    // int output_pin = hardware.get_output_pin; //include the hardware module
+    pace_A(amplitude,width,output_pin_A);
+    return;
+}
+
+
+void PaceHeart::pace_V(double amp, double wid, int pin)
+{
+    output_pin_V = !output_pin_V ;
+    wait(2);
+   
+    return;
+}
+
+void PaceHeart::pace_V()
+{
+    double amplitude = get_p_vPaceAmp();
+    double width = get_p_vPaceWidth();
+    // int output_pin = hardware.get_output_pin; //include the hardware module
+    pace_V(amplitude,width,output_pin_V);
+    return;
+}
+
+
+void PaceHeart::pace(int mode)
+{
+    switch(mode){
+    case 1:  //AOO
+           pace_A();
+    case 2:  //VOO
+           pace_V();
+    }
+    return;
+}
+
+void PaceHeart::pace()
+{
+    int mode = get_p_pacingMode();
+    pace(mode);
+    return;
+}
--- a/PaceHeart.h	Mon Oct 24 01:11:37 2016 +0000
+++ b/PaceHeart.h	Wed Oct 26 21:17:17 2016 +0000
@@ -3,19 +3,52 @@
 
 #ifndef PACEHEART_H
 #define PACEHEART_H
-
+class PaceHeart{
+    
+    private:
+    int p_pacingState;
+    int p_pacingMode;
+    int p_hysteresis;
+    int p_hysteresisInterval;
+    int lowrateInterval;
+    int uprateInterval; //upper rate limit
+    //Ventricle
+    double p_vPaceAmp;
+    double p_vPaceWidth;
+    int p_VRP;
+    //Atrium (change defaults)
+    double p_aPaceAmp;
+    double p_aPaceWidth;
+    int p_ARP;
+    public:
+PaceHeart();
+void pace_A();
+void pace_A(double amp, double wid,int pin);
+void pace_V(double amp, double wid,int pin);
+void pace_V();
+void pace();
+void pace(int x);
 int get_p_pacingState();
 int get_p_pacingMode();
 int get_p_hysteresis();
 void set_p_hysteresis(int x);
-int get_p_hysterwaiaInterval();
-void set_p_hysterwaiaInterval(int x);
+int get_p_hysteresisInterval();
+void set_p_hysteresisInterval(int x);
 int get_lowrateInterval();
 void set_lowrateInterval(int x);
-double get_p_vPacwAmp();
-void set_p_vPacwAmp(double x);
+int get_uprateInterval();
+void set_uprateInterval(int x);
+double get_p_vPaceAmp();
+void set_p_vPaceAmp(double x);
 double get_p_vPaceWidth();
 void set_p_vPaceWidth(double x);
 int get_p_VRP();
 void set_p_VRP(int x);
+double get_p_aPaceAmp();
+void set_p_aPaceAmp(double x);
+double get_p_aPaceWidth();
+void set_p_aPaceWidth(double x);
+int get_p_ARP();
+void set_p_ARP(int x);
+};
 #endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/interface.cpp	Wed Oct 26 21:17:17 2016 +0000
@@ -0,0 +1,180 @@
+#include "PaceHeart.h"
+#include <string>
+#include <iostream>
+
+using namespace std;
+
+void interface(){
+    
+int initialize_settings = 1;
+while(initialize_settings ==1){
+
+
+    PaceHeart* Pace = new PaceHeart(); //change contents based on constructor
+int VA;
+
+
+cout << "Enter 1 for atrium, 2 for ventricle: " << endl;
+cin >> VA;
+
+
+if (VA == 2){
+    system ("CLS");
+    int waveform = 0;
+    cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl;
+    cin >> waveform;
+
+
+    if (waveform == 0){
+        continue;
+    }
+    else if (waveform == 1){
+    
+        //Make sure reference to PaceHeart is correct
+        double amplitude = Pace->get_p_vPaceAmp();
+        cout << "Current amplitude is: " << amplitude << " mV." << endl;
+
+
+        cout << "Set the amplitude for the ventricle in mV (or enter -1 to escape): " << endl;
+        cin >> amplitude;
+        if ((amplitude >= 500) && (amplitude <= 7000)) {
+            cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl;
+            Pace->set_p_vPaceAmp(amplitude);
+        }
+        else if (amplitude == -1) continue;
+        else {
+            cout << "Invalid input. Returning to main menu" << endl;
+            system("PAUSE"); //use these to prompt user to return
+
+        }
+    }
+    else if (waveform == 2){
+
+
+        //Make sure reference to PaceHeart is correct
+        int duration = Pace->get_p_VRP();
+        cout << "Current duration is: " << duration << "msec. " << endl;
+
+
+        cout << "Set the duration for the ventricle in msec (or enter -1 to escape): " << endl;
+        cin >> duration;
+        if ((duration >= 150) && (duration <= 500)) {
+            cout << "Valid input. Duration is now set to " << duration << "msec" << endl;
+            Pace->set_p_VRP(duration);
+        }
+        else if (duration == -1) continue;
+        else {
+            cout << "Invalid input. Returning to main menu" << endl;
+            system("PAUSE"); //use these to prompt user to return
+        }
+
+
+
+
+    }
+    else if (waveform == 3){
+        //Make sure reference to PaceHeart is correct
+        double width = Pace->get_p_vPaceWidth();
+        cout << "Current width is: " << width << "msec. " << endl;
+
+
+        cout << "Set the width for the ventricle in msec (or enter -1 to escape): " << endl;
+        cin >> width;
+        if ((width >= 0.1) && (width <= 1.9)) {
+            cout << "Valid input. Width is now set to " << width<< "msec" << endl;
+        Pace->set_p_vPaceWidth(width);
+        }
+        else if (width == -1) continue;
+        else {
+            cout << "Invalid input. Returning to main menu" << endl;
+            system("PAUSE"); //use these to prompt user to return
+        }
+
+
+    }
+
+
+}
+else if (VA == 1){
+    system ("CLS");
+    int waveform = 0;
+    cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl;
+    cin >> waveform;
+    
+    
+    if (waveform == 0){
+        continue;
+    }
+    else if (waveform == 1){
+        
+        //Make sure reference to PaceHeart is correct
+        int amplitude = Pace->get_p_aPaceAmp();
+        cout << "Current amplitude is: " << amplitude << " mV." << endl;
+    
+    
+        cout << "Set the amplitude for the atrium in mV (or enter -1 to escape): " << endl;
+        cin >> amplitude;
+        if ((amplitude >= 500) && (amplitude <= 7000)) {
+            cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl;
+            Pace->set_p_aPaceAmp(amplitude);
+        }
+        else if (amplitude == -1) continue;
+        else {
+            cout << "Invalid input. Returning to main menu" << endl;
+            system("PAUSE"); //use these to prompt user to return
+    
+    
+        }
+    }
+    else if (waveform == 2){
+    
+    
+        //Make sure reference to PaceHeart is correct
+        int duration = Pace->get_p_ARP();
+        cout << "Current duration is: " << duration << "msec. " << endl;
+    
+    
+        cout << "Set the duration for the atrium in msec (or enter -1 to escape): " << endl;
+        cin >> duration;
+        if ((duration >= 150) && (duration <= 500)) {
+            cout << "Valid input. Duration is now set to " << duration << "msec" << endl;
+            Pace->set_p_ARP(duration);
+        }
+        else if (duration == -1) continue;
+        else {
+            cout << "Invalid input. Returning to main menu" << endl;
+            system("PAUSE"); //use these to prompt user to return
+        }
+        
+        
+        
+        
+    }
+    else if (waveform == 3){
+        //Make sure reference to PaceHeart is correct
+        double width = Pace->get_p_aPaceWidth();
+        cout << "Current width is: " << width << "msec. " << endl;
+            
+            
+        cout << "Set the width for the atrium in msec (or enter -1 to escape): " << endl;
+        cin >> width;
+        if ((width >= 0.1) && (width <= 1.9)) {
+            cout << "Valid input. Width is now set to " << width<< "msec" << endl;
+            Pace->set_p_aPaceWidth(width);
+        }
+        else if (width == -1) continue;
+        else {
+            cout << "Invalid input. Returning to main menu" << endl;
+            system("PAUSE"); //use these to prompt user to return
+        }
+        
+        
+    }
+    //Checks if user wants to re-input settings
+    cout << "Do you want to change any values? (1 to re-input all settings, 0 to start PaceMaker)" << endl;
+    cin >> initialize_settings;
+    
+    
+    }
+    }
+}
\ No newline at end of file
--- a/main.cpp	Mon Oct 24 01:11:37 2016 +0000
+++ b/main.cpp	Wed Oct 26 21:17:17 2016 +0000
@@ -1,15 +1,16 @@
 #include "mbed.h"
 #include "PaceHeart.h"
 
-DigitalOut myled(LED1);
+//DigitalOut output_pin_A(LED1);
 
-
+PaceHeart* Pacer = new PaceHeart();
 
 int main() {
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+        
+        Pacer->pace_V();
+       
+        Pacer->pace_A();
+        
     }
 }
--- a/mbed.bld	Mon Oct 24 01:11:37 2016 +0000
+++ b/mbed.bld	Wed Oct 26 21:17:17 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e
+http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file