1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-11-10 00:00:42 -05:00

GLSpectrum: added a freeze button

This commit is contained in:
f4exb 2020-07-05 10:03:41 +02:00
parent 3e6ea404e1
commit 3c7a39f71e
9 changed files with 67 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

View File

@ -43,11 +43,13 @@ MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureSpectrumVis, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureScalingFactor, Message) MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureScalingFactor, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureWSpectrumOpenClose, Message) MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureWSpectrumOpenClose, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureWSpectrum, Message) MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureWSpectrum, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgStartStop, Message)
const Real SpectrumVis::m_mult = (10.0f / log2f(10.0f)); const Real SpectrumVis::m_mult = (10.0f / log2f(10.0f));
SpectrumVis::SpectrumVis(Real scalef) : SpectrumVis::SpectrumVis(Real scalef) :
BasebandSampleSink(), BasebandSampleSink(),
m_running(true),
m_fft(nullptr), m_fft(nullptr),
m_fftEngineSequence(0), m_fftEngineSequence(0),
m_fftBuffer(MAX_FFT_SIZE), m_fftBuffer(MAX_FFT_SIZE),
@ -285,8 +287,11 @@ void SpectrumVis::feed(const Complex *begin, unsigned int length)
void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool positiveOnly) void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool positiveOnly)
{ {
// if no visualisation is set, send the samples to /dev/null if (!m_running) {
return;
}
// if no visualisation is set, send the samples to /dev/null
if (!m_glSpectrum && !m_wsSpectrum.socketOpened()) { if (!m_glSpectrum && !m_wsSpectrum.socketOpened()) {
return; return;
} }
@ -587,10 +592,12 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
void SpectrumVis::start() void SpectrumVis::start()
{ {
m_running = true;
} }
void SpectrumVis::stop() void SpectrumVis::stop()
{ {
m_running = false;
} }
bool SpectrumVis::handleMessage(const Message& message) bool SpectrumVis::handleMessage(const Message& message)
@ -629,6 +636,17 @@ bool SpectrumVis::handleMessage(const Message& message)
handleConfigureWSSpectrum(conf.getAddress(), conf.getPort()); handleConfigureWSSpectrum(conf.getAddress(), conf.getPort());
return true; return true;
} }
else if (MsgStartStop::match(message)) {
MsgStartStop& cmd = (MsgStartStop&) message;
if (cmd.getStartStop()) {
start();
} else {
stop();
}
return true;
}
else else
{ {
return false; return false;

View File

@ -88,6 +88,25 @@ public:
{} {}
}; };
class MsgStartStop : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getStartStop() const { return m_startStop; }
static MsgStartStop* create(bool startStop) {
return new MsgStartStop(startStop);
}
protected:
bool m_startStop;
MsgStartStop(bool startStop) :
Message(),
m_startStop(startStop)
{ }
};
enum AvgMode enum AvgMode
{ {
AvgModeNone, AvgModeNone,
@ -157,6 +176,7 @@ private:
uint16_t m_port; uint16_t m_port;
}; };
bool m_running;
FFTEngine* m_fft; FFTEngine* m_fft;
FFTWindow m_window; FFTWindow m_window;
unsigned int m_fftEngineSequence; unsigned int m_fftEngineSequence;

View File

@ -1988,6 +1988,8 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
if ((m_waterfallMarkers.size() > 0) && (pWat.x() >= 0) && (pWat.x() <= 1) && (pWat.y() >= 0) && (pWat.y() <= 1)) { if ((m_waterfallMarkers.size() > 0) && (pWat.x() >= 0) && (pWat.x() <= 1) && (pWat.y() >= 0) && (pWat.y() <= 1)) {
m_waterfallMarkers.pop_back(); m_waterfallMarkers.pop_back();
} }
update();
} }
else if (event->button() == Qt::LeftButton) else if (event->button() == Qt::LeftButton)
{ {
@ -2076,6 +2078,8 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
} }
} }
} }
update();
} }
if (m_cursorState == CSSplitter) if (m_cursorState == CSSplitter)

View File

@ -350,6 +350,12 @@ void GLSpectrumGUI::on_clearSpectrum_clicked(bool checked)
} }
} }
void GLSpectrumGUI::on_freeze_toggled(bool checked)
{
SpectrumVis::MsgStartStop *msg = SpectrumVis::MsgStartStop::create(!checked);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
int GLSpectrumGUI::getAveragingMaxScale(GLSpectrumSettings::AveragingMode averagingMode) int GLSpectrumGUI::getAveragingMaxScale(GLSpectrumSettings::AveragingMode averagingMode)
{ {
if (averagingMode == GLSpectrumSettings::AvgModeMoving) { if (averagingMode == GLSpectrumSettings::AvgModeMoving) {

View File

@ -103,6 +103,7 @@ private slots:
void on_invertWaterfall_toggled(bool checked); void on_invertWaterfall_toggled(bool checked);
void on_grid_toggled(bool checked); void on_grid_toggled(bool checked);
void on_clearSpectrum_clicked(bool checked); void on_clearSpectrum_clicked(bool checked);
void on_freeze_toggled(bool checked);
void handleInputMessages(); void handleInputMessages();
void openWebsocketSpectrumSettingsDialog(const QPoint& p); void openWebsocketSpectrumSettingsDialog(const QPoint& p);

View File

@ -312,24 +312,26 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_2"> <widget class="ButtonSwitch" name="freeze">
<property name="orientation"> <property name="toolTip">
<enum>Qt::Horizontal</enum> <string>Play/Pause spectrum display</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="icon">
<size> <iconset resource="../resources/res.qrc">
<width>40</width> <normaloff>:/pause.png</normaloff>
<height>20</height> <normalon>:/play.png</normalon>:/pause.png</iconset>
</size>
</property> </property>
</spacer> <property name="checkable">
<bool>true</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing"> <property name="spacing">
<number>2</number> <number>3</number>
</property> </property>
<item> <item>
<widget class="QComboBox" name="fftWindow"> <widget class="QComboBox" name="fftWindow">

View File

@ -453,7 +453,11 @@ Use this toggle button to switch between spectrum logarithmic and linear scale d
When in linear mode the range control (4.4) has no effect because the actual range is between 0 and the reference level. The reference level in dB (4.3) still applies but is translated to a linear value e.g -40 dB is 1e-4. In linear mode the scale numbers are formatted using scientific notation so that they always occupy the same space. When in linear mode the range control (4.4) has no effect because the actual range is between 0 and the reference level. The reference level in dB (4.3) still applies but is translated to a linear value e.g -40 dB is 1e-4. In linear mode the scale numbers are formatted using scientific notation so that they always occupy the same space.
<h4>4.K. Spectrum server control</h4> <h4>4.K. Spectrum live display pause/resume (freeze)</h4>
Use this control to pause or resume spectrum live display. You can use this control to freeze the spectrum display. This may be useful to make measurements using the markers (see section 7).
<h4>4.L. Spectrum server control</h4>
A websockets based server can be used to send spectrum data to clients. An example of such client can be found in the [SDRangelSpectrum](https://github.com/f4exb/sdrangelspectrum) project. A websockets based server can be used to send spectrum data to clients. An example of such client can be found in the [SDRangelSpectrum](https://github.com/f4exb/sdrangelspectrum) project.