![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
working wavelet transform
Dependencies: CMSIS_DSP_5 include mbed
Fork of Nucleo-Heart-Rate by
main.cpp@9:854f2d4eda4a, 2018-06-20 (annotated)
- Committer:
- MockyBirdTwo
- Date:
- Wed Jun 20 11:46:25 2018 +0000
- Revision:
- 9:854f2d4eda4a
- Parent:
- 7:b32f235c15f7
- Parent:
- 6:ce7f5faea04a
- Child:
- 10:f62efa525bb6
imodwt;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xorjoep | 0:f39864a2bd26 | 1 | #include "arm_common_tables.h" |
xorjoep | 0:f39864a2bd26 | 2 | #include "arm_const_structs.h" |
xorjoep | 0:f39864a2bd26 | 3 | #include "arm_math.h" |
xorjoep | 0:f39864a2bd26 | 4 | #include "mbed.h" |
xorjoep | 2:3d6a6b9afee0 | 5 | #include "vals.h" |
xorjoep | 0:f39864a2bd26 | 6 | #include "../header/wavelib.h" |
xorjoep | 0:f39864a2bd26 | 7 | |
xorjoep | 0:f39864a2bd26 | 8 | DigitalOut myled(LED1); |
xorjoep | 4:8bd1cecf2a2e | 9 | DigitalOut myled2(LED2); |
xorjoep | 0:f39864a2bd26 | 10 | |
xorjoep | 4:8bd1cecf2a2e | 11 | Serial usb_serial(SERIAL_TX, SERIAL_RX); // tx, rx |
xorjoep | 4:8bd1cecf2a2e | 12 | const int baud_rate = 115200; // Baud rate. |
xorjoep | 0:f39864a2bd26 | 13 | |
xorjoep | 0:f39864a2bd26 | 14 | int main() { |
xorjoep | 4:8bd1cecf2a2e | 15 | usb_serial.baud(baud_rate); |
xorjoep | 4:8bd1cecf2a2e | 16 | // Set serial USB connection baud rate (variable is declared in config part). |
xorjoep | 4:8bd1cecf2a2e | 17 | wave_object wave_init_obj; |
xorjoep | 4:8bd1cecf2a2e | 18 | wt_object wavelet; |
xorjoep | 4:8bd1cecf2a2e | 19 | |
xorjoep | 5:182ee08ee2b0 | 20 | int N_samples = 3000; |
xorjoep | 4:8bd1cecf2a2e | 21 | int wt_scale = 3; |
MockyBirdTwo | 9:854f2d4eda4a | 22 | // int fs = 160; |
MockyBirdTwo | 6:ce7f5faea04a | 23 | int i,j; |
xorjoep | 0:f39864a2bd26 | 24 | |
xorjoep | 4:8bd1cecf2a2e | 25 | double *inp = signal_in; //,*out,*diff; |
MockyBirdTwo | 9:854f2d4eda4a | 26 | double *out; |
xorjoep | 0:f39864a2bd26 | 27 | |
xorjoep | 4:8bd1cecf2a2e | 28 | char *m_wavelet = "db4"; |
xorjoep | 4:8bd1cecf2a2e | 29 | wave_init_obj = wave_init(m_wavelet);// Initialize the wavelet |
xorjoep | 0:f39864a2bd26 | 30 | |
xorjoep | 4:8bd1cecf2a2e | 31 | wavelet = wt_init(wave_init_obj, "modwt", N_samples, wt_scale);// Initialize the wavelet transform object |
xorjoep | 0:f39864a2bd26 | 32 | |
MockyBirdTwo | 6:ce7f5faea04a | 33 | int wt_scale_start=((wavelet->outlength)/wt_scale)*1; |
MockyBirdTwo | 6:ce7f5faea04a | 34 | int wt_scale_end=((wavelet->outlength)/wt_scale)*2; |
xorjoep | 4:8bd1cecf2a2e | 35 | modwt(wavelet, inp);// Perform MODW |
MockyBirdTwo | 6:ce7f5faea04a | 36 | |
MockyBirdTwo | 6:ce7f5faea04a | 37 | //Choose scales |
MockyBirdTwo | 6:ce7f5faea04a | 38 | for (i=0,j=wt_scale_start;j<wt_scale_end;i++,j++) { |
MockyBirdTwo | 9:854f2d4eda4a | 39 | wavelet[i]=wavelet[j]; |
MockyBirdTwo | 9:854f2d4eda4a | 40 | // wavelet.resize(6000); |
MockyBirdTwo | 6:ce7f5faea04a | 41 | } |
MockyBirdTwo | 9:854f2d4eda4a | 42 | imodwt(wavelet,out);// Perform IMODWT |
xorjoep | 0:f39864a2bd26 | 43 | |
xorjoep | 0:f39864a2bd26 | 44 | while(1){ |
xorjoep | 4:8bd1cecf2a2e | 45 | for (i = 0; i < wavelet->outlength; ++i) { |
xorjoep | 4:8bd1cecf2a2e | 46 | usb_serial.printf("%d %e \n",i, wavelet->output[i]); |
xorjoep | 0:f39864a2bd26 | 47 | } |
xorjoep | 0:f39864a2bd26 | 48 | myled = !myled; |
xorjoep | 0:f39864a2bd26 | 49 | } |
xorjoep | 0:f39864a2bd26 | 50 | } |