diff --git a/CMakeLists.txt b/CMakeLists.txt index 8250013..7f8ac92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") SET(CUBICSDR_VERSION_MAJOR "0") SET(CUBICSDR_VERSION_MINOR "2") 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(CPACK_PACKAGE_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}") diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 3e39091..bf1ccca 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -2191,3 +2191,14 @@ void AppFrame::setSpectrumAvgSpeed(double 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(); +} diff --git a/src/AppFrame.h b/src/AppFrame.h index aedc53c..fcd73f9 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -98,7 +98,9 @@ public: FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget(); void refreshGainUI(); - + void setViewState(long long center_freq, int bandwidth); + void setViewState(long long center_freq); + #ifdef _WIN32 bool canFocus(); #endif diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp index 1d6fb04..3882455 100644 --- a/src/FrequencyDialog.cpp +++ b/src/FrequencyDialog.cpp @@ -69,25 +69,68 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin void FrequencyDialog::OnChar(wxKeyEvent& event) { int c = event.GetKeyCode(); - long long freq; + long long freq, freq2, freq_ctr, range_bw; double dblval; std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType(); std::string strValue = dialogText->GetValue().ToStdString(); + bool ranged = false; + std::string strValue2; + size_t range_pos; + switch (c) { case WXK_RETURN: case WXK_NUMPAD_ENTER: // 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) { - freq = strToFrequency(strValue); + if (ranged) { + freq = strToFrequency(strValue); + freq2 = strToFrequency(strValue2); + } else { + freq = strToFrequency(strValue); + } if (activeDemod) { activeDemod->setTracking(true); activeDemod->setFollow(true); activeDemod->setFrequency(freq); activeDemod->updateLabel(freq); } 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) { @@ -163,6 +206,11 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) { std::string allowed("0123456789.MKGHZmkghz"); + // Support '-' for range + if (targetMode == FDIALOG_TARGET_DEFAULT && !activeDemod && strValue.length() > 0) { + allowed.append("-"); + } + 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)) { #ifdef __linux__