![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
working wavelet transform
Dependencies: CMSIS_DSP_5 include mbed
Fork of Nucleo-Heart-Rate by
Diff: main.cpp
- Revision:
- 5:182ee08ee2b0
- Parent:
- 3:e44f3e92cb34
- Parent:
- 4:8bd1cecf2a2e
- Child:
- 6:ce7f5faea04a
- Child:
- 7:b32f235c15f7
--- a/main.cpp Wed Jun 20 09:44:30 2018 +0000 +++ b/main.cpp Wed Jun 20 09:49:33 2018 +0000 @@ -7,60 +7,36 @@ #include "../header/wavelib.h" DigitalOut myled(LED1); -Serial usb_serial(SERIAL_TX, SERIAL_RX); // tx, rx -const int baud_rate = 115200; - // Baud rate. -//static float32_t cosSum[320]; -// -//float32_t *cosArray(int length, int freq, int fs){ -// float *p = (float *) malloc(sizeof(float) * length); -// double Ts = (double) 1/fs; -// double w = 2*PI*freq; -// -// for(int i = 0; i < length; i++){ -// p[i] = arm_cos_f32(w * Ts * i); -// } -// -// return p; -//} +DigitalOut myled2(LED2); + +Serial usb_serial(SERIAL_TX, SERIAL_RX); // tx, rx +const int baud_rate = 115200; // Baud rate. int main() { - usb_serial.baud(baud_rate); // Set serial USB connection baud rate (variable is declared in config part). + usb_serial.baud(baud_rate); + // Set serial USB connection baud rate (variable is declared in config part). + wave_object wave_init_obj; + wt_object wavelet; + + int N_samples = 3000; + int wt_scale = 3; + int fs = 160; + int i; + + double *inp = signal_in; //,*out,*diff; + + char *m_wavelet = "db4"; + wave_init_obj = wave_init(m_wavelet);// Initialize the wavelet - uint32_t N = 3000; - uint32_t fs = 160; -// uint32_t freq1 = 1; -// uint32_t freq2 = 12; -// float32_t *testCos1 = cosArray(N, freq1, fs); -// float32_t *testCos2 = cosArray(N, freq2, fs); - - wave_object obj; - wt_object wt; + wavelet = wt_init(wave_init_obj, "modwt", N_samples, wt_scale);// Initialize the wavelet transform object - double *inp; //,*out,*diff; - int i, J = 3; - - char *name = "db4"; - obj = wave_init(name);// Initialize the wavelet - - inp = signal_in; - //out = (double*)malloc(sizeof(double)* N); -// diff = (double*)malloc(sizeof(double)* N); - - myled = !myled; - - wt = wt_init(obj, "modwt", N, 3);// Initialize the wavelet transform object - myled = !myled; - - modwt(wt, inp);// Perform MODW + modwt(wavelet, inp);// Perform MODW while(1){ - for (i = 0; i < wt->outlength; ++i) { - usb_serial.printf("%d %e \n",i, wt->output[i]); + for (i = 0; i < wavelet->outlength; ++i) { + usb_serial.printf("%d %e \n",i, wavelet->output[i]); } myled = !myled; } -// setDWTExtension(wt, "sym");// Options are "per" and "sym". Symmetric is the default option -// setWTConv(wt, "direct"); }