mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-09-28 08:16:37 -04:00
Control gains with space or numeric entry
This commit is contained in:
parent
96d22ee8f7
commit
8737728cf9
@ -287,9 +287,6 @@ AppFrame::AppFrame() :
|
||||
|
||||
this->SetSizer(vbox);
|
||||
|
||||
// waterfallCanvas->SetFocusFromKbd();
|
||||
// waterfallCanvas->SetFocus();
|
||||
|
||||
// SetIcon(wxICON(sample));
|
||||
|
||||
// Make a menubar
|
||||
@ -1196,16 +1193,6 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
}
|
||||
}
|
||||
|
||||
// if (demodTuner->getMouseTracker()->mouseInView()) {
|
||||
// if (!demodTuner->HasFocus()) {
|
||||
// demodTuner->SetFocus();
|
||||
// }
|
||||
// } else if (!wxGetApp().isDeviceSelectorOpen() && (!modemProps || !modemProps->isMouseInView())) {
|
||||
// if (!waterfallCanvas->HasFocus()) {
|
||||
// waterfallCanvas->SetFocus();
|
||||
// }
|
||||
// }
|
||||
|
||||
scopeCanvas->setPPMMode(demodTuner->isAltDown());
|
||||
|
||||
scopeCanvas->setShowDb(spectrumCanvas->getShowDb());
|
||||
@ -1543,6 +1530,13 @@ void AppFrame::setMainWaterfallFFTSize(int fftSize) {
|
||||
waterfallCanvas->setFFTSize(fftSize);
|
||||
}
|
||||
|
||||
|
||||
void AppFrame::refreshGainUI() {
|
||||
gainCanvas->updateGainUI();
|
||||
gainCanvas->Refresh();
|
||||
}
|
||||
|
||||
|
||||
FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() {
|
||||
FrequencyDialog::FrequencyDialogTarget target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT;
|
||||
|
||||
@ -1551,7 +1545,8 @@ FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() {
|
||||
}
|
||||
else if (spectrumAvgMeter->getMouseTracker()->mouseInView()) {
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_SPECTRUM_AVG;
|
||||
} else if (demodTuner->getMouseTracker()->mouseInView()) {
|
||||
}
|
||||
else if (demodTuner->getMouseTracker()->mouseInView()) {
|
||||
switch (demodTuner->getHoverState()) {
|
||||
case TuningCanvas::ActiveState::TUNING_HOVER_BW:
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH;
|
||||
@ -1566,6 +1561,9 @@ FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() {
|
||||
|
||||
}
|
||||
}
|
||||
else if (gainCanvas->getMouseTracker()->mouseInView()) {
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_GAIN;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
void setSpectrumAvgSpeed(double avg);
|
||||
|
||||
FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget();
|
||||
void refreshGainUI();
|
||||
|
||||
private:
|
||||
void OnMenu(wxCommandEvent& event);
|
||||
|
@ -650,23 +650,16 @@ int CubicSDR::getPPM() {
|
||||
return ppm;
|
||||
}
|
||||
|
||||
void CubicSDR::setFrequencyInputTarget(FrequencyDialog::FrequencyDialogTarget targetMode) {
|
||||
fdlgTarget = targetMode;
|
||||
}
|
||||
|
||||
void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode, wxString initString) {
|
||||
const wxString demodTitle("Set Demodulator Frequency");
|
||||
const wxString freqTitle("Set Center Frequency");
|
||||
const wxString bwTitle("Modem Bandwidth (150Hz - 500KHz)");
|
||||
const wxString lpsTitle("Lines-Per-Second (1-1024)");
|
||||
const wxString avgTitle("Average Rate (0.1 - 0.99)");
|
||||
const wxString gainTitle("Gain Entry: "+wxGetApp().getActiveGainEntry());
|
||||
|
||||
wxString title;
|
||||
|
||||
// if (targetMode == FrequencyDialog::FDIALOG_TARGET_DEFAULT && fdlgTarget != FrequencyDialog::FDIALOG_TARGET_DEFAULT) {
|
||||
// targetMode = fdlgTarget;
|
||||
// }
|
||||
|
||||
switch (targetMode) {
|
||||
case FrequencyDialog::FDIALOG_TARGET_DEFAULT:
|
||||
title = demodMgr.getActiveDemodulator()?demodTitle:freqTitle;
|
||||
@ -680,6 +673,12 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
|
||||
case FrequencyDialog::FDIALOG_TARGET_SPECTRUM_AVG:
|
||||
title = avgTitle;
|
||||
break;
|
||||
case FrequencyDialog::FDIALOG_TARGET_GAIN:
|
||||
title = gainTitle;
|
||||
if (wxGetApp().getActiveGainEntry() == "") {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -765,6 +764,14 @@ std::string CubicSDR::getModulePath() {
|
||||
return modulePath;
|
||||
}
|
||||
|
||||
void CubicSDR::setActiveGainEntry(std::string gainName) {
|
||||
activeGain = gainName;
|
||||
}
|
||||
|
||||
std::string CubicSDR::getActiveGainEntry() {
|
||||
return activeGain;
|
||||
}
|
||||
|
||||
int CubicSDR::FilterEvent(wxEvent& event) {
|
||||
if (!appframe) {
|
||||
return -1;
|
||||
|
@ -125,7 +125,6 @@ public:
|
||||
void setPPM(int ppm_in);
|
||||
int getPPM();
|
||||
|
||||
void setFrequencyInputTarget(FrequencyDialog::FrequencyDialogTarget targetMode);
|
||||
void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT, wxString initString = "");
|
||||
AppFrame *getAppFrame();
|
||||
|
||||
@ -154,6 +153,9 @@ public:
|
||||
bool getUseLocalMod();
|
||||
std::string getModulePath();
|
||||
|
||||
void setActiveGainEntry(std::string gainName);
|
||||
std::string getActiveGainEntry();
|
||||
|
||||
#ifdef USE_HAMLIB
|
||||
RigThread *getRigThread();
|
||||
void initRig(int rigModel, std::string rigPort, int rigSerialRate);
|
||||
@ -209,6 +211,7 @@ private:
|
||||
std::atomic_bool frequency_locked;
|
||||
std::atomic_llong lock_freq;
|
||||
FrequencyDialog::FrequencyDialogTarget fdlgTarget;
|
||||
std::string activeGain;
|
||||
#ifdef USE_HAMLIB
|
||||
RigThread *rigThread;
|
||||
std::thread *t_Rig;
|
||||
|
@ -40,6 +40,12 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin
|
||||
freqStr = std::to_string(wxGetApp().getSpectrumProcessor()->getFFTAverageRate());
|
||||
}
|
||||
|
||||
if (targetMode == FDIALOG_TARGET_GAIN) {
|
||||
if (wxGetApp().getActiveGainEntry() != "") {
|
||||
freqStr = std::to_string((int)wxGetApp().getGain(wxGetApp().getActiveGainEntry()));
|
||||
}
|
||||
}
|
||||
|
||||
dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70),
|
||||
wxTE_PROCESS_ENTER);
|
||||
dialogText->SetFont(wxFont(20, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
|
||||
@ -123,6 +129,29 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||
}
|
||||
wxGetApp().getAppFrame()->setSpectrumAvgSpeed(dblval);
|
||||
}
|
||||
|
||||
if (targetMode == FDIALOG_TARGET_GAIN) {
|
||||
try {
|
||||
freq = std::stoi(strValue);
|
||||
} catch (exception e) {
|
||||
break;
|
||||
}
|
||||
SDRDeviceInfo *devInfo = wxGetApp().getDevice();
|
||||
std::string gainName = wxGetApp().getActiveGainEntry();
|
||||
if (gainName == "") {
|
||||
break;
|
||||
}
|
||||
SDRRangeMap gains = devInfo->getGains(SOAPY_SDR_RX, 0);
|
||||
if (freq > gains[gainName].maximum()) {
|
||||
freq = gains[gainName].maximum();
|
||||
}
|
||||
if (freq < gains[gainName].minimum()) {
|
||||
freq = gains[gainName].minimum();
|
||||
}
|
||||
wxGetApp().setGain(gainName, freq);
|
||||
wxGetApp().getAppFrame()->refreshGainUI();
|
||||
}
|
||||
|
||||
Close();
|
||||
break;
|
||||
case WXK_ESCAPE:
|
||||
|
@ -17,7 +17,8 @@ public:
|
||||
FDIALOG_TARGET_FREQ,
|
||||
FDIALOG_TARGET_BANDWIDTH,
|
||||
FDIALOG_TARGET_WATERFALL_LPS,
|
||||
FDIALOG_TARGET_SPECTRUM_AVG
|
||||
FDIALOG_TARGET_SPECTRUM_AVG,
|
||||
FDIALOG_TARGET_GAIN
|
||||
} FrequencyDialogTarget;
|
||||
FrequencyDialog ( wxWindow * parent, wxWindowID id, const wxString & title,
|
||||
DemodulatorInstance *demod = NULL,
|
||||
|
@ -132,6 +132,9 @@ void GainCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
int i = 0;
|
||||
for (std::vector<GainInfo *>::iterator gi = gainInfo.begin(); gi != gainInfo.end(); gi++) {
|
||||
(*gi)->highlightPanel.visible = (i==panelHit);
|
||||
if (i==panelHit) {
|
||||
wxGetApp().setActiveGainEntry((*gi)->name);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user