shengtian zhou / Mbed 2 deprecated heart

Dependencies:   TextLCD mbed-rtos mbed

Fork of heart by William Archer

Files at this revision

API Documentation at this revision

Comitter:
williamrchr
Date:
Mon Nov 28 20:40:31 2016 +0000
Child:
1:6ad7b5bf9c27
Commit message:
first push;

Changed in this revision

TextLCD.lib 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-rtos.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Mon Nov 28 20:40:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 28 20:40:31 2016 +0000
@@ -0,0 +1,111 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "TextLCD.h"
+
+TextLCD lcd(p15,p16,p17,p18,p19,p20,TextLCD::LCD16x2);
+Serial pc(USBTX, USBRX); //set up serial
+DigitalOut natAPace(LED1); //leds for pacing
+DigitalOut natVPace(LED2);
+DigitalOut aPace(LED3);
+DigitalOut vPace(LED4);
+DigitalOut alarm(p5); //pin for alarm
+
+DigitalOut a_signal(p6); //connected to pm
+DigitalOut v_signal(p7); //connected to pm
+
+unsigned int a_time = 0;
+unsigned int v_time = 0;
+
+int mode = 0; //0 = random, 1 = manual, 2 = test
+
+//constants
+
+const int minwait_A = 10;
+const int minwait_V = 20;
+const int LRI = 1000;
+const int VRP = 400;
+const int PVARP = 500;
+const int URI = 1000;
+const int AVI = 100;
+
+void switch_modes() {
+    switch(mode) {
+        case 0:
+            break;
+        case 1:
+            break;
+        case 2:
+            break;
+        
+    }    
+
+}
+
+
+void received_apace() {
+    //TODO: DO 
+    aPace = 1;
+       
+}
+
+void received_vpace() {
+    //TODO: DO
+    vPace = 1;
+        
+}
+
+void send_signal(int type) { //type=0 a_signal, type=1 v_signal
+        
+        switch(type) {
+            case 0:
+                a_signal = 1;
+            case 1:
+                v_signal = 1;
+        }
+        //TODO: Determine if time is right (is this supposed to be minWait?)
+        wait(1); 
+        a_sense = 0;
+        v_sense = 0;
+}
+
+void heart_keyboard() {
+    while(true) { //thread is continuously running
+            if(pc.readable()) {
+                char c = pc.getc();
+                
+                switch(c) {
+                    case 'r': //set to random mode
+                        mode = 0;
+                        break;
+                    case 'm': //set to manual mode
+                        mode = 1;
+                        break;
+                    case 't': //set to test mode
+                        mode = 2;
+                        break;
+                    case 'a': //asignal
+                        if(mode) { //only if in manual (heart_mode == 1)
+                            send_signal(0);
+                        }
+                        break;
+                    case 'v': //vsignal
+                        if(mode) { //only if in manual (heart_mode == 1)
+                            send_signal(1);
+                        }
+                        break; 
+                    default: //erroneous key get rid of it
+                        break;
+                }
+            }
+    }
+}
+
+void tick() {
+    a_time++;
+    v_time++;   
+}
+
+int main() {
+    //TODO: Set up threads
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Nov 28 20:40:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 28 20:40:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file