mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-09-26 23:36:43 -04:00
Simple active demod tracking, helptip updates.
This commit is contained in:
parent
ab972cc90a
commit
8589a39f66
@ -446,6 +446,26 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
|||||||
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
if (demod) {
|
if (demod) {
|
||||||
|
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
|
if (demod->isTracking()) {
|
||||||
|
if (spectrumCanvas->getViewState()) {
|
||||||
|
long long diff = abs(demod->getFrequency() - spectrumCanvas->getCenterFrequency()) + (demod->getBandwidth()/2) + (demod->getBandwidth()/4);
|
||||||
|
|
||||||
|
if (diff > spectrumCanvas->getBandwidth()/2) {
|
||||||
|
if (demod->getBandwidth() > spectrumCanvas->getBandwidth()) {
|
||||||
|
diff = abs(demod->getFrequency() - spectrumCanvas->getCenterFrequency());
|
||||||
|
} else {
|
||||||
|
diff = diff - spectrumCanvas->getBandwidth()/2;
|
||||||
|
}
|
||||||
|
spectrumCanvas->moveCenterFrequency((demod->getFrequency() < spectrumCanvas->getCenterFrequency())?diff:-diff);
|
||||||
|
demod->setTracking(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
demod->setTracking(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (demod != activeDemodulator) {
|
if (demod != activeDemodulator) {
|
||||||
demodSignalMeter->setInputValue(demod->getSquelchLevel());
|
demodSignalMeter->setInputValue(demod->getSquelchLevel());
|
||||||
demodGainMeter->setInputValue(demod->getGain());
|
demodGainMeter->setInputValue(demod->getGain());
|
||||||
|
@ -164,6 +164,9 @@ void DemodulatorInstance::setActive(bool state) {
|
|||||||
} else if (!active && state) {
|
} else if (!active && state) {
|
||||||
audioThread->setActive(state);
|
audioThread->setActive(state);
|
||||||
}
|
}
|
||||||
|
if (!state) {
|
||||||
|
tracking = false;
|
||||||
|
}
|
||||||
active = state;
|
active = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,3 +346,11 @@ bool DemodulatorInstance::isFollow() {
|
|||||||
void DemodulatorInstance::setFollow(bool follow) {
|
void DemodulatorInstance::setFollow(bool follow) {
|
||||||
this->follow = follow;
|
this->follow = follow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DemodulatorInstance::isTracking() {
|
||||||
|
return tracking;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorInstance::setTracking(bool tracking) {
|
||||||
|
this->tracking = tracking;
|
||||||
|
}
|
||||||
|
@ -80,6 +80,8 @@ public:
|
|||||||
bool isFollow();
|
bool isFollow();
|
||||||
void setFollow(bool follow);
|
void setFollow(bool follow);
|
||||||
|
|
||||||
|
bool isTracking();
|
||||||
|
void setTracking(bool tracking);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void checkBandwidth();
|
void checkBandwidth();
|
||||||
@ -98,5 +100,5 @@ private:
|
|||||||
int currentDemodType;
|
int currentDemodType;
|
||||||
int currentOutputDevice;
|
int currentOutputDevice;
|
||||||
int currentAudioSampleRate;
|
int currentAudioSampleRate;
|
||||||
bool follow;
|
bool follow, tracking;
|
||||||
};
|
};
|
||||||
|
@ -186,7 +186,7 @@ void SDRPostThread::threadMain() {
|
|||||||
DemodulatorThreadInputQueue *demodQueue = demod->threadQueueDemod;
|
DemodulatorThreadInputQueue *demodQueue = demod->threadQueueDemod;
|
||||||
|
|
||||||
if (abs(data_in->frequency - demod->getFrequency()) > (wxGetApp().getSampleRate() / 2)) {
|
if (abs(data_in->frequency - demod->getFrequency()) > (wxGetApp().getSampleRate() / 2)) {
|
||||||
if (demod->isActive() && !demod->isFollow()) {
|
if (demod->isActive() && !demod->isFollow() && !demod->isTracking()) {
|
||||||
demod->setActive(false);
|
demod->setActive(false);
|
||||||
DemodulatorThreadIQData *dummyDataOut = new DemodulatorThreadIQData;
|
DemodulatorThreadIQData *dummyDataOut = new DemodulatorThreadIQData;
|
||||||
dummyDataOut->frequency = data_in->frequency;
|
dummyDataOut->frequency = data_in->frequency;
|
||||||
|
@ -28,7 +28,7 @@ wxEND_EVENT_TABLE()
|
|||||||
|
|
||||||
SpectrumCanvas::SpectrumCanvas(wxWindow *parent, int *attribList) :
|
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(
|
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));
|
glContext = new SpectrumContext(this, &wxGetApp().GetContext(this));
|
||||||
|
|
||||||
@ -175,46 +175,49 @@ void SpectrumCanvas::OnIdle(wxIdleEvent &event) {
|
|||||||
Refresh(false);
|
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) {
|
void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||||
InteractiveCanvas::OnMouseMoved(event);
|
InteractiveCanvas::OnMouseMoved(event);
|
||||||
if (mouseTracker.mouseDown()) {
|
if (mouseTracker.mouseDown()) {
|
||||||
int freqChange = mouseTracker.getDeltaMouseX() * getBandwidth();
|
int freqChange = mouseTracker.getDeltaMouseX() * getBandwidth();
|
||||||
|
|
||||||
if (freqChange != 0) {
|
if (freqChange != 0) {
|
||||||
long long freq = wxGetApp().getFrequency();
|
moveCenterFrequency(freqChange);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setStatusText("Click and drag to adjust center frequency.");
|
setStatusText("Click and drag to adjust center frequency.");
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
void setData(DemodulatorThreadIQData *input);
|
void setData(DemodulatorThreadIQData *input);
|
||||||
void attachWaterfallCanvas(WaterfallCanvas *canvas_in);
|
void attachWaterfallCanvas(WaterfallCanvas *canvas_in);
|
||||||
|
void moveCenterFrequency(long long freqChange);
|
||||||
|
|
||||||
SpectrumContext* getSpectrumContext();
|
SpectrumContext* getSpectrumContext();
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ private:
|
|||||||
SpectrumContext *glContext;
|
SpectrumContext *glContext;
|
||||||
WaterfallCanvas *waterfallCanvas;
|
WaterfallCanvas *waterfallCanvas;
|
||||||
int fft_size;
|
int fft_size;
|
||||||
|
int trackingRate;
|
||||||
// event table
|
// event table
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
@ -153,9 +153,10 @@ void TuningCanvas::StepTuner(ActiveState state, int exponent, bool up) {
|
|||||||
wxGetApp().setFrequency(freq);
|
wxGetApp().setFrequency(freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activeDemod->setTracking(true);
|
||||||
|
activeDemod->setFollow(true);
|
||||||
activeDemod->setFrequency(freq);
|
activeDemod->setFrequency(freq);
|
||||||
activeDemod->updateLabel(freq);
|
activeDemod->updateLabel(freq);
|
||||||
activeDemod->setFollow(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == TUNING_HOVER_BW) {
|
if (state == TUNING_HOVER_BW) {
|
||||||
@ -270,16 +271,16 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
} else {
|
} else {
|
||||||
switch (hoverState) {
|
switch (hoverState) {
|
||||||
case TUNING_HOVER_FREQ:
|
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;
|
break;
|
||||||
case TUNING_HOVER_BW:
|
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;
|
break;
|
||||||
case TUNING_HOVER_CENTER:
|
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;
|
break;
|
||||||
case TUNING_HOVER_PPM:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -820,6 +820,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
mouseTracker.setHorizDragLock(false);
|
mouseTracker.setHorizDragLock(false);
|
||||||
} else {
|
} else {
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveDemodulator(), false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveDemodulator(), false);
|
||||||
|
wxGetApp().getDemodMgr().getActiveDemodulator()->setTracking(true);
|
||||||
nextDragState = WF_DRAG_FREQUENCY;
|
nextDragState = WF_DRAG_FREQUENCY;
|
||||||
}
|
}
|
||||||
} else if (dragState == WF_DRAG_RANGE) {
|
} else if (dragState == WF_DRAG_RANGE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user