From 706a113459ef879d3f7dc640359092c3ea239210 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 11 Aug 2015 23:52:03 -0400 Subject: [PATCH] Functional waterfall speed control from 1->1024 lines per second --- src/AppFrame.cpp | 54 ++++++++++++++++++++++----- src/AppFrame.h | 4 +- src/CubicSDR.cpp | 2 +- src/CubicSDRDefs.h | 1 + src/panel/SpectrumPanel.cpp | 10 ++--- src/process/SpectrumVisualProcessor.h | 2 +- 6 files changed, 55 insertions(+), 18 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 5efd96d..e092ced 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -63,8 +63,6 @@ AppFrame::AppFrame() : demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band."); demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0); -// demodTray->AddSpacer(2); - wxGetApp().getDemodSpectrumProcesor()->setup(1024); demodSpectrumCanvas = new SpectrumCanvas(this, attribList); demodSpectrumCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000); @@ -114,24 +112,49 @@ AppFrame::AppFrame() : vbox->Add(demodTray, 12, wxEXPAND | wxALL, 0); vbox->AddSpacer(1); + wxBoxSizer *spectrumSizer = new wxBoxSizer(wxHORIZONTAL); wxGetApp().getSpectrumProcesor()->setup(2048); spectrumCanvas = new SpectrumCanvas(this, attribList); - vbox->Add(spectrumCanvas, 5, wxEXPAND | wxALL, 0); - vbox->AddSpacer(1); wxGetApp().getSpectrumProcesor()->attachOutput(spectrumCanvas->getVisualDataQueue()); + + spectrumAvgMeter = new MeterCanvas(this, attribList); + spectrumAvgMeter->setMax(3.0); + spectrumAvgMeter->setInputValue(1.0); + + spectrumSizer->Add(spectrumCanvas, 63, wxEXPAND | wxALL, 0); + spectrumSizer->AddSpacer(1); + spectrumSizer->Add(spectrumAvgMeter, 1, wxEXPAND | wxALL, 0); + + vbox->Add(spectrumSizer, 5, wxEXPAND | wxALL, 0); + + vbox->AddSpacer(1); + + wxBoxSizer *wfSizer = new wxBoxSizer(wxHORIZONTAL); wxGetApp().getWaterfallProcesor()->setup(2048); waterfallCanvas = new WaterfallCanvas(this, attribList); waterfallCanvas->setup(2048, 512); - waterfallCanvas->attachSpectrumCanvas(spectrumCanvas); - spectrumCanvas->attachWaterfallCanvas(waterfallCanvas); - vbox->Add(waterfallCanvas, 20, wxEXPAND | wxALL, 0); -// wxGetApp().getSpectrumProcesor()->attachOutput(waterfallCanvas->getVisualDataQueue()); + fftDistrib.setInput(wxGetApp().getWaterfallVisualQueue()); fftDistrib.attachOutput(&fftQueue); + wxGetApp().getWaterfallProcesor()->setInput(&fftQueue); wxGetApp().getWaterfallProcesor()->attachOutput(waterfallCanvas->getVisualDataQueue()); + waterfallSpeedMeter = new MeterCanvas(this, attribList); + waterfallSpeedMeter->setMax(sqrt(1024)); + waterfallSpeedMeter->setInputValue(sqrt(DEFAULT_WATERFALL_LPS)); + + wfSizer->Add(waterfallCanvas, 63, wxEXPAND | wxALL, 0); + wfSizer->AddSpacer(1); + wfSizer->Add(waterfallSpeedMeter, 1, wxEXPAND | wxALL, 0); + + vbox->Add(wfSizer, 20, wxEXPAND | wxALL, 0); + + // TODO: refactor these.. + waterfallCanvas->attachSpectrumCanvas(spectrumCanvas); + spectrumCanvas->attachWaterfallCanvas(waterfallCanvas); + /* vbox->AddSpacer(1); testCanvas = new UITestCanvas(this, attribList); @@ -722,8 +745,13 @@ void AppFrame::OnTimer(wxTimerEvent& event) { } else { fftDistrib.setFFTSize(DEFAULT_FFT_SIZE); } - fftDistrib.setLinesPerSecond(24); - wxGetApp().getWaterfallVisualQueue()->set_max_num_items(24); + + if (waterfallSpeedMeter->inputChanged()) { + int val = (int)waterfallSpeedMeter->getInputValue(); + fftDistrib.setLinesPerSecond((int)ceil(val*val)); + wxGetApp().getWaterfallVisualQueue()->set_max_num_items((int)ceil(val*val)); + } + fftDistrib.run(); wproc->setView(waterfallCanvas->getViewState()); @@ -752,6 +780,12 @@ void AppFrame::OnTimer(wxTimerEvent& event) { if (demodModeSelector->getMouseTracker()->mouseInView()) { demodModeSelector->Refresh(); } + if (waterfallSpeedMeter->getMouseTracker()->mouseInView()) { + waterfallSpeedMeter->Refresh(); + } + if (spectrumAvgMeter->getMouseTracker()->mouseInView()) { + spectrumAvgMeter->Refresh(); + } event.Skip(); } diff --git a/src/AppFrame.h b/src/AppFrame.h index 7397097..7194068 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -80,7 +80,9 @@ private: MeterCanvas *demodSignalMeter; MeterCanvas *demodGainMeter; TuningCanvas *demodTuner; - UITestCanvas *testCanvas; +// UITestCanvas *testCanvas; + MeterCanvas *spectrumAvgMeter; + MeterCanvas *waterfallSpeedMeter; DemodulatorInstance *activeDemodulator; diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index c6bbbe4..ca1eef3 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -64,7 +64,7 @@ bool CubicSDR::OnInit() { pipeSpectrumIQVisualData->set_max_num_items(1); pipeWaterfallIQVisualData = new DemodulatorThreadInputQueue(); - pipeWaterfallIQVisualData->set_max_num_items(512); + pipeWaterfallIQVisualData->set_max_num_items(DEFAULT_WATERFALL_LPS); spectrumDistributor.attachOutput(pipeDemodIQVisualData); spectrumDistributor.attachOutput(pipeSpectrumIQVisualData); diff --git a/src/CubicSDRDefs.h b/src/CubicSDRDefs.h index b9191d2..fb96a68 100644 --- a/src/CubicSDRDefs.h +++ b/src/CubicSDRDefs.h @@ -33,3 +33,4 @@ const char filePathSeparator = #define DEFAULT_DEMOD_TYPE 1 #define DEFAULT_DEMOD_BW 200000 +#define DEFAULT_WATERFALL_LPS 24 \ No newline at end of file diff --git a/src/panel/SpectrumPanel.cpp b/src/panel/SpectrumPanel.cpp index 99bf23c..81f62f6 100644 --- a/src/panel/SpectrumPanel.cpp +++ b/src/panel/SpectrumPanel.cpp @@ -113,16 +113,16 @@ void SpectrumPanel::drawPanelContents() { long double mhzStep = (100000.0 / (long double) (rightFreq - leftFreq)) * 2.0; double mhzVisualStep = 0.1f; - if (mhzStep * 0.5 * viewWidth > 400) { - mhzStep = (10000.0 / (long double) (rightFreq - leftFreq)) * 2.0; - mhzVisualStep = 0.01f; - } - if (mhzStep * 0.5 * viewWidth < 40) { mhzStep = (250000.0 / (long double) (rightFreq - leftFreq)) * 2.0; mhzVisualStep = 0.25f; } + if (mhzStep * 0.5 * viewWidth > 400) { + mhzStep = (10000.0 / (long double) (rightFreq - leftFreq)) * 2.0; + mhzVisualStep = 0.01f; + } + long double currentMhz = trunc(floor(firstMhz / 1000000.0)); std::stringstream label; diff --git a/src/process/SpectrumVisualProcessor.h b/src/process/SpectrumVisualProcessor.h index bcbca01..2ee8ba2 100644 --- a/src/process/SpectrumVisualProcessor.h +++ b/src/process/SpectrumVisualProcessor.h @@ -68,7 +68,7 @@ private: class FFTDataDistributor : public VisualProcessor { public: - FFTDataDistributor() : linesPerSecond(30), lineRateAccum(0.0) { + FFTDataDistributor() : linesPerSecond(DEFAULT_WATERFALL_LPS), lineRateAccum(0.0) { } void setFFTSize(int fftSize) {