Bandwidth manual entry fix for LSB/USB

This commit is contained in:
Charles J. Cliffe 2015-12-31 22:31:14 -05:00
parent 22569834a9
commit caa8074531

View File

@ -24,7 +24,12 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin
} }
if (targetMode == FDIALOG_TARGET_BANDWIDTH) { if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth()); std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
if (lastDemodType == "USB" || lastDemodType == "LSB") {
freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth()/2);
} else {
freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth());
}
} }
dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70), dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70),
@ -40,29 +45,34 @@ 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;
std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
switch (c) { switch (c) {
case WXK_RETURN: case WXK_RETURN:
case WXK_NUMPAD_ENTER: case WXK_NUMPAD_ENTER:
// Do Stuff // Do Stuff
freq = strToFrequency(dialogText->GetValue().ToStdString()); freq = strToFrequency(dialogText->GetValue().ToStdString());
if (targetMode == FDIALOG_TARGET_DEFAULT) { if (lastDemodType == "USB" || lastDemodType == "LSB") {
if (activeDemod) { freq *= 2;
activeDemod->setTracking(true); }
activeDemod->setFollow(true);
activeDemod->setFrequency(freq); if (targetMode == FDIALOG_TARGET_DEFAULT) {
activeDemod->updateLabel(freq); if (activeDemod) {
} else { activeDemod->setTracking(true);
wxGetApp().setFrequency(freq); activeDemod->setFollow(true);
} activeDemod->setFrequency(freq);
activeDemod->updateLabel(freq);
} else {
wxGetApp().setFrequency(freq);
} }
if (targetMode == FDIALOG_TARGET_BANDWIDTH) { }
if (activeDemod) { if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
activeDemod->setBandwidth(freq); if (activeDemod) {
} else { activeDemod->setBandwidth(freq);
wxGetApp().getDemodMgr().setLastBandwidth(freq); } else {
} wxGetApp().getDemodMgr().setLastBandwidth(freq);
} }
}
Close(); Close();
break; break;
case WXK_ESCAPE: case WXK_ESCAPE: