Simple tuner half-band display patch

This commit is contained in:
Charles J. Cliffe 2015-12-07 20:19:03 -05:00
parent 571ccd3f48
commit 904db013c7
3 changed files with 17 additions and 2 deletions

View File

@ -874,6 +874,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
#endif #endif
demodMuteButton->setSelection(demod->isMuted()?1:-1); demodMuteButton->setSelection(demod->isMuted()?1:-1);
modemPropertiesUpdated.store(true); modemPropertiesUpdated.store(true);
demodTuner->setHalfBand(dType=="USB" || dType=="LSB");
} }
if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) { if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) {
long long centerFreq = demod->getFrequency(); long long centerFreq = demod->getFrequency();
@ -907,17 +908,20 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
// basic demodulators // basic demodulators
if (dSelection != "" && dSelection != demod->getDemodulatorType()) { if (dSelection != "" && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection); demod->setDemodulatorType(dSelection);
demodTuner->setHalfBand(dSelection=="USB" || dSelection=="LSB");
demodModeSelectorAdv->setSelection(-1); demodModeSelectorAdv->setSelection(-1);
} }
// advanced demodulators // advanced demodulators
else if (dSelectionadv != "" && dSelectionadv != demod->getDemodulatorType()) { else if (dSelectionadv != "" && dSelectionadv != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelectionadv); demod->setDemodulatorType(dSelectionadv);
demodTuner->setHalfBand(false);
demodModeSelector->setSelection(-1); demodModeSelector->setSelection(-1);
} }
#else #else
// basic demodulators // basic demodulators
if (dSelection != "" && dSelection != demod->getDemodulatorType()) { if (dSelection != "" && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection); demod->setDemodulatorType(dSelection);
demodTuner->setHalfBand(dSelection=="USB" || dSelection=="LSB");
} }
#endif #endif

View File

@ -31,7 +31,7 @@ EVT_KEY_UP(TuningCanvas::OnKeyUp)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) : TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) :
InteractiveCanvas(parent, attribList), dragAccum(0), uxDown(0), top(false), bottom(false), freq(-1), bw(-1), center(-1) { InteractiveCanvas(parent, attribList), dragAccum(0), uxDown(0), top(false), bottom(false), freq(-1), bw(-1), center(-1), halfBand(false) {
glContext = new TuningContext(this, &wxGetApp().GetContext(this)); glContext = new TuningContext(this, &wxGetApp().GetContext(this));
@ -74,6 +74,10 @@ bool TuningCanvas::changed() {
return false; return false;
} }
void TuningCanvas::setHalfBand(bool hb) {
halfBand = hb;
}
void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
@ -146,7 +150,7 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->DrawTunerDigitBox((int)log10(snap), 11, freqDP, freqW, RGBA4f(1.0,0.0,0.0)); glContext->DrawTunerDigitBox((int)log10(snap), 11, freqDP, freqW, RGBA4f(1.0,0.0,0.0));
} }
} }
glContext->DrawTuner(bw, 7, bwDP, bwW); glContext->DrawTuner(halfBand?(bw/2):bw, 7, bwDP, bwW);
glContext->DrawTuner(center, 11, centerDP, centerW); glContext->DrawTuner(center, 11, centerDP, centerW);
glContext->DrawEnd(); glContext->DrawEnd();
@ -158,6 +162,10 @@ void TuningCanvas::StepTuner(ActiveState state, int exponent, bool up) {
double exp = pow(10, exponent); double exp = pow(10, exponent);
long long amount = up?exp:-exp; long long amount = up?exp:-exp;
if (halfBand && exp == 1) {
amount *= 2;
}
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
if (state == TUNING_HOVER_FREQ && activeDemod) { if (state == TUNING_HOVER_FREQ && activeDemod) {
long long freq = activeDemod->getFrequency(); long long freq = activeDemod->getFrequency();

View File

@ -24,6 +24,8 @@ public:
void setHelpTip(std::string tip); void setHelpTip(std::string tip);
bool changed(); bool changed();
void setHalfBand(bool hb);
private: private:
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent &event); void OnIdle(wxIdleEvent &event);
@ -68,6 +70,7 @@ private:
int lastPPM; int lastPPM;
long long freq, bw, center; long long freq, bw, center;
bool halfBand;
// //
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();
}; };