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.
Diff: motion.cpp
- Revision:
- 33:686a1a0c690f
- Parent:
- 21:fc6c33206152
- Child:
- 36:b6431cd8ecd6
diff -r 69cd1390bc21 -r 686a1a0c690f motion.cpp --- a/motion.cpp Tue Dec 06 20:57:56 2016 +0000 +++ b/motion.cpp Mon Dec 12 03:31:55 2016 +0000 @@ -7,13 +7,15 @@ FXOS8700Q_acc acc(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); -DigitalOut red(LED_RED); +//DigitalOut red(LED_RED); + /* Constants and Declares */ int numCount; chamberData* ventChamber; chamberData* atrChamber; int const MAX_NUM_COUNTS = 3; +int const MIN_NUM_COUNTS = 3; int const TIMING_PERIOD = 20; // Sensor polling interval uint8_t motion_exceeded_threshold = 0; @@ -50,12 +52,21 @@ if (numCount >= MAX_NUM_COUNTS) { ventChamber->chngPaceWidth(ventChamber->getPaceWidth() - 0.01); - red = !red; // toggle LEDs to show acceleration threshold reached + //red = !red; // toggle LEDs to show acceleration threshold reached motion_exceeded_threshold = 1; } } +void b_count(){ + numCount++; + + if (numCount >= MIN_NUM_COUNTS){ + ventChamber->chngPaceWidth(ventChamber->getPaceWidth() + 0.01); + //red = !red; + } +} + void motion_thread () { while(true) { @@ -69,6 +80,9 @@ a_count(); // increment acceleration event counter } + if (magtd < 1.0f){ + b_count(); Thread::wait(TIMING_PERIOD); + } } }