Dependencies: TextLCD mbed-rtos mbed
Fork of heart by
Diff: main.cpp
- Revision:
- 1:6ad7b5bf9c27
- Parent:
- 0:08412491e70f
- Child:
- 2:b4551e56cd1c
--- a/main.cpp Mon Nov 28 20:40:31 2016 +0000 +++ b/main.cpp Wed Nov 30 02:32:59 2016 +0000 @@ -1,6 +1,8 @@ #include "mbed.h" #include "rtos.h" #include "TextLCD.h" +#include <time.h> +#include <stdlib.h> TextLCD lcd(p15,p16,p17,p18,p19,p20,TextLCD::LCD16x2); Serial pc(USBTX, USBRX); //set up serial @@ -38,7 +40,6 @@ break; } - } @@ -64,8 +65,8 @@ } //TODO: Determine if time is right (is this supposed to be minWait?) wait(1); - a_sense = 0; - v_sense = 0; + //a_sense = 0; + //v_sense = 0; } void heart_keyboard() { @@ -104,8 +105,71 @@ a_time++; v_time++; } +// Blink functions gets called when there is an Atrial/V entricular event. +void natApaceBlink(){ + natAPace = 1; + Thread::wait(500); + natAPace = 0; + Thread::wait(500); +} + +void natVpaceBlink(){ + natVPace = 1; + Thread::wait(500); + natVPace = 0; + Thread::wait(500); +} + +void ApaceBlink(){ + aPace = 1; + Thread::wait(500); + aPace = 0; + Thread::wait(500); +} + +void VpaceBlink(){ + vPace = 1; + Thread::wait(500); + vPace = 0; + Thread::wait(500); +} + +void Random(){ + //TODO: heart behaviour in random mode + while(mode == 0){ + natApaceBlink(); + + } +} + +void Manual(){ + //TODO: heart behaviour in manual mode + while(mode == 1){ + natVpaceBlink(); + } +} + +void Test(){ + //TODO: heart behaviour in test mode + while(mode == 2){ + ApaceBlink(); + } +} + +void modeSwitchDelay(){ + srand(time(NULL)); + int time = rand()%9700 + 300; + Thread::wait(time); +} int main() { //TODO: Set up threads - + Thread keyboard(heart_keyboard); + //Note: only one of the following threads will be on duty when heart runs + //and it is done through checking the mode the heart is in. + Thread random(Random); + Thread manual(Manual); + Thread test(Test); + while(1){ + } }