
heart for pacemaker
Dependencies: TextLCD mbed-rtos mbed
main.cpp
- Committer:
- williamrchr
- Date:
- 2016-11-30
- Revision:
- 1:82631d83e51e
- Parent:
- 0:08412491e70f
- Child:
- 2:2bae2020ac36
File content as of revision 1:82631d83e51e:
#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; //all in msec 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 random_mode() { if(a_time >= min_waitA) { send_signal(0); a_time = 0; } if(v_time >= min_waitV) { send_signal(1); v_time = 0; } } void switch_modes() { switch(mode) { case 0: //becomes random break; case 1: //becomes manual break; case 2: //becomes test 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; natAPace = 1; case 1: v_signal = 1; natVPace = 1; } wait(1); a_signal = 0; v_signal = 0; natAPace = 0; natVPace = 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 }