Pacemaker code Implementation for SFWRENG 3K04
Dependencies: FXOS8700Q Queue mbed-rtos mbed
Fork of Pacemaker by
chamberData.cpp@27:f8deff828a00, 2016-11-29 (annotated)
- Committer:
- FiveDollar
- Date:
- Tue Nov 29 19:41:38 2016 +0000
- Revision:
- 27:f8deff828a00
- Parent:
- 20:bfd23a6845bb
removed serial from chamberData
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 | 27:f8deff828a00 | 8 | chamberData::chamberData(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 | |
FiveDollar | 0:b2b3955cd77b | 15 | } |
FiveDollar | 0:b2b3955cd77b | 16 | char chamberData::getChamberType(){ |
FiveDollar | 0:b2b3955cd77b | 17 | return mychamber; |
FiveDollar | 0:b2b3955cd77b | 18 | } |
FiveDollar | 0:b2b3955cd77b | 19 | |
FiveDollar | 20:bfd23a6845bb | 20 | int chamberData::chngPaceAmp(double amp){ |
FiveDollar | 0:b2b3955cd77b | 21 | if(mychamber == 'a'){ |
FiveDollar | 0:b2b3955cd77b | 22 | if(amp>3.2 || amp<0.5){ |
FiveDollar | 20:bfd23a6845bb | 23 | return 0; |
FiveDollar | 20:bfd23a6845bb | 24 | }else{ |
FiveDollar | 20:bfd23a6845bb | 25 | p_PaceAmp = (amp-0)/(7-0); |
FiveDollar | 20:bfd23a6845bb | 26 | return 1; |
FiveDollar | 20:bfd23a6845bb | 27 | } |
FiveDollar | 0:b2b3955cd77b | 28 | }else{ |
FiveDollar | 0:b2b3955cd77b | 29 | if(amp>7 || amp<3.5){ |
FiveDollar | 20:bfd23a6845bb | 30 | return 0; |
FiveDollar | 20:bfd23a6845bb | 31 | }else{ |
FiveDollar | 20:bfd23a6845bb | 32 | p_PaceAmp = (amp-0)/(7-0); |
FiveDollar | 20:bfd23a6845bb | 33 | return 1; |
FiveDollar | 20:bfd23a6845bb | 34 | } |
FiveDollar | 0:b2b3955cd77b | 35 | } |
FiveDollar | 0:b2b3955cd77b | 36 | } |
FiveDollar | 0:b2b3955cd77b | 37 | |
FiveDollar | 0:b2b3955cd77b | 38 | double chamberData::getPaceAmp(){ |
FiveDollar | 0:b2b3955cd77b | 39 | return p_PaceAmp; |
FiveDollar | 0:b2b3955cd77b | 40 | } |
FiveDollar | 0:b2b3955cd77b | 41 | |
FiveDollar | 20:bfd23a6845bb | 42 | int chamberData::chngPaceWidth(double width){ |
FiveDollar | 0:b2b3955cd77b | 43 | if(mychamber == 'a'){ |
FiveDollar | 20:bfd23a6845bb | 44 | if(width!=0.05){ |
FiveDollar | 20:bfd23a6845bb | 45 | return 0; |
FiveDollar | 20:bfd23a6845bb | 46 | }else{ |
FiveDollar | 20:bfd23a6845bb | 47 | p_PaceWidth = width; |
FiveDollar | 20:bfd23a6845bb | 48 | return 1; |
FiveDollar | 20:bfd23a6845bb | 49 | } |
FiveDollar | 0:b2b3955cd77b | 50 | }else{ |
FiveDollar | 20:bfd23a6845bb | 51 | if(width>1.9 || width< 0.1){ |
FiveDollar | 20:bfd23a6845bb | 52 | return 0; |
FiveDollar | 20:bfd23a6845bb | 53 | }else{ |
FiveDollar | 20:bfd23a6845bb | 54 | p_PaceWidth = width; |
FiveDollar | 20:bfd23a6845bb | 55 | return 1; |
FiveDollar | 20:bfd23a6845bb | 56 | } |
FiveDollar | 0:b2b3955cd77b | 57 | } |
FiveDollar | 0:b2b3955cd77b | 58 | } |
FiveDollar | 0:b2b3955cd77b | 59 | |
FiveDollar | 0:b2b3955cd77b | 60 | double chamberData::getPaceWidth(){ |
FiveDollar | 0:b2b3955cd77b | 61 | return p_PaceWidth; |
FiveDollar | 0:b2b3955cd77b | 62 | } |
FiveDollar | 0:b2b3955cd77b | 63 | |
FiveDollar | 20:bfd23a6845bb | 64 | int chamberData::chngRP(double RP){ |
FiveDollar | 0:b2b3955cd77b | 65 | if(mychamber == 'a'){ |
FiveDollar | 20:bfd23a6845bb | 66 | if(RP>500 || RP<150){ |
FiveDollar | 20:bfd23a6845bb | 67 | return 0; |
FiveDollar | 20:bfd23a6845bb | 68 | }else{ |
FiveDollar | 20:bfd23a6845bb | 69 | p_RP = RP; |
FiveDollar | 20:bfd23a6845bb | 70 | return 1; |
FiveDollar | 20:bfd23a6845bb | 71 | } |
FiveDollar | 0:b2b3955cd77b | 72 | }else{ |
FiveDollar | 20:bfd23a6845bb | 73 | if(RP>500 || RP< 150){ |
FiveDollar | 20:bfd23a6845bb | 74 | return 0; |
FiveDollar | 20:bfd23a6845bb | 75 | }else{ |
FiveDollar | 20:bfd23a6845bb | 76 | p_RP = RP; |
FiveDollar | 20:bfd23a6845bb | 77 | return 1; |
FiveDollar | 20:bfd23a6845bb | 78 | } |
FiveDollar | 0:b2b3955cd77b | 79 | } |
FiveDollar | 0:b2b3955cd77b | 80 | } |
FiveDollar | 0:b2b3955cd77b | 81 | |
FiveDollar | 0:b2b3955cd77b | 82 | double chamberData::getRP(){ |
FiveDollar | 0:b2b3955cd77b | 83 | return p_RP; |
FiveDollar | 0:b2b3955cd77b | 84 | } |
FiveDollar | 0:b2b3955cd77b | 85 | |
FiveDollar | 20:bfd23a6845bb | 86 | int chamberData::chngSensitivity(double sensitivity){ |
FiveDollar | 0:b2b3955cd77b | 87 | if(mychamber == 'a'){ |
FiveDollar | 20:bfd23a6845bb | 88 | if(sensitivity!=0.05 || sensitivity!= 0.25 || sensitivity!=0.75){ |
FiveDollar | 20:bfd23a6845bb | 89 | return 0; |
FiveDollar | 20:bfd23a6845bb | 90 | }else{ |
FiveDollar | 20:bfd23a6845bb | 91 | p_Sensitivity = sensitivity; |
FiveDollar | 20:bfd23a6845bb | 92 | return 1; |
FiveDollar | 20:bfd23a6845bb | 93 | } |
FiveDollar | 0:b2b3955cd77b | 94 | }else{ |
FiveDollar | 20:bfd23a6845bb | 95 | if(sensitivity>10 || sensitivity< 1){ |
FiveDollar | 20:bfd23a6845bb | 96 | return 0; |
FiveDollar | 20:bfd23a6845bb | 97 | }else{ |
FiveDollar | 20:bfd23a6845bb | 98 | p_Sensitivity = sensitivity; |
FiveDollar | 20:bfd23a6845bb | 99 | return 1; |
FiveDollar | 20:bfd23a6845bb | 100 | } |
FiveDollar | 0:b2b3955cd77b | 101 | } |
FiveDollar | 0:b2b3955cd77b | 102 | } |
FiveDollar | 0:b2b3955cd77b | 103 | |
FiveDollar | 0:b2b3955cd77b | 104 | double chamberData::getSensitivity(){ |
FiveDollar | 0:b2b3955cd77b | 105 | return p_Sensitivity; |
FiveDollar | 0:b2b3955cd77b | 106 | } |
FiveDollar | 0:b2b3955cd77b | 107 | chamberData::~chamberData(){} |