reeeeeeeeeeeeeee

Dependencies:   MotionSensor mbed

Fork of Assignment2_ver3 by weeb grammers

Committer:
weebgrammers
Date:
Tue Nov 29 20:21:45 2016 +0000
Revision:
7:6dc42e1a2a81
Parent:
6:9b8fee13549c
s

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Judorunner 2:e2ae43e8acab 1 #include "PaceHeart.h"
oopakhooo 3:641eefd1110b 2 #include "mbed.h"
oopakhooo 3:641eefd1110b 3 #include "Hardware.h"
oopakhooo 3:641eefd1110b 4 using namespace std;
oopakhooo 3:641eefd1110b 5
oopakhooo 3:641eefd1110b 6
Judorunner 2:e2ae43e8acab 7
oopakhooo 3:641eefd1110b 8 PaceHeart::PaceHeart(){
weebgrammers 5:45d58f8a5912 9
oopakhooo 3:641eefd1110b 10 p_pacingState = 0;
oopakhooo 3:641eefd1110b 11 p_pacingMode = 0;
weebgrammers 7:6dc42e1a2a81 12 p_hysteresis = 0;
weebgrammers 7:6dc42e1a2a81 13 p_hysteresisInterval = 300;
weebgrammers 7:6dc42e1a2a81 14 p_lowrateInterval = 1000.0;
weebgrammers 7:6dc42e1a2a81 15 p_uprateInterval = 500.0; //upper rate limit
oopakhooo 3:641eefd1110b 16 //Ventricle
weebgrammers 7:6dc42e1a2a81 17 p_vPaceAmp = 3500.0;
weebgrammers 7:6dc42e1a2a81 18 p_vPaceWidth = 0.4;
weebgrammers 7:6dc42e1a2a81 19 p_VRP = 320;
oopakhooo 3:641eefd1110b 20 //Atrium (change defaults)
weebgrammers 7:6dc42e1a2a81 21 p_aPaceAmp = 3500.0;
weebgrammers 7:6dc42e1a2a81 22 p_aPaceWidth = 0.4;
weebgrammers 7:6dc42e1a2a81 23 p_ARP = 320;
oopakhooo 3:641eefd1110b 24 }
Judorunner 2:e2ae43e8acab 25
weebgrammers 5:45d58f8a5912 26 PaceHeart::PaceHeart(int mode){
weebgrammers 5:45d58f8a5912 27 p_pacingState = 0;
weebgrammers 5:45d58f8a5912 28 p_pacingMode = mode;
weebgrammers 7:6dc42e1a2a81 29 p_lowrateInterval = 1000.0; //30-50->5 50-90->1 90-175->5 ppm
weebgrammers 7:6dc42e1a2a81 30 p_uprateInterval = 2000.0; //upper rate limit 50-175->5 ppm
weebgrammers 7:6dc42e1a2a81 31 p_maxSensorRate = 2000.0; //50-175->5 ppm
weebgrammers 5:45d58f8a5912 32
weebgrammers 5:45d58f8a5912 33 //Ventricle
weebgrammers 7:6dc42e1a2a81 34 p_vPaceAmp = 3500.0; //3500->0.1
weebgrammers 7:6dc42e1a2a81 35 p_vPaceWidth = 0.4; //0.05->no change 0.1-1.9 0.1
weebgrammers 5:45d58f8a5912 36
weebgrammers 7:6dc42e1a2a81 37 p_activityThresh = 4; //1-7 print out string with level ie. Med
weebgrammers 7:6dc42e1a2a81 38 p_reactionTime = 30000; //10-50->10 seconds
weebgrammers 7:6dc42e1a2a81 39 p_responseFactor = 8; //1-16->1
weebgrammers 7:6dc42e1a2a81 40 p_recoveryTime = 300000; //2-16->1 minutes
weebgrammers 5:45d58f8a5912 41 }
oopakhooo 3:641eefd1110b 42 int PaceHeart::get_p_pacingState()
Judorunner 2:e2ae43e8acab 43 {
Judorunner 2:e2ae43e8acab 44 return p_pacingState;
Judorunner 2:e2ae43e8acab 45 }
weebgrammers 7:6dc42e1a2a81 46
weebgrammers 7:6dc42e1a2a81 47 void PaceHeart::set_p_pacingMode(int x)
weebgrammers 7:6dc42e1a2a81 48 {
weebgrammers 7:6dc42e1a2a81 49 p_pacingMode = x;
weebgrammers 7:6dc42e1a2a81 50 return;
weebgrammers 7:6dc42e1a2a81 51 }
weebgrammers 7:6dc42e1a2a81 52
weebgrammers 7:6dc42e1a2a81 53 int PaceHeart::get_p_pacingMode()//lets make it string in future
Judorunner 2:e2ae43e8acab 54 {
Judorunner 2:e2ae43e8acab 55 return p_pacingMode;
Judorunner 2:e2ae43e8acab 56 }
oopakhooo 3:641eefd1110b 57 int PaceHeart::get_p_hysteresis()
Judorunner 2:e2ae43e8acab 58 {
oopakhooo 3:641eefd1110b 59 return p_hysteresis;
Judorunner 2:e2ae43e8acab 60 }
oopakhooo 3:641eefd1110b 61 void PaceHeart::set_p_hysteresis(int x)
Judorunner 2:e2ae43e8acab 62 {
Judorunner 2:e2ae43e8acab 63 p_hysteresis = x;
Judorunner 2:e2ae43e8acab 64 return;
Judorunner 2:e2ae43e8acab 65 }
oopakhooo 3:641eefd1110b 66 int PaceHeart::get_p_hysteresisInterval()
Judorunner 2:e2ae43e8acab 67 {
oopakhooo 3:641eefd1110b 68 return p_hysteresisInterval;
Judorunner 2:e2ae43e8acab 69 }
oopakhooo 3:641eefd1110b 70 void PaceHeart::set_p_hysteresisInterval(int x)
Judorunner 2:e2ae43e8acab 71 {
oopakhooo 3:641eefd1110b 72 p_hysteresisInterval = x;
Judorunner 2:e2ae43e8acab 73 return;
Judorunner 2:e2ae43e8acab 74 }
Judorunner 6:9b8fee13549c 75 double PaceHeart::get_p_lowrateInterval()
Judorunner 2:e2ae43e8acab 76 {
Judorunner 6:9b8fee13549c 77 return p_lowrateInterval;
Judorunner 2:e2ae43e8acab 78 }
Judorunner 6:9b8fee13549c 79 void PaceHeart::set_p_lowrateInterval(double x)
Judorunner 2:e2ae43e8acab 80 {
weebgrammers 7:6dc42e1a2a81 81 if (p_pacingMode == 1) {
Judorunner 6:9b8fee13549c 82
weebgrammers 7:6dc42e1a2a81 83 if (dir ==1) // Change values to take into account for user inputs
weebgrammers 7:6dc42e1a2a81 84 {
weebgrammers 7:6dc42e1a2a81 85 if (p_lowrateInterval >=833.33 && p_lowrateInterval<=1483.33)
weebgrammers 7:6dc42e1a2a81 86 {
weebgrammers 7:6dc42e1a2a81 87 p_lowrateInterval += 16.67;
weebgrammers 7:6dc42e1a2a81 88 }
weebgrammers 7:6dc42e1a2a81 89 else if (p_lowrateInterval >2833.33)
weebgrammers 7:6dc42e1a2a81 90 {
weebgrammers 7:6dc42e1a2a81 91 return;
weebgrammers 7:6dc42e1a2a81 92 }
weebgrammers 7:6dc42e1a2a81 93 else
weebgrammers 7:6dc42e1a2a81 94 {
weebgrammers 7:6dc42e1a2a81 95 p_lowrateInterval += 83.33;
weebgrammers 7:6dc42e1a2a81 96 }
Judorunner 6:9b8fee13549c 97 }
weebgrammers 7:6dc42e1a2a81 98 else if (dir==0)
weebgrammers 7:6dc42e1a2a81 99 {
weebgrammers 7:6dc42e1a2a81 100 if (p_lowrateInterval >=850 && p_lowrateInterval<=1500)
weebgrammers 7:6dc42e1a2a81 101 {
weebgrammers 7:6dc42e1a2a81 102 p_lowrateInterval -= 16.67;
weebgrammers 7:6dc42e1a2a81 103 }
weebgrammers 7:6dc42e1a2a81 104 else if (p_lowrateInterval<583.33)
weebgrammers 7:6dc42e1a2a81 105 {
weebgrammers 7:6dc42e1a2a81 106 return;
weebgrammers 7:6dc42e1a2a81 107 }
weebgrammers 7:6dc42e1a2a81 108 else
weebgrammers 7:6dc42e1a2a81 109 {
weebgrammers 7:6dc42e1a2a81 110 p_lowrateInterval -= 83.33;
weebgrammers 7:6dc42e1a2a81 111 }
Judorunner 6:9b8fee13549c 112 }
Judorunner 6:9b8fee13549c 113 }
Judorunner 6:9b8fee13549c 114 else {
Judorunner 6:9b8fee13549c 115 p_lowrateInterval = x;
Judorunner 6:9b8fee13549c 116 }
Judorunner 2:e2ae43e8acab 117 return;
Judorunner 2:e2ae43e8acab 118 }
Judorunner 6:9b8fee13549c 119 double PaceHeart::get_p_uprateInterval()
Judorunner 2:e2ae43e8acab 120 {
Judorunner 6:9b8fee13549c 121 return p_uprateInterval;
Judorunner 2:e2ae43e8acab 122 }
Judorunner 6:9b8fee13549c 123 void PaceHeart::set_p_uprateInterval(double x)
Judorunner 2:e2ae43e8acab 124 {
weebgrammers 7:6dc42e1a2a81 125 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 126 if (dir ==1) // Change values to take into account for user inputs
weebgrammers 7:6dc42e1a2a81 127 {
weebgrammers 7:6dc42e1a2a81 128 if (p_uprateInterval >=833.33 && p_uprateInterval<=2833.33)
weebgrammers 7:6dc42e1a2a81 129 {
weebgrammers 7:6dc42e1a2a81 130 p_uprateInterval += 83.33;
weebgrammers 7:6dc42e1a2a81 131 }
weebgrammers 7:6dc42e1a2a81 132 else if (p_uprateInterval >2833.33)
weebgrammers 7:6dc42e1a2a81 133 {
weebgrammers 7:6dc42e1a2a81 134 return;
weebgrammers 7:6dc42e1a2a81 135 }
Judorunner 6:9b8fee13549c 136 }
weebgrammers 7:6dc42e1a2a81 137 else if (dir==0)
weebgrammers 7:6dc42e1a2a81 138 {
weebgrammers 7:6dc42e1a2a81 139 if (p_uprateInterval >=916.67 && p_uprateInterval<=2916.67)
weebgrammers 7:6dc42e1a2a81 140 {
weebgrammers 7:6dc42e1a2a81 141 p_uprateInterval -= 83.33;
weebgrammers 7:6dc42e1a2a81 142 }
weebgrammers 7:6dc42e1a2a81 143 else if (p_uprateInterval<916.67)
weebgrammers 7:6dc42e1a2a81 144 {
weebgrammers 7:6dc42e1a2a81 145 return;
weebgrammers 7:6dc42e1a2a81 146 }
Judorunner 6:9b8fee13549c 147 }
Judorunner 6:9b8fee13549c 148 }
Judorunner 6:9b8fee13549c 149 else {
Judorunner 6:9b8fee13549c 150 p_uprateInterval = x;
Judorunner 6:9b8fee13549c 151 }
Judorunner 6:9b8fee13549c 152 return;
Judorunner 6:9b8fee13549c 153 }
Judorunner 6:9b8fee13549c 154 double PaceHeart::get_p_maxSensorRate(){
weebgrammers 7:6dc42e1a2a81 155 return p_maxSensorRate;
Judorunner 6:9b8fee13549c 156 }
Judorunner 6:9b8fee13549c 157 void PaceHeart::set_p_maxSensorRate(double x)
Judorunner 6:9b8fee13549c 158 {
weebgrammers 7:6dc42e1a2a81 159 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 160 if (dir ==1) // Change values to take into account for user inputs
weebgrammers 7:6dc42e1a2a81 161 {
weebgrammers 7:6dc42e1a2a81 162 if (p_maxSensorRate >=833.33 && p_maxSensorRate<=2833.33)
weebgrammers 7:6dc42e1a2a81 163 {
weebgrammers 7:6dc42e1a2a81 164 p_maxSensorRate += 83.33;
weebgrammers 7:6dc42e1a2a81 165 }
weebgrammers 7:6dc42e1a2a81 166 else if (p_maxSensorRate >2833.33)
weebgrammers 7:6dc42e1a2a81 167 {
weebgrammers 7:6dc42e1a2a81 168 return;
weebgrammers 7:6dc42e1a2a81 169 }
Judorunner 6:9b8fee13549c 170 }
weebgrammers 7:6dc42e1a2a81 171 else if (dir==0)
weebgrammers 7:6dc42e1a2a81 172 {
weebgrammers 7:6dc42e1a2a81 173 if (p_maxSensorRate >=916.67 && p_maxSensorRate<=2916.67)
weebgrammers 7:6dc42e1a2a81 174 {
weebgrammers 7:6dc42e1a2a81 175 p_maxSensorRate -= 83.33;
weebgrammers 7:6dc42e1a2a81 176 }
weebgrammers 7:6dc42e1a2a81 177 else if (p_maxSensorRate<916.67)
weebgrammers 7:6dc42e1a2a81 178 {
weebgrammers 7:6dc42e1a2a81 179 return;
weebgrammers 7:6dc42e1a2a81 180 }
Judorunner 6:9b8fee13549c 181 }
Judorunner 6:9b8fee13549c 182 }
Judorunner 6:9b8fee13549c 183 else {
Judorunner 6:9b8fee13549c 184 p_maxSensorRate = x;
Judorunner 6:9b8fee13549c 185 }
Judorunner 2:e2ae43e8acab 186 return;
Judorunner 2:e2ae43e8acab 187 }
oopakhooo 3:641eefd1110b 188 //Ventricle
oopakhooo 3:641eefd1110b 189 double PaceHeart::get_p_vPaceAmp()
oopakhooo 3:641eefd1110b 190 {
oopakhooo 3:641eefd1110b 191 return p_vPaceAmp;
oopakhooo 3:641eefd1110b 192 }
oopakhooo 3:641eefd1110b 193 void PaceHeart::set_p_vPaceAmp(double x)
oopakhooo 3:641eefd1110b 194 {
weebgrammers 7:6dc42e1a2a81 195 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 196
weebgrammers 7:6dc42e1a2a81 197 if (dir ==1) // Change values to take into account for user inputs
weebgrammers 7:6dc42e1a2a81 198 {
weebgrammers 7:6dc42e1a2a81 199 if (p_vPaceAmp >=500 && p_vPaceAmp<=3100)
weebgrammers 7:6dc42e1a2a81 200 {
weebgrammers 7:6dc42e1a2a81 201 p_vPaceAmp += 100;
weebgrammers 7:6dc42e1a2a81 202 }
weebgrammers 7:6dc42e1a2a81 203 else if (p_vPaceAmp >= 3500 && p_vPaceAmp<=6500)
weebgrammers 7:6dc42e1a2a81 204 {
weebgrammers 7:6dc42e1a2a81 205 p_vPaceAmp += 500;
weebgrammers 7:6dc42e1a2a81 206 }
weebgrammers 7:6dc42e1a2a81 207 else
weebgrammers 7:6dc42e1a2a81 208 {
weebgrammers 7:6dc42e1a2a81 209 return;
weebgrammers 7:6dc42e1a2a81 210 }
weebgrammers 7:6dc42e1a2a81 211 }
weebgrammers 7:6dc42e1a2a81 212 else if (dir==0)
weebgrammers 7:6dc42e1a2a81 213 {
weebgrammers 7:6dc42e1a2a81 214 if (p_vPaceAmp >=600 && p_vPaceAmp<3200)
weebgrammers 7:6dc42e1a2a81 215 {
weebgrammers 7:6dc42e1a2a81 216 p_vPaceAmp -= 100;
weebgrammers 7:6dc42e1a2a81 217 }
weebgrammers 7:6dc42e1a2a81 218 else if (p_vPaceAmp >= 4000 && p_vPaceAmp<=7000)
weebgrammers 7:6dc42e1a2a81 219 {
weebgrammers 7:6dc42e1a2a81 220 p_vPaceAmp -= 500;
weebgrammers 7:6dc42e1a2a81 221 }
weebgrammers 7:6dc42e1a2a81 222 else
weebgrammers 7:6dc42e1a2a81 223 {
weebgrammers 7:6dc42e1a2a81 224 return;
weebgrammers 7:6dc42e1a2a81 225 }
weebgrammers 7:6dc42e1a2a81 226 }
weebgrammers 7:6dc42e1a2a81 227 }
weebgrammers 7:6dc42e1a2a81 228 else {
oopakhooo 3:641eefd1110b 229 p_vPaceAmp = x;
weebgrammers 7:6dc42e1a2a81 230 }
oopakhooo 3:641eefd1110b 231 return;
oopakhooo 3:641eefd1110b 232 }
oopakhooo 3:641eefd1110b 233
oopakhooo 3:641eefd1110b 234 double PaceHeart::get_p_vPaceWidth()
Judorunner 2:e2ae43e8acab 235 {
Judorunner 2:e2ae43e8acab 236 return p_vPaceWidth;
Judorunner 2:e2ae43e8acab 237 }
oopakhooo 3:641eefd1110b 238 void PaceHeart::set_p_vPaceWidth(double x)
Judorunner 2:e2ae43e8acab 239 {
weebgrammers 7:6dc42e1a2a81 240 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 241 if (p_vPaceWidth == 0.05) {
weebgrammers 7:6dc42e1a2a81 242 p_vPaceWidth = 0.4;
weebgrammers 7:6dc42e1a2a81 243 }
weebgrammers 7:6dc42e1a2a81 244 if (dir ==1){
weebgrammers 7:6dc42e1a2a81 245 if (p_vPaceWidth >= 0.1 && p_vPaceWidth <= 1.8){
weebgrammers 7:6dc42e1a2a81 246 p_vPaceWidth += 0.1;
weebgrammers 7:6dc42e1a2a81 247 }
weebgrammers 7:6dc42e1a2a81 248 else {
weebgrammers 7:6dc42e1a2a81 249 return;
weebgrammers 7:6dc42e1a2a81 250 }
weebgrammers 7:6dc42e1a2a81 251 }
weebgrammers 7:6dc42e1a2a81 252 else if (dir ==0) {
weebgrammers 7:6dc42e1a2a81 253 if (p_vPaceWidth >= 0.2 && p_vPaceWidth <= 1.9){
weebgrammers 7:6dc42e1a2a81 254 p_vPaceWidth -= 0.1;
weebgrammers 7:6dc42e1a2a81 255 }
weebgrammers 7:6dc42e1a2a81 256 else {
weebgrammers 7:6dc42e1a2a81 257 return;
weebgrammers 7:6dc42e1a2a81 258 }
weebgrammers 7:6dc42e1a2a81 259 }
weebgrammers 7:6dc42e1a2a81 260 }
weebgrammers 7:6dc42e1a2a81 261 else {
weebgrammers 7:6dc42e1a2a81 262 p_vPaceWidth = x;
weebgrammers 7:6dc42e1a2a81 263 }
Judorunner 2:e2ae43e8acab 264 return;
Judorunner 2:e2ae43e8acab 265 }
oopakhooo 3:641eefd1110b 266
oopakhooo 3:641eefd1110b 267 int PaceHeart::get_p_VRP()
Judorunner 2:e2ae43e8acab 268 {
Judorunner 2:e2ae43e8acab 269 return p_VRP;
Judorunner 2:e2ae43e8acab 270 }
oopakhooo 3:641eefd1110b 271 void PaceHeart::set_p_VRP(int x)
Judorunner 2:e2ae43e8acab 272 {
Judorunner 2:e2ae43e8acab 273 p_VRP = x;
Judorunner 2:e2ae43e8acab 274 return;
oopakhooo 3:641eefd1110b 275 }
oopakhooo 3:641eefd1110b 276 //Atrium
oopakhooo 3:641eefd1110b 277 double PaceHeart::get_p_aPaceAmp()
oopakhooo 3:641eefd1110b 278 {
oopakhooo 3:641eefd1110b 279 return p_aPaceAmp;
oopakhooo 3:641eefd1110b 280 }
oopakhooo 3:641eefd1110b 281 void PaceHeart::set_p_aPaceAmp(double x)
oopakhooo 3:641eefd1110b 282 {
oopakhooo 3:641eefd1110b 283 p_aPaceAmp = x;
oopakhooo 3:641eefd1110b 284 return;
oopakhooo 3:641eefd1110b 285 }
oopakhooo 3:641eefd1110b 286
oopakhooo 3:641eefd1110b 287 double PaceHeart::get_p_aPaceWidth()
oopakhooo 3:641eefd1110b 288 {
oopakhooo 3:641eefd1110b 289 return p_aPaceWidth;
oopakhooo 3:641eefd1110b 290 }
oopakhooo 3:641eefd1110b 291 void PaceHeart::set_p_aPaceWidth(double x)
oopakhooo 3:641eefd1110b 292 {
oopakhooo 3:641eefd1110b 293 p_aPaceWidth = x;
oopakhooo 3:641eefd1110b 294 return;
oopakhooo 3:641eefd1110b 295 }
oopakhooo 3:641eefd1110b 296
oopakhooo 3:641eefd1110b 297 int PaceHeart::get_p_ARP()
oopakhooo 3:641eefd1110b 298 {
oopakhooo 3:641eefd1110b 299 return p_ARP;
oopakhooo 3:641eefd1110b 300 }
oopakhooo 3:641eefd1110b 301 void PaceHeart::set_p_ARP(int x)
oopakhooo 3:641eefd1110b 302 {
oopakhooo 3:641eefd1110b 303 p_ARP = x;
oopakhooo 3:641eefd1110b 304 return;
oopakhooo 3:641eefd1110b 305 }
oopakhooo 3:641eefd1110b 306
oopakhooo 3:641eefd1110b 307
oopakhooo 3:641eefd1110b 308
weebgrammers 7:6dc42e1a2a81 309 void PaceHeart::pace_A(double amp, double wid)
oopakhooo 3:641eefd1110b 310 {
weebgrammers 7:6dc42e1a2a81 311 Output_A(amp,wid);
oopakhooo 3:641eefd1110b 312 return;
oopakhooo 3:641eefd1110b 313 }
oopakhooo 3:641eefd1110b 314
oopakhooo 3:641eefd1110b 315 void PaceHeart::pace_A()
oopakhooo 3:641eefd1110b 316 {
oopakhooo 3:641eefd1110b 317 double amplitude = get_p_aPaceAmp();
oopakhooo 3:641eefd1110b 318 double width = get_p_aPaceWidth();
weebgrammers 7:6dc42e1a2a81 319 pace_A(amplitude,width);
oopakhooo 3:641eefd1110b 320 return;
oopakhooo 3:641eefd1110b 321 }
oopakhooo 3:641eefd1110b 322
oopakhooo 3:641eefd1110b 323
weebgrammers 7:6dc42e1a2a81 324 void PaceHeart::pace_V(double amp, double wid)
oopakhooo 3:641eefd1110b 325 {
weebgrammers 7:6dc42e1a2a81 326 Output_V(amp,wid);
oopakhooo 3:641eefd1110b 327 return;
oopakhooo 3:641eefd1110b 328 }
oopakhooo 3:641eefd1110b 329
oopakhooo 3:641eefd1110b 330 void PaceHeart::pace_V()
oopakhooo 3:641eefd1110b 331 {
oopakhooo 3:641eefd1110b 332 double amplitude = get_p_vPaceAmp();
oopakhooo 3:641eefd1110b 333 double width = get_p_vPaceWidth();
weebgrammers 7:6dc42e1a2a81 334 pace_V(amplitude,width);
oopakhooo 3:641eefd1110b 335 return;
oopakhooo 3:641eefd1110b 336 }
oopakhooo 3:641eefd1110b 337
oopakhooo 3:641eefd1110b 338
oopakhooo 3:641eefd1110b 339 void PaceHeart::pace(int mode)
oopakhooo 3:641eefd1110b 340 {
oopakhooo 3:641eefd1110b 341 switch(mode){
weebgrammers 7:6dc42e1a2a81 342 case 1: //VOOR
weebgrammers 7:6dc42e1a2a81 343 pace_V();
weebgrammers 7:6dc42e1a2a81 344 case 0: //VOO
oopakhooo 3:641eefd1110b 345 pace_V();
oopakhooo 3:641eefd1110b 346 }
oopakhooo 3:641eefd1110b 347 return;
oopakhooo 3:641eefd1110b 348 }
oopakhooo 3:641eefd1110b 349
oopakhooo 3:641eefd1110b 350 void PaceHeart::pace()
oopakhooo 3:641eefd1110b 351 {
oopakhooo 3:641eefd1110b 352 int mode = get_p_pacingMode();
oopakhooo 3:641eefd1110b 353 pace(mode);
oopakhooo 3:641eefd1110b 354 return;
oopakhooo 3:641eefd1110b 355 }
Judorunner 6:9b8fee13549c 356 int PaceHeart::get_p_activityThresh()
weebgrammers 5:45d58f8a5912 357 {
weebgrammers 5:45d58f8a5912 358 return p_activityThresh;
weebgrammers 5:45d58f8a5912 359 }
Judorunner 6:9b8fee13549c 360 int PaceHeart::get_p_reactionTime()
weebgrammers 5:45d58f8a5912 361 {
weebgrammers 5:45d58f8a5912 362 return p_reactionTime;
weebgrammers 5:45d58f8a5912 363 }
Judorunner 6:9b8fee13549c 364 int PaceHeart::get_p_responseFactor()
weebgrammers 5:45d58f8a5912 365 {
weebgrammers 5:45d58f8a5912 366 return p_responseFactor;
weebgrammers 5:45d58f8a5912 367 }
Judorunner 6:9b8fee13549c 368 int PaceHeart::get_p_recoveryTime()
weebgrammers 5:45d58f8a5912 369 {
weebgrammers 5:45d58f8a5912 370 return p_recoveryTime;
weebgrammers 5:45d58f8a5912 371 }
Judorunner 6:9b8fee13549c 372 void PaceHeart::set_p_activityThresh(int x)
weebgrammers 5:45d58f8a5912 373 {
weebgrammers 7:6dc42e1a2a81 374 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 375 p_activityThresh=x; //no increment set at beginning
weebgrammers 7:6dc42e1a2a81 376 }
weebgrammers 7:6dc42e1a2a81 377 else {
weebgrammers 7:6dc42e1a2a81 378 p_activityThresh=x;
weebgrammers 7:6dc42e1a2a81 379 }
weebgrammers 5:45d58f8a5912 380 return;
weebgrammers 5:45d58f8a5912 381 }
Judorunner 6:9b8fee13549c 382 void PaceHeart::set_p_reactionTime(int x)
weebgrammers 5:45d58f8a5912 383 {
weebgrammers 7:6dc42e1a2a81 384 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 385
weebgrammers 7:6dc42e1a2a81 386 if (dir ==1){
weebgrammers 7:6dc42e1a2a81 387 if (p_reactionTime >= 10000 && p_reactionTime <= 40000) {
weebgrammers 7:6dc42e1a2a81 388 p_reactionTime += 10000;
weebgrammers 7:6dc42e1a2a81 389 }
weebgrammers 7:6dc42e1a2a81 390 else if (p_reactionTime >40000)
weebgrammers 7:6dc42e1a2a81 391 {
weebgrammers 7:6dc42e1a2a81 392 return;
weebgrammers 7:6dc42e1a2a81 393 }
weebgrammers 7:6dc42e1a2a81 394 }
weebgrammers 7:6dc42e1a2a81 395 else if (dir==0)
weebgrammers 7:6dc42e1a2a81 396 {
weebgrammers 7:6dc42e1a2a81 397 if (p_reactionTime >=20000 && p_reactionTime <=50000)
weebgrammers 7:6dc42e1a2a81 398 {
weebgrammers 7:6dc42e1a2a81 399 p_reactionTime -= 10000;
weebgrammers 7:6dc42e1a2a81 400 }
weebgrammers 7:6dc42e1a2a81 401 else if (p_reactionTime < 20000)
weebgrammers 7:6dc42e1a2a81 402 {
weebgrammers 7:6dc42e1a2a81 403 return;
weebgrammers 7:6dc42e1a2a81 404 }
weebgrammers 7:6dc42e1a2a81 405 }
weebgrammers 7:6dc42e1a2a81 406 }
weebgrammers 7:6dc42e1a2a81 407 else {
weebgrammers 7:6dc42e1a2a81 408 p_reactionTime = x;
weebgrammers 7:6dc42e1a2a81 409 }
weebgrammers 5:45d58f8a5912 410 return;
weebgrammers 5:45d58f8a5912 411 }
Judorunner 6:9b8fee13549c 412 void PaceHeart::set_p_responseFactor(int x)
weebgrammers 5:45d58f8a5912 413 {
weebgrammers 7:6dc42e1a2a81 414 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 415
weebgrammers 7:6dc42e1a2a81 416 if (dir ==1){
weebgrammers 7:6dc42e1a2a81 417 if (p_responseFactor >= 1 && p_responseFactor <= 15) {
weebgrammers 7:6dc42e1a2a81 418 p_responseFactor += 1;
weebgrammers 7:6dc42e1a2a81 419 }
weebgrammers 7:6dc42e1a2a81 420 else if (p_responseFactor >15)
weebgrammers 7:6dc42e1a2a81 421 {
weebgrammers 7:6dc42e1a2a81 422 return;
weebgrammers 7:6dc42e1a2a81 423 }
weebgrammers 7:6dc42e1a2a81 424 }
weebgrammers 7:6dc42e1a2a81 425 else if (dir==0)
weebgrammers 7:6dc42e1a2a81 426 {
weebgrammers 7:6dc42e1a2a81 427 if (p_responseFactor >=2 && p_responseFactor <=16)
weebgrammers 7:6dc42e1a2a81 428 {
weebgrammers 7:6dc42e1a2a81 429 p_responseFactor -= 1;
weebgrammers 7:6dc42e1a2a81 430 }
weebgrammers 7:6dc42e1a2a81 431 else if (p_responseFactor < 2)
weebgrammers 7:6dc42e1a2a81 432 {
weebgrammers 7:6dc42e1a2a81 433 return;
weebgrammers 7:6dc42e1a2a81 434 }
weebgrammers 7:6dc42e1a2a81 435 }
weebgrammers 7:6dc42e1a2a81 436 }
weebgrammers 7:6dc42e1a2a81 437 else {
weebgrammers 7:6dc42e1a2a81 438 p_responseFactor=x;
weebgrammers 7:6dc42e1a2a81 439 }
weebgrammers 5:45d58f8a5912 440 return;
weebgrammers 5:45d58f8a5912 441 }
Judorunner 6:9b8fee13549c 442 void PaceHeart::set_p_recoveryTime(int x)
weebgrammers 5:45d58f8a5912 443 {
weebgrammers 7:6dc42e1a2a81 444 if (p_pacingMode == 1) {
weebgrammers 7:6dc42e1a2a81 445
weebgrammers 7:6dc42e1a2a81 446 if (dir ==1){
weebgrammers 7:6dc42e1a2a81 447 if (p_recoveryTime >= 120000 && p_recoveryTime <= 900000) {
weebgrammers 7:6dc42e1a2a81 448 p_recoveryTime += 60000;
weebgrammers 7:6dc42e1a2a81 449 }
weebgrammers 7:6dc42e1a2a81 450 else if (p_recoveryTime >900000)
weebgrammers 7:6dc42e1a2a81 451 {
weebgrammers 7:6dc42e1a2a81 452 return;
weebgrammers 7:6dc42e1a2a81 453 }
weebgrammers 7:6dc42e1a2a81 454 }
weebgrammers 7:6dc42e1a2a81 455 else if (dir==0)
weebgrammers 7:6dc42e1a2a81 456 {
weebgrammers 7:6dc42e1a2a81 457 if (p_recoveryTime >=180000 && p_recoveryTime <=960000)
weebgrammers 7:6dc42e1a2a81 458 {
weebgrammers 7:6dc42e1a2a81 459 p_recoveryTime -= 60000;
weebgrammers 7:6dc42e1a2a81 460 }
weebgrammers 7:6dc42e1a2a81 461 else if (p_recoveryTime < 180000)
weebgrammers 7:6dc42e1a2a81 462 {
weebgrammers 7:6dc42e1a2a81 463 return;
weebgrammers 7:6dc42e1a2a81 464 }
weebgrammers 7:6dc42e1a2a81 465 }
weebgrammers 7:6dc42e1a2a81 466 }
weebgrammers 7:6dc42e1a2a81 467 else {
weebgrammers 7:6dc42e1a2a81 468 p_recoveryTime=x;
weebgrammers 7:6dc42e1a2a81 469 }
weebgrammers 7:6dc42e1a2a81 470 return;
weebgrammers 7:6dc42e1a2a81 471 }
weebgrammers 7:6dc42e1a2a81 472 void PaceHeart::set_dir(int x)
weebgrammers 7:6dc42e1a2a81 473 {
weebgrammers 7:6dc42e1a2a81 474 dir=x;
weebgrammers 5:45d58f8a5912 475 return;
weebgrammers 5:45d58f8a5912 476 }