mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-07-26 12:04:13 -04:00
Simple active demod tracking, helptip updates.
This commit is contained in:
@@ -28,7 +28,7 @@ wxEND_EVENT_TABLE()
|
||||
|
||||
SpectrumCanvas::SpectrumCanvas(wxWindow *parent, int *attribList) :
|
||||
InteractiveCanvas(parent, attribList), fft_size(0), in(NULL), out(NULL), plan(NULL), fft_ceil_ma(1), fft_ceil_maa(1), fft_floor_ma(0), fft_floor_maa(
|
||||
0), waterfallCanvas(NULL) {
|
||||
0), waterfallCanvas(NULL), trackingRate(0) {
|
||||
|
||||
glContext = new SpectrumContext(this, &wxGetApp().GetContext(this));
|
||||
|
||||
@@ -175,46 +175,49 @@ void SpectrumCanvas::OnIdle(wxIdleEvent &event) {
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
|
||||
void SpectrumCanvas::moveCenterFrequency(long long freqChange) {
|
||||
long long freq = wxGetApp().getFrequency();
|
||||
|
||||
if (isView) {
|
||||
if (centerFreq - freqChange < bandwidth/2) {
|
||||
centerFreq = bandwidth/2;
|
||||
} else {
|
||||
centerFreq -= freqChange;
|
||||
}
|
||||
|
||||
if (waterfallCanvas) {
|
||||
waterfallCanvas->setCenterFrequency(centerFreq);
|
||||
}
|
||||
|
||||
long long bwOfs = (centerFreq > freq) ? ((long long) bandwidth / 2) : (-(long long) bandwidth / 2);
|
||||
long long freqEdge = centerFreq + bwOfs;
|
||||
|
||||
if (abs(freq - freqEdge) > (wxGetApp().getSampleRate() / 2)) {
|
||||
freqChange = -((centerFreq > freq) ? (freqEdge - freq - (wxGetApp().getSampleRate() / 2)) : (freqEdge - freq + (wxGetApp().getSampleRate() / 2)));
|
||||
} else {
|
||||
freqChange = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (freqChange) {
|
||||
if (freq - freqChange < wxGetApp().getSampleRate()/2) {
|
||||
freq = wxGetApp().getSampleRate()/2;
|
||||
} else {
|
||||
freq -= freqChange;
|
||||
}
|
||||
wxGetApp().setFrequency(freq);
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
}
|
||||
}
|
||||
|
||||
void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseMoved(event);
|
||||
if (mouseTracker.mouseDown()) {
|
||||
int freqChange = mouseTracker.getDeltaMouseX() * getBandwidth();
|
||||
|
||||
if (freqChange != 0) {
|
||||
long long freq = wxGetApp().getFrequency();
|
||||
|
||||
if (isView) {
|
||||
if (isView) {
|
||||
if (centerFreq - freqChange < bandwidth/2) {
|
||||
centerFreq = bandwidth/2;
|
||||
} else {
|
||||
centerFreq -= freqChange;
|
||||
}
|
||||
}
|
||||
if (waterfallCanvas) {
|
||||
waterfallCanvas->setCenterFrequency(centerFreq);
|
||||
}
|
||||
|
||||
long long bwOfs = (centerFreq > freq) ? ((long long) bandwidth / 2) : (-(long long) bandwidth / 2);
|
||||
long long freqEdge = centerFreq + bwOfs;
|
||||
|
||||
if (abs(freq - freqEdge) > (wxGetApp().getSampleRate() / 2)) {
|
||||
freqChange = -((centerFreq > freq) ? (freqEdge - freq - (wxGetApp().getSampleRate() / 2)) : (freqEdge - freq + (wxGetApp().getSampleRate() / 2)));
|
||||
} else {
|
||||
freqChange = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (freqChange) {
|
||||
if (freq - freqChange < wxGetApp().getSampleRate()/2) {
|
||||
freq = wxGetApp().getSampleRate()/2;
|
||||
} else {
|
||||
freq -= freqChange;
|
||||
}
|
||||
wxGetApp().setFrequency(freq);
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
}
|
||||
|
||||
moveCenterFrequency(freqChange);
|
||||
}
|
||||
} else {
|
||||
setStatusText("Click and drag to adjust center frequency.");
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
|
||||
void setData(DemodulatorThreadIQData *input);
|
||||
void attachWaterfallCanvas(WaterfallCanvas *canvas_in);
|
||||
void moveCenterFrequency(long long freqChange);
|
||||
|
||||
SpectrumContext* getSpectrumContext();
|
||||
|
||||
@@ -51,6 +52,7 @@ private:
|
||||
SpectrumContext *glContext;
|
||||
WaterfallCanvas *waterfallCanvas;
|
||||
int fft_size;
|
||||
int trackingRate;
|
||||
// event table
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
@@ -153,9 +153,10 @@ void TuningCanvas::StepTuner(ActiveState state, int exponent, bool up) {
|
||||
wxGetApp().setFrequency(freq);
|
||||
}
|
||||
|
||||
activeDemod->setTracking(true);
|
||||
activeDemod->setFollow(true);
|
||||
activeDemod->setFrequency(freq);
|
||||
activeDemod->updateLabel(freq);
|
||||
activeDemod->setFollow(true);
|
||||
}
|
||||
|
||||
if (state == TUNING_HOVER_BW) {
|
||||
@@ -270,16 +271,16 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
} else {
|
||||
switch (hoverState) {
|
||||
case TUNING_HOVER_FREQ:
|
||||
setStatusText("Click or drag a digit to change frequency. Hold ALT to change PPM. Hold SHIFT to disable carry.");
|
||||
setStatusText("Click, wheel or drag a digit to change frequency. Hold ALT to change PPM. Hold SHIFT to disable carry.");
|
||||
break;
|
||||
case TUNING_HOVER_BW:
|
||||
setStatusText("Click or drag a digit to change bandwidth. Hold SHIFT to disable carry.");
|
||||
setStatusText("Click, wheel or drag a digit to change bandwidth. Hold SHIFT to disable carry.");
|
||||
break;
|
||||
case TUNING_HOVER_CENTER:
|
||||
setStatusText("Click or drag a digit to change center frequency. Hold SHIFT to disable carry.");
|
||||
setStatusText("Click, wheel or drag a digit to change center frequency. Hold SHIFT to disable carry.");
|
||||
break;
|
||||
case TUNING_HOVER_PPM:
|
||||
setStatusText("Click or drag a digit to change device PPM offset. Hold SHIFT to disable carry.");
|
||||
setStatusText("Click, wheel or drag a digit to change device PPM offset. Hold SHIFT to disable carry.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,6 +820,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
mouseTracker.setHorizDragLock(false);
|
||||
} else {
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveDemodulator(), false);
|
||||
wxGetApp().getDemodMgr().getActiveDemodulator()->setTracking(true);
|
||||
nextDragState = WF_DRAG_FREQUENCY;
|
||||
}
|
||||
} else if (dragState == WF_DRAG_RANGE) {
|
||||
|
||||
Reference in New Issue
Block a user