From 16ca15bcfd58695c7982114904c80711bd9e81d3 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 4 Oct 2015 00:26:40 +0100 Subject: Fixed fft drawing in gui --- draw/glui.c | 8 ++++---- test/ui_gl_waterfall.c | 34 ++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/draw/glui.c b/draw/glui.c index fd27693..db9837a 100644 --- a/draw/glui.c +++ b/draw/glui.c @@ -1,7 +1,7 @@ #include "glui.h" #define DEFAULT_TITLE "RADIOLA" -#define SCREEN_X 640 +#define SCREEN_X 1024 #define SCREEN_Y 480 int glui_init( glui_t **t ) @@ -144,9 +144,9 @@ glui_color_t glui_waterfall_color( uint8_t d ) { glui_color_t c; - c.r = d; - c.g = d; - c.b = d; + c.r = d*10; + c.g = d*10; + c.b = d*10; return c; } diff --git a/test/ui_gl_waterfall.c b/test/ui_gl_waterfall.c index 3eb3f1f..3c19aca 100644 --- a/test/ui_gl_waterfall.c +++ b/test/ui_gl_waterfall.c @@ -11,7 +11,7 @@ #define CENTER_FREQ 446500000 #define FFT_LEVEL 10 #define FFT_SIZE (1 << FFT_LEVEL) -#define BUF_LENGHT (2 * FFT_SIZE) +#define SAMPLE_LENGHT (2 * FFT_SIZE) #define PRESCALE 8 #define POSTSCALE 2 @@ -105,12 +105,15 @@ int normalise( uint8_t *ibuf, int ilen, uint8_t *obuf, int olen ) int i,j,m; int ppi; + /* if ( ilen >= olen ) { ppi = ilen / olen; } else { return -1; } + */ + ppi = 1; m = 0; i = 0; while ( (i < ilen) && (m < olen) ) @@ -221,29 +224,31 @@ int simple_fft( uint8_t *buf, int len ) { int i,j; uint16_t p; + uint16_t buf1[SAMPLE_LENGHT]; + uint16_t buf2[SAMPLE_LENGHT]; int fft_len; for (i=0; iw; buf = malloc( buf_len ); - sample_len = BUF_LENGHT; + sample_len = SAMPLE_LENGHT; sample_buf = malloc( sample_len ); srand(0); //fake seed @@ -307,16 +313,16 @@ int main() sdr_get_samples( sample_buf, sample_len ); //do fft - simple_fft( sample_buf, sample_len/2 ); + simple_fft( sample_buf, sample_len ); //prepare to show on the screen - if (normalise( sample_buf, sample_len/2, buf, buf_len ) == -1) + //if (normalise( sample_buf, sample_len, buf, buf_len ) == -1) { - printf("Cannot normalise\n"); + //printf("Cannot normalise\n"); } - glui_waterfall_data( t, buf_len, buf ); + glui_waterfall_data( t, sample_len/2, sample_buf ); //printf("\n\b"); - usleep(100000); + usleep(10000); } main_exit: -- cgit v1.2.3