Skip to content

Commit

Permalink
Osc: Allow plugins to revert a cross-correlation within a plot
Browse files Browse the repository at this point in the history
  • Loading branch information
dNechita committed Jun 5, 2014
1 parent f147951 commit 0295a81
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ struct _constellation_settings {

struct _cross_correlation_settings {
unsigned int num_samples;
int revert_xcorr;
fftw_complex *signal_a;
fftw_complex *signal_b;
fftw_complex *xcorr_data;
Expand Down
7 changes: 5 additions & 2 deletions osc.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void cross_correlation_transform_function(Transform *tr, gboolean init_transform
settings->signal_b[i] = q_1[i] + I * i_1[i];
}

if (revert_xcorr)
if (settings->revert_xcorr)
xcorr(settings->signal_b, settings->signal_a, settings->xcorr_data, axis_length);
else
xcorr(settings->signal_a, settings->signal_b, settings->xcorr_data, axis_length);
Expand Down Expand Up @@ -939,8 +939,11 @@ int plugin_data_capture_bytes_per_sample(const char *device)
return iio_device_get_sample_size(dev);
}

void plugin_data_capture_revert_xcorr(int revert)
void plugin_data_capture_revert_xcorr(OscPlot *plot, int revert)
{
if (!plot)
return;

revert_xcorr = revert;
}

Expand Down
4 changes: 1 addition & 3 deletions osc.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ enum marker_types plugin_get_plot_marker_type(OscPlot *plot, const char *device)
void plugin_set_plot_marker_type(OscPlot *plot, const char *device, enum marker_types type);
gdouble plugin_get_plot_fft_avg(OscPlot *plot, const char *device);
OscPlot * plugin_get_new_plot(void);

void plugin_data_capture_revert_xcorr(int);

void plugin_data_capture_revert_xcorr(OscPlot *, int);
void capture_profile_save(const char *filename);
void main_setup_before_ini_load(void);
void main_setup_after_ini_load(void);
Expand Down
13 changes: 13 additions & 0 deletions oscplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,18 @@ void osc_plot_set_channel_state(OscPlot *plot, const char *dev, int channel, boo
check_valid_setup(plot);
}

void osc_plot_xcorr_revert (OscPlot *plot, int revert)
{
TrList *tr_list = plot->priv->transform_list;
Transform *transform;
int i;

for (i = 0; i < tr_list->size; i++) {
transform = tr_list->transforms[i];
XCORR_SETTINGS(transform)->revert_xcorr = revert;
}
}

static void osc_plot_dispose(GObject *object)
{
G_OBJECT_CLASS(osc_plot_parent_class)->dispose(object);
Expand Down Expand Up @@ -820,6 +832,7 @@ static void update_transform_settings(OscPlot *plot, Transform *transform,
CONSTELLATION_SETTINGS(transform)->num_samples = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->sample_count_widget));
} else if (plot_type == XCORR_PLOT){
XCORR_SETTINGS(transform)->num_samples = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->sample_count_widget));
XCORR_SETTINGS(transform)->revert_xcorr = 0;
XCORR_SETTINGS(transform)->signal_a = NULL;
XCORR_SETTINGS(transform)->signal_b = NULL;
XCORR_SETTINGS(transform)->xcorr_data = NULL;
Expand Down
2 changes: 2 additions & 0 deletions oscplot.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ GMutex * osc_plot_get_marker_lock (OscPlot *plot);
bool osc_plot_set_sample_count (OscPlot *plot, int sample_count);
int osc_plot_get_sample_count (OscPlot *plot);
void osc_plot_set_channel_state(OscPlot *plot, const char *dev, int channel, bool state);
void osc_plot_xcorr_revert (OscPlot *plot, int revert);

G_END_DECLS

#endif /* __OSC_PLOT__ */

0 comments on commit 0295a81

Please sign in to comment.