Skip to content

Commit

Permalink
Spectrum Analyzer: Fix frequency axis scale label not showing MHz
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Sep 2, 2015
1 parent 99b3268 commit 0bc6779
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion oscplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ void osc_plot_update_rx_lbl(OscPlot *plot, bool force_update)
if (priv->redraw_function <= 0 && !force_update)
return;

if (priv->active_transform_type == FFT_TRANSFORM || priv->active_transform_type == COMPLEX_FFT_TRANSFORM) {
if (priv->active_transform_type == FFT_TRANSFORM ||
priv->active_transform_type == COMPLEX_FFT_TRANSFORM ||
priv->active_transform_type == FREQ_SPECTRUM_TRANSFORM) {

/* In FFT mode we need to scale the x-axis according to the selected sampling frequency */
for (i = 0; i < tr_list->size; i++)
Expand Down
14 changes: 13 additions & 1 deletion plugins/spectrum_analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,19 @@ static bool configure_data_capture(plugin_setup *setup)
dev_info = iio_device_get_data(cap);
dev_info->sample_count = setup->fft_size;
dev_info->adc_freq = device_get_rx_sampling_freq(cap);
if (HZ_TO_MHZ(dev_info->adc_freq) != sampling_rate) {
if (dev_info->adc_freq >= 1000000) {
dev_info->adc_scale = 'M';
dev_info->adc_freq /= 1000000.0;
} else if (dev_info->adc_freq >= 1000) {
dev_info->adc_scale = 'k';
dev_info->adc_freq /= 1000.0;
} else if (dev_info->adc_freq >= 0) {
dev_info->adc_scale = ' ';
} else {
dev_info->adc_scale = '?';
dev_info->adc_freq = 0.0;
}
if (dev_info->adc_freq != sampling_rate) {
fprintf(stderr, "Failed to set the rx sampling rate to %f"
"in %s\n", sampling_rate, __func__);
return false;
Expand Down

0 comments on commit 0bc6779

Please sign in to comment.