a pacemaker

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kohlerba
Date:
Wed Oct 26 13:42:57 2016 +0000
Parent:
0:9e97accb2a4c
Child:
2:ab8469051a2d
Commit message:
blah;

Changed in this revision

clock.cpp Show annotated file Show diff for this revision Revisions of this file
clock.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
main.h Show annotated file Show diff for this revision Revisions of this file
pacing.c Show diff for this revision Revisions of this file
pacing.cpp Show annotated file Show diff for this revision Revisions of this file
pacing.h Show annotated file Show diff for this revision Revisions of this file
v_pacing.cpp Show annotated file Show diff for this revision Revisions of this file
v_pacing.h Show annotated file Show diff for this revision Revisions of this file
--- a/clock.cpp	Wed Oct 26 02:06:02 2016 +0000
+++ b/clock.cpp	Wed Oct 26 13:42:57 2016 +0000
@@ -3,8 +3,9 @@
 Ticker tick;
 double counter = 0;
 
-void start_clock(void){
+int start_clock(void){
     tick.attach(&count_time, 0.0001);
+    return 1;
     }
     
 void count_time(void){
@@ -14,4 +15,11 @@
 double get_time(void){
     return counter;
     }
+    
+int wait_time(double wait_time){
+    while (wait_time > 0){
+        wait_time--;
+        }
+    return 1;
+    }
     
\ No newline at end of file
--- a/clock.h	Wed Oct 26 02:06:02 2016 +0000
+++ b/clock.h	Wed Oct 26 13:42:57 2016 +0000
@@ -1,5 +1,13 @@
 #include "mbed.h"
 
-void start_clock(void);
+//Starts the clock
+int start_clock(void);
+
+//A counter that updates to the current time
 void count_time(void);
+
+//Returns the clock time
 double get_time(void);
+
+//wait a given amount of time
+int wait_time(double wait_time);
--- a/main.cpp	Wed Oct 26 02:06:02 2016 +0000
+++ b/main.cpp	Wed Oct 26 13:42:57 2016 +0000
@@ -1,28 +1,23 @@
-#include "clock.h"
-Serial pc(USBTX , USBRX);
+#include "main.h"
 
-//DigitalOut gpo(D0);
-//DigitalOut led(LED_RED);
-//
-//
-//Ticker tick;
-//
-//enum chamber {atrial = 'a', ventricle = 'v' , dual = 'd'};
-//
-//double counter;
-//    
-//int generate_sq_wave(int amp ,int freq);
-//void count_time(void);
-//
-//void count_time(void){
-//    counter += 0.0001;
-//    }
-//    
+Serial pc(USBTX , USBRX);
+DigitalOut led(LED_GREEN);
 int main()
 {
+    led = 0;
+    wait(3);
+    pc.printf("connecting...");
+    pc.printf("\n\n");
+    led = 1;
     start_clock();
     while (true) {
-        pc.printf("%2.4f" , get_time());
-        wait(0.5);
+        pc.printf("%d" , get_time());
+        pc.printf("\n");
+        led = 0;
+        v_pace_sq(5 , 0.08);
+        led = 1;
+        pc.printf("%d" , get_time());
+        pc.printf("\n");
+        wait(0.92);
     }
 }
\ No newline at end of file
--- a/main.h	Wed Oct 26 02:06:02 2016 +0000
+++ b/main.h	Wed Oct 26 13:42:57 2016 +0000
@@ -0,0 +1,2 @@
+#include "clock.h"
+#include "v_pacing.h"
\ No newline at end of file
--- a/pacing.c	Wed Oct 26 02:06:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#include "pacing.h"
-
-void write_to_pin(DigitalOut pinName , int to_write){
-        DigitalOut *pin = new DigitalOut(pinName);
-        pin = to_write;
-    }
-    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pacing.cpp	Wed Oct 26 13:42:57 2016 +0000
@@ -0,0 +1,6 @@
+#include "pacing.h"
+
+void write_to_pin(PinName pin , int to_write){
+        DigitalOut(pin , to_write);
+    }
+    
\ No newline at end of file
--- a/pacing.h	Wed Oct 26 02:06:02 2016 +0000
+++ b/pacing.h	Wed Oct 26 13:42:57 2016 +0000
@@ -1,3 +1,4 @@
 #include "clock.h"
+#include "assert.h"
 
 void write_to_pin(DigitalOut& pin ,int to_write);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/v_pacing.cpp	Wed Oct 26 13:42:57 2016 +0000
@@ -0,0 +1,22 @@
+#include "v_pacing.h"
+
+double v_pace = 0;
+
+double get_v_pace(void){
+    return v_pace;
+    }
+    
+int set_v_pace(double amp){
+    v_pace = amp;
+    return 1;
+    }
+    
+int v_pace_sq(double amp , double pulse_width){
+    assert (get_time() != 0);
+    double clock_freeze = get_time();
+    while((get_time() - clock_freeze) < pulse_width){
+        set_v_pace(amp);
+        }
+    v_pace = 0;
+    return 1;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/v_pacing.h	Wed Oct 26 13:42:57 2016 +0000
@@ -0,0 +1,7 @@
+#include "pacing.h"
+
+double get_v_pace(void);
+
+int set_v_pace(double amp);
+
+int v_pace_sq(double amp , double pulse_width);