working wavelet transform

Dependencies:   CMSIS_DSP_5 include mbed

Fork of Nucleo-Heart-Rate by BAP TUDelft

Committer:
xorjoep
Date:
Wed Jun 20 09:46:38 2018 +0000
Revision:
4:8bd1cecf2a2e
Parent:
2:3d6a6b9afee0
Child:
5:182ee08ee2b0
lel;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xorjoep 0:f39864a2bd26 1 //#include <math.h>
xorjoep 0:f39864a2bd26 2 #include "arm_common_tables.h"
xorjoep 0:f39864a2bd26 3 #include "arm_const_structs.h"
xorjoep 0:f39864a2bd26 4 #include "arm_math.h"
xorjoep 0:f39864a2bd26 5 #include "mbed.h"
xorjoep 2:3d6a6b9afee0 6 #include "vals.h"
xorjoep 0:f39864a2bd26 7 #include "../header/wavelib.h"
xorjoep 0:f39864a2bd26 8
xorjoep 0:f39864a2bd26 9 DigitalOut myled(LED1);
xorjoep 4:8bd1cecf2a2e 10 DigitalOut myled2(LED2);
xorjoep 0:f39864a2bd26 11
xorjoep 4:8bd1cecf2a2e 12 Serial usb_serial(SERIAL_TX, SERIAL_RX); // tx, rx
xorjoep 4:8bd1cecf2a2e 13 const int baud_rate = 115200; // Baud rate.
xorjoep 0:f39864a2bd26 14
xorjoep 0:f39864a2bd26 15 int main() {
xorjoep 4:8bd1cecf2a2e 16 usb_serial.baud(baud_rate);
xorjoep 4:8bd1cecf2a2e 17 // Set serial USB connection baud rate (variable is declared in config part).
xorjoep 4:8bd1cecf2a2e 18 wave_object wave_init_obj;
xorjoep 4:8bd1cecf2a2e 19 wt_object wavelet;
xorjoep 4:8bd1cecf2a2e 20
xorjoep 4:8bd1cecf2a2e 21 int N_samples = 2000;
xorjoep 4:8bd1cecf2a2e 22 int wt_scale = 3;
xorjoep 4:8bd1cecf2a2e 23 int i;
xorjoep 0:f39864a2bd26 24
xorjoep 4:8bd1cecf2a2e 25 double *inp = signal_in; //,*out,*diff;
xorjoep 0:f39864a2bd26 26
xorjoep 4:8bd1cecf2a2e 27 char *m_wavelet = "db4";
xorjoep 4:8bd1cecf2a2e 28 wave_init_obj = wave_init(m_wavelet);// Initialize the wavelet
xorjoep 0:f39864a2bd26 29
xorjoep 0:f39864a2bd26 30 //out = (double*)malloc(sizeof(double)* N);
xorjoep 0:f39864a2bd26 31
xorjoep 4:8bd1cecf2a2e 32 wavelet = wt_init(wave_init_obj, "modwt", N_samples, wt_scale);// Initialize the wavelet transform object
xorjoep 0:f39864a2bd26 33
xorjoep 4:8bd1cecf2a2e 34 modwt(wavelet, inp);// Perform MODW
xorjoep 0:f39864a2bd26 35
xorjoep 0:f39864a2bd26 36 while(1){
xorjoep 4:8bd1cecf2a2e 37 for (i = 0; i < wavelet->outlength; ++i) {
xorjoep 4:8bd1cecf2a2e 38 usb_serial.printf("%d %e \n",i, wavelet->output[i]);
xorjoep 0:f39864a2bd26 39 }
xorjoep 0:f39864a2bd26 40 myled = !myled;
xorjoep 0:f39864a2bd26 41 }
xorjoep 0:f39864a2bd26 42 }