fix fft
cast in high priority task was causing data issues + buffer overflow causing crazy issues
This commit is contained in:
parent
22a3b5e795
commit
d3abffa13d
1 changed files with 6 additions and 5 deletions
11
main.c
11
main.c
|
@ -187,10 +187,9 @@ void capture_waveform(UArg arg1, UArg arg2)
|
|||
|
||||
if (true) {
|
||||
adc_current_index = gADCBufferIndex;
|
||||
int32_t j = 0;
|
||||
for(i=adc_current_index-FFT_BUF_LEN; i<adc_current_index; i++) {
|
||||
//in[i].r = sinf(20*PI*i/FFT_BUF_LEN);
|
||||
in[i].r = (float) gADCBuffer[ADC_BUFFER_WRAP(adc_current_index + i)];
|
||||
in[i].i = 0;
|
||||
adc_buffer_fft_sample[j++] = gADCBuffer[ADC_BUFFER_WRAP(adc_current_index + i)];
|
||||
}
|
||||
} else {
|
||||
// single read of options is atomic
|
||||
|
@ -231,7 +230,9 @@ void process_waveform(UArg arg1, UArg arg2) {
|
|||
|
||||
if(true) { // fft
|
||||
for(i=0; i<FFT_BUF_LEN; i++) {
|
||||
in[i].r *= w[i];
|
||||
//in[i].r = sinf(20*PI*i/FFT_BUF_LEN);
|
||||
in[i].r = (float) adc_buffer_fft_sample[i] * w[i];
|
||||
in[i].i = 0;
|
||||
}
|
||||
|
||||
kiss_fft(cfg, in, out);
|
||||
|
@ -240,7 +241,7 @@ void process_waveform(UArg arg1, UArg arg2) {
|
|||
#define DB(out) 10 * log10f(out.r * out.r + out.i * out.i)
|
||||
|
||||
//adc_buffer_processed[i] = CONSTRAIN(HEIGHT- (int)roundf(0.5 * DB(out[i])));
|
||||
adc_buffer_processed[i] = CONSTRAIN(HEIGHT- (int) (DB(out[i])) + 64);
|
||||
adc_buffer_processed[i] = CONSTRAIN(HEIGHT- (int) (DB(out[i])) );
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue