From fa9dfc2fb4308444788a25d68c8a4c1615100c1a Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Fri, 3 Jun 2016 20:05:38 -0400 Subject: [PATCH] Rough visual cue for demod instances, implement squelch break indicator --- src/demod/DemodulatorInstance.cpp | 29 +++++++++++++++++++++++++++++ src/demod/DemodulatorInstance.h | 17 +++++++++++++++++ src/demod/DemodulatorThread.cpp | 1 + src/visual/WaterfallCanvas.cpp | 10 ++++++++++ 4 files changed, 57 insertions(+) diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index 867f921..e1e6860 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -5,6 +5,31 @@ #include "RigThread.h" #endif +DemodVisualCue::DemodVisualCue() { + squelchBreak.store(false); +} + +DemodVisualCue::~DemodVisualCue() { + +} + +void DemodVisualCue::triggerSquelchBreak(int counter) { + squelchBreak.store(counter); +} + +int DemodVisualCue::getSquelchBreak() { + return squelchBreak.load(); +} + +void DemodVisualCue::step() { + if (squelchBreak.load()) { + squelchBreak--; + if (squelchBreak.load() < 0) { + squelchBreak.store(0); + } + } +} + DemodulatorInstance::DemodulatorInstance() : t_PreDemod(nullptr), t_Demod(nullptr), t_Audio(nullptr) { @@ -418,6 +443,10 @@ void DemodulatorInstance::setMuted(bool muted) { wxGetApp().getDemodMgr().setLastMuted(muted); } +DemodVisualCue *DemodulatorInstance::getVisualCue() { + return &visualCue; +} + DemodulatorThreadInputQueue *DemodulatorInstance::getIQInputDataPipe() { return pipeIQInputData; } diff --git a/src/demod/DemodulatorInstance.h b/src/demod/DemodulatorInstance.h index 18c5362..b5532ae 100644 --- a/src/demod/DemodulatorInstance.h +++ b/src/demod/DemodulatorInstance.h @@ -14,6 +14,20 @@ #include "DigitalConsole.h" #endif +class DemodVisualCue { +public: + DemodVisualCue(); + ~DemodVisualCue(); + + void triggerSquelchBreak(int counter); + int getSquelchBreak(); + + void step(); +private: + std::atomic_int squelchBreak; +}; + + class DemodulatorInstance { public: @@ -89,6 +103,8 @@ public: bool isMuted(); void setMuted(bool muted); + DemodVisualCue *getVisualCue(); + DemodulatorThreadInputQueue *getIQInputDataPipe(); ModemArgInfoList getModemArgs(); @@ -135,6 +151,7 @@ private: std::atomic_bool follow, tracking; std::map lastModemSettings; std::map lastModemBandwidth; + DemodVisualCue visualCue; #if ENABLE_DIGITAL_LAB ModemDigitalOutput *activeOutput; #endif diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index 8dba9ed..254aa68 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -157,6 +157,7 @@ void DemodulatorThread::run() { wxGetApp().getDemodMgr().setActiveDemodulator(demodInstance, false); } squelchBreak = true; + demodInstance->getVisualCue()->triggerSquelchBreak(120); } else if (squelched && squelchBreak) { squelchBreak = false; } diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 8003345..d65c98b 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -338,6 +338,16 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->DrawDemod(demods[i], currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth); } + for (int i = 0, iMax = demods.size(); i < iMax; i++) { + demods[i]->getVisualCue()->step(); + + int squelchBreak = demods[i]->getVisualCue()->getSquelchBreak(); + if (squelchBreak) { + glContext->setHoverAlpha((float(squelchBreak) / 60.0)); + glContext->DrawDemod(demods[i], currentTheme->waterfallHover, currentCenterFreq, currentBandwidth); + } + } + glContext->EndDraw(); SwapBuffers();