Pacemaker code Implementation for SFWRENG 3K04
Dependencies: FXOS8700Q Queue mbed-rtos mbed
Fork of Pacemaker by
chamberData.cpp@20:bfd23a6845bb, 2016-11-24 (annotated)
- Committer:
- FiveDollar
- Date:
- Thu Nov 24 03:26:14 2016 +0000
- Revision:
- 20:bfd23a6845bb
- Parent:
- 1:fbba2687ddfe
- Child:
- 27:f8deff828a00
All values can now be updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
FiveDollar | 0:b2b3955cd77b | 1 | #pragma once |
FiveDollar | 0:b2b3955cd77b | 2 | #include "mbed.h" |
FiveDollar | 0:b2b3955cd77b | 3 | #include "chamberData.h" |
FiveDollar | 0:b2b3955cd77b | 4 | |
FiveDollar | 0:b2b3955cd77b | 5 | chamberData::chamberData(){ |
FiveDollar | 0:b2b3955cd77b | 6 | } |
FiveDollar | 0:b2b3955cd77b | 7 | |
FiveDollar | 0:b2b3955cd77b | 8 | chamberData::chamberData(Serial* inputPC, char chamberType){ |
FiveDollar | 1:fbba2687ddfe | 9 | p_PaceAmp = 3.75; //decimal value between 0 and 1 which is a factor applied to 3.3V output. ie. 0.5 will give 0.5(3.3) V of output |
FiveDollar | 1:fbba2687ddfe | 10 | p_PaceWidth = 0.4; |
FiveDollar | 0:b2b3955cd77b | 11 | p_RP = 0; |
FiveDollar | 0:b2b3955cd77b | 12 | p_Sensitivity = 0; |
FiveDollar | 0:b2b3955cd77b | 13 | mychamber = chamberType; |
FiveDollar | 0:b2b3955cd77b | 14 | pc = inputPC; |
FiveDollar | 0:b2b3955cd77b | 15 | |
FiveDollar | 0:b2b3955cd77b | 16 | } |
FiveDollar | 0:b2b3955cd77b | 17 | char chamberData::getChamberType(){ |
FiveDollar | 0:b2b3955cd77b | 18 | return mychamber; |
FiveDollar | 0:b2b3955cd77b | 19 | } |
FiveDollar | 0:b2b3955cd77b | 20 | |
FiveDollar | 20:bfd23a6845bb | 21 | int chamberData::chngPaceAmp(double amp){ |
FiveDollar | 0:b2b3955cd77b | 22 | if(mychamber == 'a'){ |
FiveDollar | 0:b2b3955cd77b | 23 | if(amp>3.2 || amp<0.5){ |
FiveDollar | 20:bfd23a6845bb | 24 | return 0; |
FiveDollar | 20:bfd23a6845bb | 25 | }else{ |
FiveDollar | 20:bfd23a6845bb | 26 | p_PaceAmp = (amp-0)/(7-0); |
FiveDollar | 20:bfd23a6845bb | 27 | return 1; |
FiveDollar | 20:bfd23a6845bb | 28 | } |
FiveDollar | 0:b2b3955cd77b | 29 | }else{ |
FiveDollar | 0:b2b3955cd77b | 30 | if(amp>7 || amp<3.5){ |
FiveDollar | 20:bfd23a6845bb | 31 | return 0; |
FiveDollar | 20:bfd23a6845bb | 32 | }else{ |
FiveDollar | 20:bfd23a6845bb | 33 | p_PaceAmp = (amp-0)/(7-0); |
FiveDollar | 20:bfd23a6845bb | 34 | return 1; |
FiveDollar | 20:bfd23a6845bb | 35 | } |
FiveDollar | 0:b2b3955cd77b | 36 | } |
FiveDollar | 0:b2b3955cd77b | 37 | } |
FiveDollar | 0:b2b3955cd77b | 38 | |
FiveDollar | 0:b2b3955cd77b | 39 | double chamberData::getPaceAmp(){ |
FiveDollar | 0:b2b3955cd77b | 40 | return p_PaceAmp; |
FiveDollar | 0:b2b3955cd77b | 41 | } |
FiveDollar | 0:b2b3955cd77b | 42 | |
FiveDollar | 20:bfd23a6845bb | 43 | int chamberData::chngPaceWidth(double width){ |
FiveDollar | 0:b2b3955cd77b | 44 | if(mychamber == 'a'){ |
FiveDollar | 20:bfd23a6845bb | 45 | if(width!=0.05){ |
FiveDollar | 20:bfd23a6845bb | 46 | return 0; |
FiveDollar | 20:bfd23a6845bb | 47 | }else{ |
FiveDollar | 20:bfd23a6845bb | 48 | p_PaceWidth = width; |
FiveDollar | 20:bfd23a6845bb | 49 | return 1; |
FiveDollar | 20:bfd23a6845bb | 50 | } |
FiveDollar | 0:b2b3955cd77b | 51 | }else{ |
FiveDollar | 20:bfd23a6845bb | 52 | if(width>1.9 || width< 0.1){ |
FiveDollar | 20:bfd23a6845bb | 53 | return 0; |
FiveDollar | 20:bfd23a6845bb | 54 | }else{ |
FiveDollar | 20:bfd23a6845bb | 55 | p_PaceWidth = width; |
FiveDollar | 20:bfd23a6845bb | 56 | return 1; |
FiveDollar | 20:bfd23a6845bb | 57 | } |
FiveDollar | 0:b2b3955cd77b | 58 | } |
FiveDollar | 0:b2b3955cd77b | 59 | } |
FiveDollar | 0:b2b3955cd77b | 60 | |
FiveDollar | 0:b2b3955cd77b | 61 | double chamberData::getPaceWidth(){ |
FiveDollar | 0:b2b3955cd77b | 62 | return p_PaceWidth; |
FiveDollar | 0:b2b3955cd77b | 63 | } |
FiveDollar | 0:b2b3955cd77b | 64 | |
FiveDollar | 20:bfd23a6845bb | 65 | int chamberData::chngRP(double RP){ |
FiveDollar | 0:b2b3955cd77b | 66 | if(mychamber == 'a'){ |
FiveDollar | 20:bfd23a6845bb | 67 | if(RP>500 || RP<150){ |
FiveDollar | 20:bfd23a6845bb | 68 | return 0; |
FiveDollar | 20:bfd23a6845bb | 69 | }else{ |
FiveDollar | 20:bfd23a6845bb | 70 | p_RP = RP; |
FiveDollar | 20:bfd23a6845bb | 71 | return 1; |
FiveDollar | 20:bfd23a6845bb | 72 | } |
FiveDollar | 0:b2b3955cd77b | 73 | }else{ |
FiveDollar | 20:bfd23a6845bb | 74 | if(RP>500 || RP< 150){ |
FiveDollar | 20:bfd23a6845bb | 75 | return 0; |
FiveDollar | 20:bfd23a6845bb | 76 | }else{ |
FiveDollar | 20:bfd23a6845bb | 77 | p_RP = RP; |
FiveDollar | 20:bfd23a6845bb | 78 | return 1; |
FiveDollar | 20:bfd23a6845bb | 79 | } |
FiveDollar | 0:b2b3955cd77b | 80 | } |
FiveDollar | 0:b2b3955cd77b | 81 | } |
FiveDollar | 0:b2b3955cd77b | 82 | |
FiveDollar | 0:b2b3955cd77b | 83 | double chamberData::getRP(){ |
FiveDollar | 0:b2b3955cd77b | 84 | return p_RP; |
FiveDollar | 0:b2b3955cd77b | 85 | } |
FiveDollar | 0:b2b3955cd77b | 86 | |
FiveDollar | 20:bfd23a6845bb | 87 | int chamberData::chngSensitivity(double sensitivity){ |
FiveDollar | 0:b2b3955cd77b | 88 | if(mychamber == 'a'){ |
FiveDollar | 20:bfd23a6845bb | 89 | if(sensitivity!=0.05 || sensitivity!= 0.25 || sensitivity!=0.75){ |
FiveDollar | 20:bfd23a6845bb | 90 | return 0; |
FiveDollar | 20:bfd23a6845bb | 91 | }else{ |
FiveDollar | 20:bfd23a6845bb | 92 | p_Sensitivity = sensitivity; |
FiveDollar | 20:bfd23a6845bb | 93 | return 1; |
FiveDollar | 20:bfd23a6845bb | 94 | } |
FiveDollar | 0:b2b3955cd77b | 95 | }else{ |
FiveDollar | 20:bfd23a6845bb | 96 | if(sensitivity>10 || sensitivity< 1){ |
FiveDollar | 20:bfd23a6845bb | 97 | return 0; |
FiveDollar | 20:bfd23a6845bb | 98 | }else{ |
FiveDollar | 20:bfd23a6845bb | 99 | p_Sensitivity = sensitivity; |
FiveDollar | 20:bfd23a6845bb | 100 | return 1; |
FiveDollar | 20:bfd23a6845bb | 101 | } |
FiveDollar | 0:b2b3955cd77b | 102 | } |
FiveDollar | 0:b2b3955cd77b | 103 | } |
FiveDollar | 0:b2b3955cd77b | 104 | |
FiveDollar | 0:b2b3955cd77b | 105 | double chamberData::getSensitivity(){ |
FiveDollar | 0:b2b3955cd77b | 106 | return p_Sensitivity; |
FiveDollar | 0:b2b3955cd77b | 107 | } |
FiveDollar | 0:b2b3955cd77b | 108 | chamberData::~chamberData(){} |