mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-25 13:18:37 -05:00
Support ranged frequency input for center frequency
This commit is contained in:
parent
19533e08de
commit
4be9fa0538
@ -7,7 +7,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
|
|||||||
SET(CUBICSDR_VERSION_MAJOR "0")
|
SET(CUBICSDR_VERSION_MAJOR "0")
|
||||||
SET(CUBICSDR_VERSION_MINOR "2")
|
SET(CUBICSDR_VERSION_MINOR "2")
|
||||||
SET(CUBICSDR_VERSION_PATCH "0")
|
SET(CUBICSDR_VERSION_PATCH "0")
|
||||||
SET(CUBICSDR_VERSION_REL "beta-rc5")
|
SET(CUBICSDR_VERSION_REL "beta-rc6")
|
||||||
SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}-${CUBICSDR_VERSION_REL}")
|
SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}-${CUBICSDR_VERSION_REL}")
|
||||||
|
|
||||||
SET(CPACK_PACKAGE_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}")
|
SET(CPACK_PACKAGE_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}")
|
||||||
|
@ -2191,3 +2191,14 @@ void AppFrame::setSpectrumAvgSpeed(double avg) {
|
|||||||
spectrumAvgMeter->setUserInputValue(avg);
|
spectrumAvgMeter->setUserInputValue(avg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppFrame::setViewState(long long center_freq, int bandwidth) {
|
||||||
|
spectrumCanvas->setView(center_freq, bandwidth);
|
||||||
|
waterfallCanvas->setView(center_freq, bandwidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFrame::setViewState(long long center_freq) {
|
||||||
|
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
|
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
|
spectrumCanvas->disableView();
|
||||||
|
waterfallCanvas->disableView();
|
||||||
|
}
|
||||||
|
@ -98,7 +98,9 @@ public:
|
|||||||
|
|
||||||
FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget();
|
FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget();
|
||||||
void refreshGainUI();
|
void refreshGainUI();
|
||||||
|
void setViewState(long long center_freq, int bandwidth);
|
||||||
|
void setViewState(long long center_freq);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
bool canFocus();
|
bool canFocus();
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,25 +69,68 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin
|
|||||||
|
|
||||||
void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||||
int c = event.GetKeyCode();
|
int c = event.GetKeyCode();
|
||||||
long long freq;
|
long long freq, freq2, freq_ctr, range_bw;
|
||||||
double dblval;
|
double dblval;
|
||||||
std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
|
std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
|
||||||
std::string strValue = dialogText->GetValue().ToStdString();
|
std::string strValue = dialogText->GetValue().ToStdString();
|
||||||
|
bool ranged = false;
|
||||||
|
std::string strValue2;
|
||||||
|
size_t range_pos;
|
||||||
|
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
case WXK_NUMPAD_ENTER:
|
case WXK_NUMPAD_ENTER:
|
||||||
// Do Stuff
|
// Do Stuff
|
||||||
|
ranged = false;
|
||||||
|
if ((range_pos = strValue.find_first_of("-")) > 0) {
|
||||||
|
strValue2 = strValue.substr(range_pos+1);
|
||||||
|
strValue = strValue.substr(0,range_pos);
|
||||||
|
|
||||||
|
if (targetMode == FDIALOG_TARGET_DEFAULT && !activeDemod && strValue.length() && strValue2.length()) {
|
||||||
|
ranged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (targetMode == FDIALOG_TARGET_DEFAULT) {
|
if (targetMode == FDIALOG_TARGET_DEFAULT) {
|
||||||
freq = strToFrequency(strValue);
|
if (ranged) {
|
||||||
|
freq = strToFrequency(strValue);
|
||||||
|
freq2 = strToFrequency(strValue2);
|
||||||
|
} else {
|
||||||
|
freq = strToFrequency(strValue);
|
||||||
|
}
|
||||||
if (activeDemod) {
|
if (activeDemod) {
|
||||||
activeDemod->setTracking(true);
|
activeDemod->setTracking(true);
|
||||||
activeDemod->setFollow(true);
|
activeDemod->setFollow(true);
|
||||||
activeDemod->setFrequency(freq);
|
activeDemod->setFrequency(freq);
|
||||||
activeDemod->updateLabel(freq);
|
activeDemod->updateLabel(freq);
|
||||||
} else {
|
} else {
|
||||||
wxGetApp().setFrequency(freq);
|
if (ranged && (freq || freq2)) {
|
||||||
|
if (freq > freq2) {
|
||||||
|
std::swap(freq,freq2);
|
||||||
|
}
|
||||||
|
range_bw = (freq2-freq);
|
||||||
|
freq_ctr = freq + (range_bw/2);
|
||||||
|
if (range_bw > wxGetApp().getSampleRate()) {
|
||||||
|
range_bw = wxGetApp().getSampleRate();
|
||||||
|
}
|
||||||
|
if (range_bw < 30000) {
|
||||||
|
range_bw = 30000;
|
||||||
|
}
|
||||||
|
if (freq == freq2) {
|
||||||
|
wxGetApp().setFrequency(freq_ctr);
|
||||||
|
wxGetApp().getAppFrame()->setViewState(freq_ctr);
|
||||||
|
} else {
|
||||||
|
if (wxGetApp().getSampleRate()/4 > range_bw) {
|
||||||
|
wxGetApp().setFrequency(freq_ctr + wxGetApp().getSampleRate()/4);
|
||||||
|
} else {
|
||||||
|
wxGetApp().setFrequency(freq_ctr);
|
||||||
|
}
|
||||||
|
wxGetApp().getAppFrame()->setViewState(freq_ctr, range_bw);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wxGetApp().setFrequency(freq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
|
if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
|
||||||
@ -161,7 +204,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string allowed("0123456789.MKGHZmkghz");
|
std::string allowed("0123456789.MKGHZmkghz-");
|
||||||
|
|
||||||
if (allowed.find_first_of(c) != std::string::npos || c == WXK_DELETE || c == WXK_BACK || c == WXK_NUMPAD_DECIMAL
|
if (allowed.find_first_of(c) != std::string::npos || c == WXK_DELETE || c == WXK_BACK || c == WXK_NUMPAD_DECIMAL
|
||||||
|| (c >= WXK_NUMPAD0 && c <= WXK_NUMPAD9)) {
|
|| (c >= WXK_NUMPAD0 && c <= WXK_NUMPAD9)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user