From 71f6be8d08c589f71e24ef0ebb8fefa0d725800f Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Tue, 20 Oct 2020 14:59:42 +0200 Subject: [PATCH] Fixed VFO alignment --- core/src/gui/menus/source.cpp | 6 +++ core/src/gui/waterfall.cpp | 12 ++++- core/src/gui/waterfall.h | 1 + core/src/signal_path/source.cpp | 8 +++- core/src/signal_path/source.h | 3 ++ radio/src/main.cpp | 5 ++ root_dev/config.json | 84 ++++++++++++++++----------------- root_dev/module_list.json | 9 ++-- 8 files changed, 78 insertions(+), 50 deletions(-) diff --git a/core/src/gui/menus/source.cpp b/core/src/gui/menus/source.cpp index c2f06be9..2bccaa56 100644 --- a/core/src/gui/menus/source.cpp +++ b/core/src/gui/menus/source.cpp @@ -6,6 +6,7 @@ namespace sourecmenu { int sourceId = 0; + double freqOffset = 0.0; void init() { // Select default @@ -13,6 +14,7 @@ namespace sourecmenu { if (sigpath::sourceManager.sourceNames.size() > 0) { sigpath::sourceManager.selectSource(sigpath::sourceManager.sourceNames[0]); } + sigpath::sourceManager.setTuningOffset(0); } void draw(void* ctx) { @@ -29,5 +31,9 @@ namespace sourecmenu { } sigpath::sourceManager.showSelectedMenu(); + ImGui::SetNextItemWidth(itemWidth - ImGui::CalcTextSize("Offset (Hz)").x - 10); + if (ImGui::InputDouble("Offset (Hz)##freq_offset", &freqOffset, 1.0, 100.0)) { + sigpath::sourceManager.setTuningOffset(freqOffset); + } } } \ No newline at end of file diff --git a/core/src/gui/waterfall.cpp b/core/src/gui/waterfall.cpp index 86c5f644..4b8258b8 100644 --- a/core/src/gui/waterfall.cpp +++ b/core/src/gui/waterfall.cpp @@ -230,7 +230,9 @@ namespace ImGui { int refCenter = mousePos.x - (widgetPos.x + 50); if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) { double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset; - vfo->setOffset(round(off / vfo->snapInterval) * vfo->snapInterval); + off += centerFreq; + off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq; + vfo->setOffset(off); } } @@ -239,7 +241,9 @@ namespace ImGui { int refCenter = mousePos.x - (widgetPos.x + 50); if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) { double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset; - vfo->setOffset(round(off / vfo->snapInterval) * vfo->snapInterval); + off += centerFreq; + off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq; + vfo->setOffset(off); } } @@ -797,5 +801,9 @@ namespace ImGui { void WaterFall::hideBandplan() { bandplanVisible = false; } + + void WaterfallVFO::setSnapInterval(double interval) { + snapInterval = interval; + } }; diff --git a/core/src/gui/waterfall.h b/core/src/gui/waterfall.h index 9f766625..12d62c44 100644 --- a/core/src/gui/waterfall.h +++ b/core/src/gui/waterfall.h @@ -16,6 +16,7 @@ namespace ImGui { void setCenterOffset(double offset); void setBandwidth(double bw); void setReference(int ref); + void setSnapInterval(double interval); void updateDrawingVars(double viewBandwidth, float dataWidth, double viewOffset, ImVec2 widgetPos, int fftHeight); // NOTE: Datawidth double??? void draw(ImGuiWindow* window, bool selected); diff --git a/core/src/signal_path/source.cpp b/core/src/signal_path/source.cpp index e8412b4b..8e734a56 100644 --- a/core/src/signal_path/source.cpp +++ b/core/src/signal_path/source.cpp @@ -54,5 +54,11 @@ void SourceManager::tune(double freq) { if (selectedHandler == NULL) { return; } - selectedHandler->tuneHandler(freq, selectedHandler->ctx); + selectedHandler->tuneHandler(freq + tuneOffset, selectedHandler->ctx); + currentFreq = freq; +} + +void SourceManager::setTuningOffset(double offset) { + tuneOffset = offset; + tune(currentFreq); } \ No newline at end of file diff --git a/core/src/signal_path/source.h b/core/src/signal_path/source.h index 8ad53e15..ce5d0bdf 100644 --- a/core/src/signal_path/source.h +++ b/core/src/signal_path/source.h @@ -26,6 +26,7 @@ public: void start(); void stop(); void tune(double freq); + void setTuningOffset(double offset); std::vector sourceNames; @@ -33,5 +34,7 @@ private: std::map sources; std::string selectedName; SourceHandler* selectedHandler = NULL; + double tuneOffset; + double currentFreq; }; \ No newline at end of file diff --git a/radio/src/main.cpp b/radio/src/main.cpp index d5f913a6..d9bb8519 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -124,6 +124,10 @@ private: ImGui::SliderFloat(CONCAT("##_squelch_select_", _this->name), &_this->sigPath.squelch.level, -100, 0); ImGui::PopItemWidth(); + + ImGui::Text("Snap Interval"); + ImGui::SetNextItemWidth(menuColumnWidth - ImGui::GetCursorPosX()); + if (ImGui:) } static void scriptCreateHandler(void* ctx, duk_context* dukCtx, duk_idx_t objId) { @@ -315,6 +319,7 @@ private: int bandWidth; int bandWidthMin; int bandWidthMax; + double snapInterval = 100000.0; SigPath sigPath; }; diff --git a/root_dev/config.json b/root_dev/config.json index c3ddd76d..9595ad7a 100644 --- a/root_dev/config.json +++ b/root_dev/config.json @@ -1,43 +1,43 @@ -{ - "audio": { - "Radio": { - "device": "Speakers (Realtek High Definiti", - "sampleRate": 48000.0, - "volume": 0.60546875 - }, - "Radio 1": { - "device": "CABLE-A Input (VB-Audio Cable A)", - "sampleRate": 48000.0, - "volume": 1.0 - }, - "Radio 2": { - "device": "CABLE Input (VB-Audio Virtual Cable)", - "sampleRate": 48000.0, - "volume": 1.0 - } - }, - "bandPlan": "General", - "bandPlanEnabled": true, - "fftHeight": 300, - "frequency": 98983691, - "max": 0.0, - "maximized": false, - "menuOrder": [ - "Source", - "Radio", - "Recorder", - "Audio", - "Scripting", - "Band Plan", - "Display" - ], - "menuWidth": 300, - "min": -72.05882263183594, - "showWaterfall": true, - "source": "", - "sourceSettings": {}, - "windowSize": { - "h": 720, - "w": 1280 - } +{ + "audio": { + "Radio": { + "device": "Speakers (Realtek High Definiti", + "sampleRate": 48000.0, + "volume": 0.60546875 + }, + "Radio 1": { + "device": "CABLE-A Input (VB-Audio Cable A)", + "sampleRate": 48000.0, + "volume": 1.0 + }, + "Radio 2": { + "device": "CABLE Input (VB-Audio Virtual Cable)", + "sampleRate": 48000.0, + "volume": 1.0 + } + }, + "bandPlan": "General", + "bandPlanEnabled": true, + "fftHeight": 300, + "frequency": 99015000, + "max": 0.0, + "maximized": false, + "menuOrder": [ + "Source", + "Radio", + "Recorder", + "Audio", + "Scripting", + "Band Plan", + "Display" + ], + "menuWidth": 300, + "min": -72.05882263183594, + "showWaterfall": true, + "source": "", + "sourceSettings": {}, + "windowSize": { + "h": 1053, + "w": 959 + } } \ No newline at end of file diff --git a/root_dev/module_list.json b/root_dev/module_list.json index 446b3f19..5a29e31f 100644 --- a/root_dev/module_list.json +++ b/root_dev/module_list.json @@ -1,7 +1,6 @@ { - "Radio": "./radio/Release/radio.dll", - "Recorder": "./recorder/Release/recorder.dll", - "Soapy": "./soapy/Release/soapy.dll", - "RTLTCPSource": "./rtl_tcp_source/Release/rtl_tcp_source.dll", - "FileSource": "./file_source/Release/file_source.dll" + "Radio": "./radio/radio.so", + "Recorder": "./recorder/recorder.so", + "Soapy": "./soapy/soapy.so", + "RTLTCPSource": "./rtl_tcp_source/rtl_tcp_source.so" }