Pacemaker code Implementation for SFWRENG 3K04
Dependencies: mbed Queue mbed-rtos FXOS8700Q
Fork of Pacemaker by
SWFRENG 3K04 Project to design, develop, and document a functional pacemaker.
The project uses the Freescale K64F Microcontroller and C++ mbed library.
sense.cpp@34:701503855d52, 2016-12-13 (annotated)
- Committer:
- noahzwiep
- Date:
- Tue Dec 13 03:46:34 2016 +0000
- Revision:
- 34:701503855d52
- Parent:
- 5:253c33930e91
- Child:
- 36:b6431cd8ecd6
Added sense module, only thing left is figuring out pins
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
trane3 | 5:253c33930e91 | 1 | #pragma once |
trane3 | 5:253c33930e91 | 2 | #include "mbed.h" |
trane3 | 5:253c33930e91 | 3 | #include "sense.h" |
noahzwiep | 34:701503855d52 | 4 | #include "VVI.h" |
trane3 | 5:253c33930e91 | 5 | |
noahzwiep | 34:701503855d52 | 6 | sense::sense(genData* a){ |
noahzwiep | 34:701503855d52 | 7 | myGenData = a; |
noahzwiep | 34:701503855d52 | 8 | isSensed = false; |
trane3 | 5:253c33930e91 | 9 | } |
trane3 | 5:253c33930e91 | 10 | |
noahzwiep | 34:701503855d52 | 11 | sense::~sense(){}; |
noahzwiep | 34:701503855d52 | 12 | |
noahzwiep | 34:701503855d52 | 13 | bool sense::returnedSense(){ |
noahzwiep | 34:701503855d52 | 14 | timeout = false; |
noahzwiep | 34:701503855d52 | 15 | mbed::Timer t; |
noahzwiep | 34:701503855d52 | 16 | t.start(); |
noahzwiep | 34:701503855d52 | 17 | while(!timeout){ |
noahzwiep | 34:701503855d52 | 18 | //Here we check if we should still be sensing or if we should give up |
noahzwiep | 34:701503855d52 | 19 | if(myGenData->getHyst()){ //This is the case where hysteresis is enabled, we wait the lrl plus hysteresis |
noahzwiep | 34:701503855d52 | 20 | if(t.read_ms() >= (myGenData->getLRL()+myGenData->getHystRL())){ |
noahzwiep | 34:701503855d52 | 21 | timeout = true; |
noahzwiep | 34:701503855d52 | 22 | } |
noahzwiep | 34:701503855d52 | 23 | } |
noahzwiep | 34:701503855d52 | 24 | else{ //Here hysteresis isn't enabled, so its just waiting the LRL. |
noahzwiep | 34:701503855d52 | 25 | if(t.read_ms() >= myGenData->getLRL()){ |
noahzwiep | 34:701503855d52 | 26 | timeout = true; |
noahzwiep | 34:701503855d52 | 27 | } |
noahzwiep | 34:701503855d52 | 28 | } |
noahzwiep | 34:701503855d52 | 29 | //Here we have to check the pin and see if it is above threshold. |
noahzwiep | 34:701503855d52 | 30 | /* if(PINNAME.read() == 1){ |
noahzwiep | 34:701503855d52 | 31 | isSensed = true; |
noahzwiep | 34:701503855d52 | 32 | timeout = true; |
noahzwiep | 34:701503855d52 | 33 | }*/ |
noahzwiep | 34:701503855d52 | 34 | } |
noahzwiep | 34:701503855d52 | 35 | t.stop(); |
noahzwiep | 34:701503855d52 | 36 | return isSensed; |
noahzwiep | 34:701503855d52 | 37 | } |
noahzwiep | 34:701503855d52 | 38 | |
noahzwiep | 34:701503855d52 | 39 |