mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
fix keyboard control code
This commit is contained in:
parent
3e2570a26c
commit
cd129e0726
@ -269,8 +269,9 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
|
||||
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator();
|
||||
|
||||
long long freq;
|
||||
long long originalFreq;
|
||||
long long originalFreq = getCenterFrequency();
|
||||
long long freq = originalFreq;
|
||||
|
||||
switch (event.GetKeyCode()) {
|
||||
case 'A':
|
||||
case WXK_UP:
|
||||
@ -284,59 +285,19 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
break;
|
||||
case WXK_RIGHT:
|
||||
case WXK_NUMPAD_RIGHT:
|
||||
freq = getCenterFrequency();
|
||||
originalFreq = freq;
|
||||
if (shiftDown) {
|
||||
freq += getBandwidth() * 10;
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setView(getCenterFrequency(), getBandwidth());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
freq += getBandwidth() / 2;
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setView(getCenterFrequency(), getBandwidth());
|
||||
}
|
||||
}
|
||||
}
|
||||
wxGetApp().setFrequency(freq);
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
break;
|
||||
case WXK_LEFT:
|
||||
case WXK_NUMPAD_LEFT:
|
||||
freq = getCenterFrequency();
|
||||
originalFreq = freq;
|
||||
if (shiftDown) {
|
||||
if ((freq - getBandwidth() * 10) < wxGetApp().getSampleRate() / 2) {
|
||||
freq = wxGetApp().getSampleRate() / 2;
|
||||
} else {
|
||||
freq -= getBandwidth() * 10;
|
||||
}
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setView(getCenterFrequency(), getBandwidth());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((freq - getBandwidth() / 2) < wxGetApp().getSampleRate() / 2) {
|
||||
freq = wxGetApp().getSampleRate() / 2;
|
||||
} else {
|
||||
freq -= getBandwidth() / 2;
|
||||
}
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setView(getCenterFrequency(), getBandwidth());
|
||||
}
|
||||
}
|
||||
}
|
||||
wxGetApp().setFrequency(freq);
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
break;
|
||||
case 'D':
|
||||
case WXK_DELETE:
|
||||
@ -363,6 +324,36 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
long long minFreq = wxGetApp().getSampleRate()/2;
|
||||
if (freq < minFreq) {
|
||||
freq = minFreq;
|
||||
}
|
||||
|
||||
if (freq != originalFreq) {
|
||||
if (isView) {
|
||||
setView(freq, getBandwidth());
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setView(freq, getBandwidth());
|
||||
}
|
||||
|
||||
long long minFreq = wxGetApp().getFrequency()-(wxGetApp().getSampleRate()/2);
|
||||
long long maxFreq = wxGetApp().getFrequency()+(wxGetApp().getSampleRate()/2);
|
||||
|
||||
if (freq < minFreq) {
|
||||
wxGetApp().setFrequency(freq+(wxGetApp().getSampleRate()/2));
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
}
|
||||
if (freq > maxFreq) {
|
||||
wxGetApp().setFrequency(freq-(wxGetApp().getSampleRate()/2));
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
}
|
||||
} else {
|
||||
wxGetApp().setFrequency(freq);
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
|
||||
Refresh();
|
||||
|
Loading…
Reference in New Issue
Block a user