eric's fork test

Dependencies:   mbed-rtos mbed

Fork of Pacemaker by 3k04 team

Committer:
trane3
Date:
Mon Nov 14 02:22:40 2016 +0000
Revision:
7:4eb590c7e064
Parent:
2:fbba2687ddfe
Child:
8:75c1dd8b0d61
added voor modules and interface module destructors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
FiveDollar 0:b2b3955cd77b 1 #pragma once
FiveDollar 0:b2b3955cd77b 2 #include "mbed.h"
FiveDollar 0:b2b3955cd77b 3 #include "interface.h"
FiveDollar 0:b2b3955cd77b 4 #include "hardware.h"
FiveDollar 0:b2b3955cd77b 5 #include "chamberData.h"
FiveDollar 0:b2b3955cd77b 6 #include "genData.h"
FiveDollar 0:b2b3955cd77b 7 #include "pulse.h"
FiveDollar 0:b2b3955cd77b 8 #include <stdlib.h>
FiveDollar 0:b2b3955cd77b 9 #include <stdio.h>
FiveDollar 0:b2b3955cd77b 10 #include <string>
FiveDollar 0:b2b3955cd77b 11
FiveDollar 0:b2b3955cd77b 12 //CONSTRUCTORS*****************************
FiveDollar 0:b2b3955cd77b 13 interface::interface(){
FiveDollar 0:b2b3955cd77b 14 }
FiveDollar 0:b2b3955cd77b 15
trane3 7:4eb590c7e064 16 interface::~interface(){};
trane3 7:4eb590c7e064 17
FiveDollar 0:b2b3955cd77b 18 interface::interface(Serial* inputPC){
FiveDollar 0:b2b3955cd77b 19 pc = inputPC;
FiveDollar 0:b2b3955cd77b 20 }
FiveDollar 0:b2b3955cd77b 21
FiveDollar 0:b2b3955cd77b 22 interface::interface(Serial* inputPC , pulse* p , chamberData* atrium , chamberData* ventricle){
FiveDollar 0:b2b3955cd77b 23 pc = inputPC;
FiveDollar 0:b2b3955cd77b 24 interfacePulse = p;
FiveDollar 0:b2b3955cd77b 25 atrData = atrium;
FiveDollar 0:b2b3955cd77b 26 ventData = ventricle;
FiveDollar 0:b2b3955cd77b 27 startScreen();
FiveDollar 0:b2b3955cd77b 28 }
FiveDollar 0:b2b3955cd77b 29 //********************************************
FiveDollar 0:b2b3955cd77b 30
FiveDollar 0:b2b3955cd77b 31
FiveDollar 0:b2b3955cd77b 32 //USER INTERFACE SCREENS**************************
FiveDollar 0:b2b3955cd77b 33
FiveDollar 0:b2b3955cd77b 34 void interface::startScreen(){
FiveDollar 0:b2b3955cd77b 35 (*pc).printf("\nWelcome to the PACEMAKER DCM.\n");
FiveDollar 0:b2b3955cd77b 36 (*pc).printf("Options:\n");
FiveDollar 0:b2b3955cd77b 37 (*pc).printf("1. Start pulse\n");
FiveDollar 0:b2b3955cd77b 38 (*pc).printf("2. View/Change data\n");
FiveDollar 0:b2b3955cd77b 39 (*pc).printf("Please enter a command:");
FiveDollar 0:b2b3955cd77b 40 char command = getChar();
FiveDollar 0:b2b3955cd77b 41 switch (command) {
FiveDollar 0:b2b3955cd77b 42 case '1':
FiveDollar 0:b2b3955cd77b 43 interfacePulse->startPulse(); //problems with this method: you create the pc output twice, once in UI and once in pulse.
FiveDollar 0:b2b3955cd77b 44 startScreen(); //realistically we'll never need to call the serial output in pulse, it should all be done in UI
FiveDollar 0:b2b3955cd77b 45 break;
FiveDollar 0:b2b3955cd77b 46 case '2':
FiveDollar 0:b2b3955cd77b 47 interface::dataScreen();
FiveDollar 0:b2b3955cd77b 48 break;
FiveDollar 2:fbba2687ddfe 49 default:
FiveDollar 2:fbba2687ddfe 50 pc->printf("\nThat is not an option.");
FiveDollar 2:fbba2687ddfe 51 interface::startScreen();
FiveDollar 2:fbba2687ddfe 52 break;
FiveDollar 2:fbba2687ddfe 53 }
FiveDollar 0:b2b3955cd77b 54 }
FiveDollar 0:b2b3955cd77b 55
FiveDollar 0:b2b3955cd77b 56 void interface::dataScreen(){
FiveDollar 0:b2b3955cd77b 57 (*pc).printf("\nDCM Data sets:\n");
FiveDollar 2:fbba2687ddfe 58 (*pc).printf("1. Atrium Data\n2. Ventricle Data\n3. General Data\n4. Egram Data\n5. Back to start page\n");
FiveDollar 0:b2b3955cd77b 59 (*pc).printf("Choose a data set:");
FiveDollar 0:b2b3955cd77b 60 char command = getChar();
FiveDollar 0:b2b3955cd77b 61 switch (command) {
FiveDollar 0:b2b3955cd77b 62 case '1':
FiveDollar 2:fbba2687ddfe 63 pc->printf("\nAtrium Data");
FiveDollar 2:fbba2687ddfe 64 pc->printf("\n1. Pace Amplitude: %f", atrData->getPaceAmp()*7);
FiveDollar 0:b2b3955cd77b 65 pc->printf("\n2. Pace Width: %f", atrData->getPaceWidth());
FiveDollar 0:b2b3955cd77b 66 pc->printf("\n3. Refractory Period: %f", atrData->getRP());
FiveDollar 0:b2b3955cd77b 67 pc->printf("\n4. Sensitivity: %f", atrData->getSensitivity());
FiveDollar 0:b2b3955cd77b 68 pc->printf("\nChoose variable to be changed or 5 To return to Data Sets");
FiveDollar 0:b2b3955cd77b 69 interface::getData(atrData);
FiveDollar 0:b2b3955cd77b 70 break;
FiveDollar 0:b2b3955cd77b 71 case '2':
FiveDollar 2:fbba2687ddfe 72 pc->printf("\nVentricle Data");
FiveDollar 2:fbba2687ddfe 73 pc->printf("\n1. Pace Amplitude: %f", ventData->getPaceAmp()*7);
FiveDollar 0:b2b3955cd77b 74 pc->printf("\n2. Pace Width: %f", ventData->getPaceWidth());
FiveDollar 0:b2b3955cd77b 75 pc->printf("\n3. Refractory Period: %f", ventData->getRP());
FiveDollar 0:b2b3955cd77b 76 pc->printf("\n4. Sensitivity: %f", ventData->getSensitivity());
FiveDollar 0:b2b3955cd77b 77 pc->printf("\nChoose variable to be changed or 5 To return to Data Sets");
FiveDollar 0:b2b3955cd77b 78 interface::getData(ventData);
FiveDollar 0:b2b3955cd77b 79 break;
FiveDollar 0:b2b3955cd77b 80 case '3':
FiveDollar 2:fbba2687ddfe 81 pc->printf("\nGeneral Data");
FiveDollar 2:fbba2687ddfe 82 // pc->printf("\n1. Hysteresis: %f",
FiveDollar 2:fbba2687ddfe 83 case '4':
FiveDollar 2:fbba2687ddfe 84 pc->printf("\nNot setup yet");
FiveDollar 0:b2b3955cd77b 85 break;
FiveDollar 2:fbba2687ddfe 86 case '5':
FiveDollar 0:b2b3955cd77b 87 interface::startScreen();
FiveDollar 0:b2b3955cd77b 88 default:
FiveDollar 2:fbba2687ddfe 89 pc->printf("\nThat is not an option.");
FiveDollar 0:b2b3955cd77b 90 interface::dataScreen();
FiveDollar 0:b2b3955cd77b 91 }
FiveDollar 0:b2b3955cd77b 92 }
FiveDollar 0:b2b3955cd77b 93
FiveDollar 0:b2b3955cd77b 94 void interface::getData(chamberData* chamber){
FiveDollar 0:b2b3955cd77b 95 char command = getChar();
FiveDollar 0:b2b3955cd77b 96 switch (command){
FiveDollar 0:b2b3955cd77b 97 case '1':
FiveDollar 2:fbba2687ddfe 98 pc->printf("\nChoose New Value:");
FiveDollar 0:b2b3955cd77b 99 char* value = getInput();
FiveDollar 0:b2b3955cd77b 100 chamber->chngPaceAmp(atof(value));
FiveDollar 0:b2b3955cd77b 101 pc->printf("\t%f",chamber->getPaceAmp()*7);
FiveDollar 0:b2b3955cd77b 102 interface::dataScreen();
FiveDollar 0:b2b3955cd77b 103 break;
FiveDollar 0:b2b3955cd77b 104 case '2':
FiveDollar 2:fbba2687ddfe 105 pc->printf("\nChoose New Value:");
FiveDollar 0:b2b3955cd77b 106 value = getInput();
FiveDollar 0:b2b3955cd77b 107 chamber->chngPaceWidth(atof(value));
FiveDollar 0:b2b3955cd77b 108 pc->printf("\t%f",chamber->getPaceWidth());
FiveDollar 0:b2b3955cd77b 109 interface::dataScreen();
FiveDollar 0:b2b3955cd77b 110 break;
FiveDollar 0:b2b3955cd77b 111 case '3':
FiveDollar 2:fbba2687ddfe 112 pc->printf("\nChoose New Value:");
FiveDollar 0:b2b3955cd77b 113 value = getInput();
FiveDollar 0:b2b3955cd77b 114 chamber->chngRP(atof(value));
FiveDollar 0:b2b3955cd77b 115 pc->printf("\t%f",chamber->getRP());
FiveDollar 0:b2b3955cd77b 116 interface::dataScreen();
FiveDollar 0:b2b3955cd77b 117 break;
FiveDollar 0:b2b3955cd77b 118 case '4':
FiveDollar 2:fbba2687ddfe 119 pc->printf("\nChoose New Value:");
FiveDollar 0:b2b3955cd77b 120 value = getInput();
FiveDollar 0:b2b3955cd77b 121 chamber->chngSensitivity(atof(value));
FiveDollar 0:b2b3955cd77b 122 pc->printf("\t%f",chamber->getSensitivity());
FiveDollar 0:b2b3955cd77b 123 interface::dataScreen();
FiveDollar 0:b2b3955cd77b 124 break;
FiveDollar 0:b2b3955cd77b 125 case '5':
FiveDollar 0:b2b3955cd77b 126 interface::dataScreen();
FiveDollar 0:b2b3955cd77b 127 break;
FiveDollar 0:b2b3955cd77b 128 default:
FiveDollar 0:b2b3955cd77b 129 pc->printf("\nThat is not an option.");
FiveDollar 0:b2b3955cd77b 130 interface::getData(chamber);
FiveDollar 0:b2b3955cd77b 131 }
FiveDollar 0:b2b3955cd77b 132 }
FiveDollar 0:b2b3955cd77b 133
FiveDollar 0:b2b3955cd77b 134 char* interface::getInput(){
FiveDollar 0:b2b3955cd77b 135 char buffer[5];
FiveDollar 0:b2b3955cd77b 136 fgets (buffer,5,stdin);
FiveDollar 0:b2b3955cd77b 137 return buffer;
FiveDollar 0:b2b3955cd77b 138 }
FiveDollar 0:b2b3955cd77b 139
FiveDollar 0:b2b3955cd77b 140 char interface::getChar(){
FiveDollar 0:b2b3955cd77b 141 while(true){
FiveDollar 0:b2b3955cd77b 142 if(pc->readable()){
FiveDollar 0:b2b3955cd77b 143 char command = pc->getc();
FiveDollar 0:b2b3955cd77b 144 return command;
FiveDollar 0:b2b3955cd77b 145 }
FiveDollar 0:b2b3955cd77b 146 }
FiveDollar 0:b2b3955cd77b 147 }
FiveDollar 0:b2b3955cd77b 148 //****************************
FiveDollar 0:b2b3955cd77b 149
FiveDollar 0:b2b3955cd77b 150 //void interface::getAPulse(){ //TODO get this to work, the wait command has issues, see pulse.cpp . wait takes in seconds as argument
FiveDollar 0:b2b3955cd77b 151 // pulse myPulse(*atr);
FiveDollar 0:b2b3955cd77b 152 // myPulse.setWidth(1);
FiveDollar 0:b2b3955cd77b 153 // myPulse.startPulse();
FiveDollar 0:b2b3955cd77b 154 // }
FiveDollar 0:b2b3955cd77b 155
FiveDollar 0:b2b3955cd77b 156 //void interface::LEDon(AnalogOut* out){
FiveDollar 0:b2b3955cd77b 157 // (*out) = 0;
FiveDollar 0:b2b3955cd77b 158 //// (*pc).printf(led);
FiveDollar 0:b2b3955cd77b 159 //}
FiveDollar 0:b2b3955cd77b 160 //
FiveDollar 0:b2b3955cd77b 161 //void interface::LEDoff(AnalogOut* out){
FiveDollar 0:b2b3955cd77b 162 // (*out) = 1;
FiveDollar 0:b2b3955cd77b 163 //}