Made the file source set the frequency of the waterfall

This commit is contained in:
Ryzerth
2021-07-21 04:08:28 +02:00
parent 5f1a94c267
commit fb32b4d55a
7 changed files with 67 additions and 6 deletions

View File

@ -4,6 +4,7 @@
#include <string>
namespace tuner {
void centerTuning(std::string vfoName, double freq) {
if (vfoName != "") {
if (gui::waterfall.vfos.find(vfoName) == gui::waterfall.vfos.end()) { return; }
@ -110,6 +111,12 @@ namespace tuner {
}
}
void iqTuning(double freq) {
gui::waterfall.setCenterFrequency(freq);
gui::waterfall.centerFreqMoved = true;
sigpath::sourceManager.tune(freq);
}
void tune(int mode, std::string vfoName, double freq) {
switch (mode) {
case TUNER_MODE_CENTER:
@ -124,6 +131,9 @@ namespace tuner {
case TUNER_MODE_UPPER_HALF:
normalTuning(vfoName, freq);
break;
case TUNER_MODE_IQ_ONLY:
iqTuning(freq);
break;
}
}
}

View File

@ -1,15 +1,18 @@
#pragma once
#include <string>
#include <module.h>
namespace tuner {
void centerTuning(std::string vfoName, double freq);
void normalTuning(std::string vfoName, double freq);
void iqTuning(double freq);
enum {
TUNER_MODE_CENTER,
TUNER_MODE_NORMAL,
TUNER_MODE_LOWER_HALF,
TUNER_MODE_UPPER_HALF,
TUNER_MODE_IQ_ONLY,
_TUNER_MODE_COUNT
};

View File

@ -173,6 +173,7 @@ void FrequencySelect::draw() {
for (int j = i; j < 12; j++) {
digits[j] = 0;
}
frequencyChanged = true;
}
if (ImGui::IsKeyPressed(GLFW_KEY_UP)) {
@ -214,7 +215,15 @@ void FrequencySelect::draw() {
for (int i = 0; i < 12; i++) {
freq += digits[i] * pow(10, 11 - i);
}
frequency = freq;
uint64_t orig = freq;
freq = std::clamp<uint64_t>(freq, minFreq, maxFreq);
if (freq != orig && limitFreq) {
setFrequency(freq);
}
else {
frequency = orig;
}
ImGui::PopFont();

View File

@ -14,6 +14,10 @@ public:
bool frequencyChanged = false;
bool digitHovered = false;
bool limitFreq;
uint64_t minFreq;
uint64_t maxFreq;
private:
void onPosChange();
void onResize();

View File

@ -336,14 +336,18 @@ namespace ImGui {
if (viewOffset + (viewBandwidth / 2.0) > wholeBandwidth / 2.0) {
double freqOffset = (viewOffset + (viewBandwidth / 2.0)) - (wholeBandwidth / 2.0);
viewOffset = (wholeBandwidth / 2.0) - (viewBandwidth / 2.0);
centerFreq += freqOffset;
centerFreqMoved = true;
if (!centerFrequencyLocked) {
centerFreq += freqOffset;
centerFreqMoved = true;
}
}
if (viewOffset - (viewBandwidth / 2.0) < -(wholeBandwidth / 2.0)) {
double freqOffset = (viewOffset - (viewBandwidth / 2.0)) + (wholeBandwidth / 2.0);
viewOffset = (viewBandwidth / 2.0) - (wholeBandwidth / 2.0);
centerFreq += freqOffset;
centerFreqMoved = true;
if (!centerFrequencyLocked) {
centerFreq += freqOffset;
centerFreqMoved = true;
}
}
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);

View File

@ -141,6 +141,8 @@ namespace ImGui {
float selectedVFOSNR = NAN;
bool centerFrequencyLocked = false;
std::map<std::string, WaterfallVFO*> vfos;
std::string selectedVFO = "";
bool selectedVFOChanged = false;