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: mbed mbed-rtos TextLCD
main.cpp
- Committer:
- shibulal
- Date:
- 2015-11-26
- Revision:
- 1:e3a5388e46ab
- Parent:
- 0:2d6b43fc4625
- Child:
- 2:b178e27d9f22
File content as of revision 1:e3a5388e46ab:
#include "mbed.h"
#include "rtos.h"
Serial pc(USBTX, USBRX);
void PacemakerKeyboardInput(void const *args);
void PacemakerModes(void const *args);
int modeSwitchTimeInterval = 5000;
int flag=0;
const int sleepModeURI = 1000;
const int sleepModeLRI = 2000;
const int normalModeURI = 600;
const int normalModeLRI = 1500;
const int sportsModeURI = 343;
const int sportsModeLRI = 600;
const int manualModeURI = 343;
const int manualModeLRI = 2000;
int LRI = normalModeLRI;
int URI = normalModeURI;
Timer k;
char mode;
char manualPace;
Thread Pmki(PacemakerKeyboardInput,(void *) 0);
Thread Pmm(PacemakerModes,(void *) 0);
void PacemakerKeyboardInput(void const *args){
k.start();
char input;
while(true){
input=pc.getc();
if (k.read()>=modeSwitchTimeInterval && flag==0){
if (input=='F'){
mode='F';
Pmm.signal_set(0x1);
Thread::signal_wait(0x1);
}
else if (input=='S'){
mode='S';
Pmm.signal_set(0x1);
Thread::signal_wait(0x1);
}
else if (input=='N'){
mode='N';
Pmm.signal_set(0x1);
Thread::signal_wait(0x1);
}
else if (input=='O'){
mode='O';
Pmm.signal_set(0x1);
Thread::signal_wait(0x1);
}
else if (input=='M'){
mode='M';
Pmm.signal_set(0x1);
Thread::signal_wait(0x1);
}
else if (input=='A'){
if (mode=='M')
manualPace='A';
Pmm.signal_set(0x1);
Thread::signal_wait(0x1);
}
}
else if (input=='V'){
if (mode=='M'){
manualControl.lock();
manualPace='V';
Pmm.signal_set(0x1);
Thread::signal_wait(0x1);
}
}
}
}
}
void PacemakerModes(void const *args){
while(1){
Thread::signal_wait(0x1);
if (mode=='F'){
LRI=sportsModeLRI;
URI=sportsModeURI;
pmki.signal_set(0x1);
}
else if (mode=='S'){
LRI=sleepModeLRI;
URI=sleepModeURI;
pmki.signal_set(0x1);
}
else if (mode=='N'){
LRI=normalModeLRI;
URI=normalModeURI;
pmki.signal_set(0x1);
}
else if (mode=='O'){
//not sure what to do here
pmki.signal_set(0x1);
}
else if (mode=='M'){
LRI=manualModeLRI;
URI=manualModeURI;
pmki.signal_set(0x1);
while(1){
Thread::signal_wait(0x1);
if (mode=='M'){
if (manualPace=='A'){
// do stuff
manualPace='';
}
else if (manualPace=='V'){
//do stuff
manualPace='';
}
}
else {
pmm.signal_set(0x1);
pmki.signal_wait(0x1);
break;
}
pmki.signal_wait(0x1);
}
}
}
}
int main(){
while(1);
}