Add start/stop device to menu

This commit is contained in:
Charles J. Cliffe 2016-02-28 23:16:56 -05:00
parent 3df7461a15
commit 05a3e74645
5 changed files with 33 additions and 4 deletions

View File

@ -321,6 +321,8 @@ AppFrame::AppFrame() :
menu->Append(wxID_SDR_DEVICES, "SDR Devices");
menu->AppendSeparator();
menu->Append(wxID_SDR_START_STOP, "Stop / Start Device");
menu->AppendSeparator();
menu->Append(wxID_OPEN, "&Open Session");
menu->Append(wxID_SAVE, "&Save Session");
menu->Append(wxID_SAVEAS, "Save Session &As..");
@ -755,9 +757,22 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
activeDemodulator->setOutputDevice(event.GetId() - wxID_RT_AUDIO_DEVICE);
activeDemodulator = NULL;
}
} else if (event.GetId() == wxApp::s_macAboutMenuItemId) {
}
#ifdef __APPLE__
else if (event.GetId() == wxApp::s_macAboutMenuItemId) {
wxMessageDialog *aboutDlg = new wxMessageDialog(NULL, wxT("CubicSDR v" CUBICSDR_VERSION "\nby Charles J. Cliffe (@ccliffe)\nwww.cubicsdr.com"), wxT("CubicSDR v" CUBICSDR_VERSION), wxOK);
aboutDlg->ShowModal();
}
#endif
else if (event.GetId() == wxID_SDR_START_STOP) {
if (!wxGetApp().getSDRThread()->isTerminated()) {
wxGetApp().stopDevice(true);
} else {
SDRDeviceInfo *dev = wxGetApp().getDevice();
if (dev != nullptr) {
wxGetApp().setDevice(dev);
}
}
} else if (event.GetId() == wxID_SET_TIPS ) {
if (wxGetApp().getConfig()->getShowTips()) {
wxGetApp().getConfig()->setShowTips(false);

View File

@ -30,6 +30,7 @@
#define wxID_SET_IQSWAP 2005
#define wxID_SDR_DEVICES 2008
#define wxID_AGC_CONTROL 2009
#define wxID_SDR_START_STOP 2010
#define wxID_MAIN_SPLITTER 2050
#define wxID_VIS_SPLITTER 2051

View File

@ -136,6 +136,7 @@ CubicSDR::CubicSDR() : appframe(NULL), m_glContext(NULL), frequency(0), offset(0
agcMode.store(true);
soloMode.store(false);
fdlgTarget = FrequencyDialog::FDIALOG_TARGET_DEFAULT;
stoppedDev = nullptr;
}
bool CubicSDR::OnInit() {
@ -498,7 +499,12 @@ void CubicSDR::setSampleRate(long long rate_in) {
}
}
void CubicSDR::stopDevice() {
void CubicSDR::stopDevice(bool store) {
if (store) {
stoppedDev = sdrThread->getDevice();
} else {
stoppedDev = nullptr;
}
sdrThread->setDevice(nullptr);
if (!sdrThread->isTerminated()) {
@ -565,9 +571,15 @@ void CubicSDR::setDevice(SDRDeviceInfo *dev) {
t_SDR = new std::thread(&SDRThread::threadMain, sdrThread);
}
stoppedDev = nullptr;
}
SDRDeviceInfo *CubicSDR::getDevice() {
if (!sdrThread->getDevice() && stoppedDev) {
return stoppedDev;
}
return sdrThread->getDevice();
}

View File

@ -97,7 +97,7 @@ public:
std::vector<SDRDeviceInfo *> *getDevices();
void setDevice(SDRDeviceInfo *dev);
void stopDevice();
void stopDevice(bool store);
SDRDeviceInfo * getDevice();
ScopeVisualProcessor *getScopeProcessor();
@ -216,6 +216,7 @@ private:
FrequencyDialog::FrequencyDialogTarget fdlgTarget;
std::string activeGain;
std::atomic_bool soloMode;
SDRDeviceInfo *stoppedDev;
#ifdef USE_HAMLIB
RigThread *rigThread;
std::thread *t_Rig;

View File

@ -443,7 +443,7 @@ void SDRDevicesDialog::doRefreshDevices() {
editId = nullptr;
removeId = nullptr;
dev = nullptr;
wxGetApp().stopDevice();
wxGetApp().stopDevice(false);
devTree->DeleteAllItems();
devTree->Disable();
m_propertyGrid->Clear();