Simple active demod tracking, helptip updates.

This commit is contained in:
Charles J. Cliffe 2015-04-23 19:38:44 -04:00
parent ab972cc90a
commit 8589a39f66
8 changed files with 82 additions and 42 deletions

View File

@ -446,6 +446,26 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
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) {
demodSignalMeter->setInputValue(demod->getSquelchLevel());
demodGainMeter->setInputValue(demod->getGain());

View File

@ -164,6 +164,9 @@ void DemodulatorInstance::setActive(bool state) {
} else if (!active && state) {
audioThread->setActive(state);
}
if (!state) {
tracking = false;
}
active = state;
}
@ -343,3 +346,11 @@ bool DemodulatorInstance::isFollow() {
void DemodulatorInstance::setFollow(bool follow) {
this->follow = follow;
}
bool DemodulatorInstance::isTracking() {
return tracking;
}
void DemodulatorInstance::setTracking(bool tracking) {
this->tracking = tracking;
}

View File

@ -80,6 +80,8 @@ public:
bool isFollow();
void setFollow(bool follow);
bool isTracking();
void setTracking(bool tracking);
private:
void checkBandwidth();
@ -98,5 +100,5 @@ private:
int currentDemodType;
int currentOutputDevice;
int currentAudioSampleRate;
bool follow;
bool follow, tracking;
};

View File

@ -186,7 +186,7 @@ void SDRPostThread::threadMain() {
DemodulatorThreadInputQueue *demodQueue = demod->threadQueueDemod;
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);
DemodulatorThreadIQData *dummyDataOut = new DemodulatorThreadIQData;
dummyDataOut->frequency = data_in->frequency;

View File

@ -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.");

View File

@ -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();
};

View File

@ -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;
}
}

View File

@ -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) {