Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TextLCD mbed-rtos mbed
Fork of mbed_PM by
main.cpp
- Committer:
- harry8989
- Date:
- 2015-12-01
- Revision:
- 1:e4a204ef28bc
- Parent:
- 0:093bb69f95f0
File content as of revision 1:e4a204ef28bc:
#include "mbed.h"
#include "rtos.h"
#include "TextLCD.h"
Serial keyboard(USBTX, USBRX);
int PacemakerA, PacemakerV = 0;
DigitalOut Apace(), Vpace();
DigitalIn Aget(), Vget();
int PacemakerModeGuard = 0;
void PacemakerSense() {
}
void PacemakerKeyboard() {
while(1) {
char c = keyboard.getc();
switch(c) {
case 'n':
case 'N':
PacemakerModeGuard = 0;
break;
case 's':
case 'S':
PacemakerModeGuard = 1;
break;
case 'e':
case 'E':
PacemakerModeGuard = 2;
break;
case 'm':
case 'M':
PacemakerModeGuard = 3;
break;
case 'a':
case 'A':
if(PacemakerModeGuard == 3) {
PacemakerA = 1;
Thread::wait(10);
PacemakerA = 0;
}
break;
case 'v':
case 'V':
}
}
}
Timer obsInt;
int observationInterval = 10; //observation interval in seconds
float vget_count = 0.; // A counter that increments every time a ventricular pulse has been detected
Semaphore heartBeat(1);
float DisplayMe;
void PacemakerDisplay() {
if (obsInt.read_ms()/1000 >= observationInterval) { //reporting interval exceeded
obsInt.stop();
heartBeat.wait(); //DONT LET ANY OTHER CODE RUN RIGHT NOW
DisplayMe = vget_count*(60/observationInterval);
lcd.printf("HR = %s\n", DisplayMe); // multiplies the number of counted Vgets by the number of observation periods in one minute,
PacemakerAlarm(DisplayMe);
vget_count = 0;
obsInt.reset();
heartBeat.release(); //OTHER CODE CAN RUN AGAIN
}
}
void PacemakerAlarm(int HeartRate) { //Takes the heart rate and returns an appropriate message; runs whenever display is updated
if HeartRate > LRI {
lcd.printf("HR TOO FAST\n");
} else if HeartRate < URI{
lcd.printf("HR TOO SLOW\n");
} else{
lcd.printf(" \n");
}
}
void PacemakerLED() {
}
int main() {
}
