mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-07-02 17:55:15 -04:00
Set waterfall lps or spectrum avg by space/typing
This commit is contained in:
parent
d7bb214d42
commit
96d22ee8f7
@ -1543,6 +1543,32 @@ void AppFrame::setMainWaterfallFFTSize(int fftSize) {
|
||||
waterfallCanvas->setFFTSize(fftSize);
|
||||
}
|
||||
|
||||
FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() {
|
||||
FrequencyDialog::FrequencyDialogTarget target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT;
|
||||
|
||||
if (waterfallSpeedMeter->getMouseTracker()->mouseInView()) {
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_WATERFALL_LPS;
|
||||
}
|
||||
else if (spectrumAvgMeter->getMouseTracker()->mouseInView()) {
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_SPECTRUM_AVG;
|
||||
} else if (demodTuner->getMouseTracker()->mouseInView()) {
|
||||
switch (demodTuner->getHoverState()) {
|
||||
case TuningCanvas::ActiveState::TUNING_HOVER_BW:
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH;
|
||||
break;
|
||||
case TuningCanvas::ActiveState::TUNING_HOVER_FREQ:
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_FREQ;
|
||||
break;
|
||||
case TuningCanvas::ActiveState::TUNING_HOVER_CENTER:
|
||||
default:
|
||||
target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
|
||||
if (!this->IsActive()) {
|
||||
return -1;
|
||||
@ -1574,7 +1600,7 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
wxGetApp().showFrequencyInput(FrequencyDialog::FDIALOG_TARGET_DEFAULT, std::to_string(event.GetKeyCode() - '0'));
|
||||
wxGetApp().showFrequencyInput(getFrequencyDialogTarget(), std::to_string(event.GetKeyCode() - '0'));
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
@ -1600,7 +1626,7 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) {
|
||||
switch (event.GetKeyCode()) {
|
||||
case WXK_SPACE:
|
||||
if (!demodTuner->getMouseTracker()->mouseInView()) {
|
||||
wxGetApp().showFrequencyInput();
|
||||
wxGetApp().showFrequencyInput(getFrequencyDialogTarget());
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
@ -1648,3 +1674,12 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void AppFrame::setWaterfallLinesPerSecond(int lps) {
|
||||
waterfallSpeedMeter->setUserInputValue(sqrt(lps));
|
||||
}
|
||||
|
||||
void AppFrame::setSpectrumAvgSpeed(double avg) {
|
||||
spectrumAvgMeter->setUserInputValue(avg);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "SDRDeviceInfo.h"
|
||||
#include "ModemProperties.h"
|
||||
//#include "UITestCanvas.h"
|
||||
#include "FrequencyDialog.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -78,6 +79,11 @@ public:
|
||||
int OnGlobalKeyDown(wxKeyEvent &event);
|
||||
int OnGlobalKeyUp(wxKeyEvent &event);
|
||||
|
||||
void setWaterfallLinesPerSecond(int lps);
|
||||
void setSpectrumAvgSpeed(double avg);
|
||||
|
||||
FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget();
|
||||
|
||||
private:
|
||||
void OnMenu(wxCommandEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
@ -134,6 +134,7 @@ CubicSDR::CubicSDR() : appframe(NULL), m_glContext(NULL), frequency(0), offset(0
|
||||
sdrThread(NULL), sdrPostThread(NULL), spectrumVisualThread(NULL), demodVisualThread(NULL), pipeSDRIQData(NULL), pipeIQVisualData(NULL), pipeAudioVisualData(NULL), t_SDR(NULL), t_PostSDR(NULL) {
|
||||
sampleRateInitialized.store(false);
|
||||
agcMode.store(true);
|
||||
fdlgTarget = FrequencyDialog::FDIALOG_TARGET_DEFAULT;
|
||||
}
|
||||
|
||||
bool CubicSDR::OnInit() {
|
||||
@ -649,14 +650,23 @@ 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("Set Demodulator Bandwidth");
|
||||
const wxString bwTitle("Modem Bandwidth (150Hz - 500KHz)");
|
||||
const wxString lpsTitle("Lines-Per-Second (1-1024)");
|
||||
const wxString avgTitle("Average Rate (0.1 - 0.99)");
|
||||
|
||||
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;
|
||||
@ -664,11 +674,17 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
|
||||
case FrequencyDialog::FDIALOG_TARGET_BANDWIDTH:
|
||||
title = bwTitle;
|
||||
break;
|
||||
case FrequencyDialog::FDIALOG_TARGET_WATERFALL_LPS:
|
||||
title = lpsTitle;
|
||||
break;
|
||||
case FrequencyDialog::FDIALOG_TARGET_SPECTRUM_AVG:
|
||||
title = avgTitle;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(320, 75 ), wxDEFAULT_DIALOG_STYLE, targetMode, initString);
|
||||
FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(350, 75), wxDEFAULT_DIALOG_STYLE, targetMode, initString);
|
||||
fdialog.ShowModal();
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,7 @@ 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();
|
||||
|
||||
@ -207,6 +208,7 @@ private:
|
||||
std::mutex notify_busy;
|
||||
std::atomic_bool frequency_locked;
|
||||
std::atomic_llong lock_freq;
|
||||
FrequencyDialog::FrequencyDialogTarget fdlgTarget;
|
||||
#ifdef USE_HAMLIB
|
||||
RigThread *rigThread;
|
||||
std::thread *t_Rig;
|
||||
|
@ -31,18 +31,29 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin
|
||||
freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth());
|
||||
}
|
||||
}
|
||||
|
||||
if (targetMode == FDIALOG_TARGET_WATERFALL_LPS) {
|
||||
freqStr = std::to_string(wxGetApp().getAppFrame()->getWaterfallDataThread()->getLinesPerSecond());
|
||||
}
|
||||
|
||||
if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) {
|
||||
freqStr = std::to_string(wxGetApp().getSpectrumProcessor()->getFFTAverageRate());
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
Centre();
|
||||
|
||||
if (initString != "") {
|
||||
if (initString != "" && initString.length() == 1) {
|
||||
dialogText->SetValue(initString);
|
||||
dialogText->SetSelection(initString.length(), initString.length());
|
||||
dialogText->SetFocus();
|
||||
} else {
|
||||
if (initString != "") {
|
||||
dialogText->SetValue(initString);
|
||||
}
|
||||
dialogText->SetSelection(-1, -1);
|
||||
}
|
||||
}
|
||||
@ -51,15 +62,17 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin
|
||||
void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||
int c = event.GetKeyCode();
|
||||
long long freq;
|
||||
double dblval;
|
||||
std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
|
||||
|
||||
std::string strValue = dialogText->GetValue().ToStdString();
|
||||
|
||||
switch (c) {
|
||||
case WXK_RETURN:
|
||||
case WXK_NUMPAD_ENTER:
|
||||
// Do Stuff
|
||||
freq = strToFrequency(dialogText->GetValue().ToStdString());
|
||||
|
||||
if (targetMode == FDIALOG_TARGET_DEFAULT) {
|
||||
freq = strToFrequency(strValue);
|
||||
if (activeDemod) {
|
||||
activeDemod->setTracking(true);
|
||||
activeDemod->setFollow(true);
|
||||
@ -70,6 +83,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||
}
|
||||
}
|
||||
if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
|
||||
freq = strToFrequency(strValue);
|
||||
if (lastDemodType == "USB" || lastDemodType == "LSB") {
|
||||
freq *= 2;
|
||||
}
|
||||
@ -79,6 +93,36 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||
wxGetApp().getDemodMgr().setLastBandwidth(freq);
|
||||
}
|
||||
}
|
||||
if (targetMode == FDIALOG_TARGET_WATERFALL_LPS) {
|
||||
try {
|
||||
freq = std::stoi(strValue);
|
||||
} catch (exception e) {
|
||||
Close();
|
||||
break;
|
||||
}
|
||||
if (freq > 1024) {
|
||||
freq = 1024;
|
||||
}
|
||||
if (freq < 1) {
|
||||
freq = 1;
|
||||
}
|
||||
wxGetApp().getAppFrame()->setWaterfallLinesPerSecond(freq);
|
||||
}
|
||||
if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) {
|
||||
try {
|
||||
dblval = std::stod(strValue);
|
||||
} catch (exception e) {
|
||||
Close();
|
||||
break;
|
||||
}
|
||||
if (dblval > 0.99) {
|
||||
dblval = 0.99;
|
||||
}
|
||||
if (dblval < 0.1) {
|
||||
dblval = 0.1;
|
||||
}
|
||||
wxGetApp().getAppFrame()->setSpectrumAvgSpeed(dblval);
|
||||
}
|
||||
Close();
|
||||
break;
|
||||
case WXK_ESCAPE:
|
||||
|
@ -11,7 +11,14 @@
|
||||
class FrequencyDialog: public wxDialog
|
||||
{
|
||||
public:
|
||||
typedef enum FrequencyDialogTarget { FDIALOG_TARGET_DEFAULT, FDIALOG_TARGET_CENTERFREQ, FDIALOG_TARGET_FREQ, FDIALOG_TARGET_BANDWIDTH } FrequencyDialogTarget;
|
||||
typedef enum FrequencyDialogTarget {
|
||||
FDIALOG_TARGET_DEFAULT,
|
||||
FDIALOG_TARGET_CENTERFREQ,
|
||||
FDIALOG_TARGET_FREQ,
|
||||
FDIALOG_TARGET_BANDWIDTH,
|
||||
FDIALOG_TARGET_WATERFALL_LPS,
|
||||
FDIALOG_TARGET_SPECTRUM_AVG
|
||||
} FrequencyDialogTarget;
|
||||
FrequencyDialog ( wxWindow * parent, wxWindowID id, const wxString & title,
|
||||
DemodulatorInstance *demod = NULL,
|
||||
const wxPoint & pos = wxDefaultPosition,
|
||||
|
@ -52,6 +52,11 @@ void MeterCanvas::setMin(float min_in) {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void MeterCanvas::setUserInputValue(float slider_in) {
|
||||
userInputValue = slider_in;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void MeterCanvas::setInputValue(float slider_in) {
|
||||
userInputValue = inputValue = slider_in;
|
||||
Refresh();
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
void setMax(float max_in);
|
||||
void setMin(float max_in);
|
||||
|
||||
void setUserInputValue(float slider_in);
|
||||
void setInputValue(float slider_in);
|
||||
bool inputChanged();
|
||||
float getInputValue();
|
||||
|
@ -428,3 +428,7 @@ void TuningCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
void TuningCanvas::OnKeyUp(wxKeyEvent& event) {
|
||||
InteractiveCanvas::OnKeyUp(event);
|
||||
}
|
||||
|
||||
TuningCanvas::ActiveState TuningCanvas::getHoverState() {
|
||||
return hoverState;
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
void OnKeyUp(wxKeyEvent& event);
|
||||
|
||||
ActiveState getHoverState();
|
||||
|
||||
private:
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnIdle(wxIdleEvent &event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user