From fcbe2723e696edd635f5e9f216a5f55421bf0500 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 21 Oct 2015 17:39:44 -0400 Subject: [PATCH] Manual bandwidth input improvements - Prevent out-of-range bandwidths - Display device name and known min/max rate --- src/AppFrame.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 04ac4df..c4f6a30 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -531,8 +531,32 @@ void AppFrame::OnMenu(wxCommandEvent& event) { switch (event.GetId()) { case wxID_BANDWIDTH_MANUAL: - long bw = wxGetNumberFromUser("Set the bandwidth manually", "Sample Rate (Hz), i.e. 2560000 for 2.56M", - "Manual Bandwidth Entry", wxGetApp().getSampleRate(), 250000, 25000000, this); + int rateHigh, rateLow; + + SDRDeviceInfo *dev = wxGetApp().getDevice(); + if (dev == NULL) { + break; + } + + SDRDeviceChannel *chan = dev->getRxChannel(); + + rateLow = 2000000; + rateHigh = 30000000; + + if (chan->getSampleRates().size()) { + rateLow = chan->getSampleRates()[0]; + rateHigh = chan->getSampleRates()[chan->getSampleRates().size()-1]; + } + + long bw = wxGetNumberFromUser("\n" + dev->getName() + "\n\n " + + "min: " + std::to_string(rateLow) + " Hz" + + ", max: " + std::to_string(rateHigh) + " Hz\n", + "Sample Rate in Hz", + "Manual Bandwidth Entry", + wxGetApp().getSampleRate(), + rateLow, + rateHigh, + this); if (bw != -1) { wxGetApp().setSampleRate(bw); }