Skip to content

Commit

Permalink
Spectrum Analyzer: Add the first working version
Browse files Browse the repository at this point in the history
Still work in progress.

Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Jul 1, 2015
1 parent a968ff3 commit 22e1eba
Show file tree
Hide file tree
Showing 10 changed files with 1,415 additions and 138 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CFLAGS := $(shell $(PKG_CONFIG) --cflags $(DEPENDENCIES)) \
-Wall -Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers \
-Wmissing-parameter-type -Wold-style-declaration -Woverride-init \
-Wsign-compare -Wtype-limits -Wuninitialized -Wunused-but-set-parameter \
-Werror -g -std=gnu90 -D_GNU_SOURCE -O2 -DPREFIX='"$(PREFIX)"' \
-Werror -g -std=gnu90 -D_GNU_SOURCE -ggdb -DPREFIX='"$(PREFIX)"' \
-DFRU_FILES=\"$(FRU_FILES)\" -DGIT_VERSION=\"$(GIT_VERSION)\" \
-DGIT_COMMIT_TIMESTAMP='"$(GIT_COMMIT_TIMESTAMP)"' \
-DOSC_VERSION=\"$(GIT_BRANCH)-g$(GIT_HASH)\" \
Expand Down Expand Up @@ -70,6 +70,7 @@ PLUGINS=\
plugins/motor_control.$(SO) \
plugins/dmm.$(SO) \
plugins/debug.$(SO) \
plugins/spectrum_analyzer.$(SO) \
$(if $(WITH_MINGW),,plugins/scpi.so)

ifdef V
Expand Down
6 changes: 3 additions & 3 deletions datatypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void Transform_attach_settings(Transform *tr, void *settings)
tr->settings = settings;
}

void Transform_attach_function(Transform *tr, void (*f)(Transform *tr , gboolean init_transform))
void Transform_attach_function(Transform *tr, bool (*f)(Transform *tr , gboolean init_transform))
{
tr->transform_function = f;
}
Expand All @@ -101,9 +101,9 @@ void Transform_setup(Transform *tr)
tr->transform_function(tr, TRUE);
}

void Transform_update_output(Transform *tr)
bool Transform_update_output(Transform *tr)
{
tr->transform_function(tr, FALSE);
return tr->transform_function(tr, FALSE);
}

TrList* TrList_new(void)
Expand Down
27 changes: 24 additions & 3 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum {
CONSTELLATION_TRANSFORM,
COMPLEX_FFT_TRANSFORM,
CROSS_CORRELATION_TRANSFORM,
FREQ_SPECTRUM_TRANSFORM,
TRANSFORMS_TYPES_COUNT
};

Expand Down Expand Up @@ -104,7 +105,7 @@ struct _transform {
GdkColor *graph_color;
bool has_the_marker;
void *settings;
void (*transform_function)(Transform *tr, gboolean init_transform);
bool (*transform_function)(Transform *tr, gboolean init_transform);
};

struct _tr_list {
Expand Down Expand Up @@ -160,16 +161,36 @@ struct _cross_correlation_settings {
enum marker_types *marker_type;
};

struct _freq_spectrum_settings {
gfloat *real_source;
gfloat *imag_source;
gfloat *freq_axis_source;
gfloat *magn_axis_source;
unsigned freq_axis_size;
unsigned magn_axis_size;
unsigned fft_index;
unsigned fft_count;
double freq_sweep_start;
double filter_bandwidth;
unsigned int fft_size;
unsigned int fft_avg;
gfloat fft_pwr_off;
unsigned fft_lower_clipping_limit;
unsigned fft_upper_clipping_limit;
struct _fft_alg_data *ffts_alg_data;
gfloat fft_corr;
};

Transform* Transform_new(int tr_type);
void Transform_destroy(Transform *tr);
void Transform_resize_x_axis(Transform *tr, int new_size);
void Transform_resize_y_axis(Transform *tr, int new_size);
gfloat* Transform_get_x_axis_ref(Transform *tr);
gfloat* Transform_get_y_axis_ref(Transform *tr);
void Transform_attach_settings(Transform *tr, void *settings);
void Transform_attach_function(Transform *tr, void (*f)(Transform *tr , gboolean init_transform));
void Transform_attach_function(Transform *tr, bool (*f)(Transform *tr , gboolean init_transform));
void Transform_setup(Transform *tr);
void Transform_update_output(Transform *tr);
bool Transform_update_output(Transform *tr);

TrList* TrList_new(void);
void TrList_destroy(TrList *list);
Expand Down
213 changes: 113 additions & 100 deletions fmcomms2.glade

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions osc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ enum marker_types {
#define FFT_PLOT 1
#define XY_PLOT 2
#define XCORR_PLOT 3
#define SPECTRUM_PLOT 4

#define USE_INTERN_SAMPLING_FREQ -1.0

Expand Down
Loading

0 comments on commit 22e1eba

Please sign in to comment.