Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:9ff19f3965fb, 2010-09-25 (annotated)
- Committer:
- kasturir
- Date:
- Sat Sep 25 03:23:19 2010 +0000
- Revision:
- 0:9ff19f3965fb
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kasturir | 0:9ff19f3965fb | 1 | // Author: kasturir@ucla.edu (Kasturi Rangan Raghavan) |
| kasturir | 0:9ff19f3965fb | 2 | // \file |
| kasturir | 0:9ff19f3965fb | 3 | // QRSDet library for QRS delays |
| kasturir | 0:9ff19f3965fb | 4 | // Very naive and basic implementation to demonstrate |
| kasturir | 0:9ff19f3965fb | 5 | // QRS code ported from QRSDet. |
| kasturir | 0:9ff19f3965fb | 6 | // |
| kasturir | 0:9ff19f3965fb | 7 | // Note: |
| kasturir | 0:9ff19f3965fb | 8 | // Change both the wait_us and qrsdet::SAMPLE_RATE (in qrsdet-params.h) |
| kasturir | 0:9ff19f3965fb | 9 | // to adjust to different sampling rates. Currently set up for 125Hz |
| kasturir | 0:9ff19f3965fb | 10 | // Also, the offset/scale for reading ADC input may have to be adjusted |
| kasturir | 0:9ff19f3965fb | 11 | // |
| kasturir | 0:9ff19f3965fb | 12 | // Note2: |
| kasturir | 0:9ff19f3965fb | 13 | // Since function are not pure, local variables stored as static, |
| kasturir | 0:9ff19f3965fb | 14 | // That means the filter functions like deriv1, etc should be left alone. |
| kasturir | 0:9ff19f3965fb | 15 | |
| kasturir | 0:9ff19f3965fb | 16 | #include "mbed.h" |
| kasturir | 0:9ff19f3965fb | 17 | #include "qrsdet2-inl.h" |
| kasturir | 0:9ff19f3965fb | 18 | #include "qrsfilt-inl.h" |
| kasturir | 0:9ff19f3965fb | 19 | |
| kasturir | 0:9ff19f3965fb | 20 | DigitalOut peak(LED1); |
| kasturir | 0:9ff19f3965fb | 21 | DigitalOut time_out(LED4); |
| kasturir | 0:9ff19f3965fb | 22 | DigitalOut time_out1(p18); |
| kasturir | 0:9ff19f3965fb | 23 | PwmOut bridge_out(LED2); |
| kasturir | 0:9ff19f3965fb | 24 | |
| kasturir | 0:9ff19f3965fb | 25 | AnalogIn ecg_in(p20); |
| kasturir | 0:9ff19f3965fb | 26 | float float_val; |
| kasturir | 0:9ff19f3965fb | 27 | int int_val; |
| kasturir | 0:9ff19f3965fb | 28 | int delay; // return of QRSDet |
| kasturir | 0:9ff19f3965fb | 29 | int main() { |
| kasturir | 0:9ff19f3965fb | 30 | time_out = 1; |
| kasturir | 0:9ff19f3965fb | 31 | //qrsdet::QRSDet(0, 1); |
| kasturir | 0:9ff19f3965fb | 32 | qrsdet::deriv1(0, 1); |
| kasturir | 0:9ff19f3965fb | 33 | peak = 1; |
| kasturir | 0:9ff19f3965fb | 34 | while(1) { |
| kasturir | 0:9ff19f3965fb | 35 | float_val = ecg_in.read(); |
| kasturir | 0:9ff19f3965fb | 36 | int_val = float_val*128; |
| kasturir | 0:9ff19f3965fb | 37 | delay = qrsdet::QRSDet(int_val, 0); |
| kasturir | 0:9ff19f3965fb | 38 | if ( delay > 0) { |
| kasturir | 0:9ff19f3965fb | 39 | peak = !peak; |
| kasturir | 0:9ff19f3965fb | 40 | } |
| kasturir | 0:9ff19f3965fb | 41 | wait_us(8000); // 125Hz |
| kasturir | 0:9ff19f3965fb | 42 | bridge_out = float_val; |
| kasturir | 0:9ff19f3965fb | 43 | time_out = !time_out; |
| kasturir | 0:9ff19f3965fb | 44 | time_out1 = !time_out1; |
| kasturir | 0:9ff19f3965fb | 45 | } |
| kasturir | 0:9ff19f3965fb | 46 | } |