mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 21:58:37 -05:00
Merge pull request #83 from cjcliffe/direct_sampling
Adds RTL-SDR direct sampling mode option
This commit is contained in:
commit
0237c563a0
@ -121,23 +121,37 @@ AppFrame::AppFrame() :
|
|||||||
|
|
||||||
this->SetSizer(vbox);
|
this->SetSizer(vbox);
|
||||||
|
|
||||||
// waterfallCanvas->SetFocusFromKbd();
|
// waterfallCanvas->SetFocusFromKbd();
|
||||||
waterfallCanvas->SetFocus();
|
waterfallCanvas->SetFocus();
|
||||||
|
|
||||||
// SetIcon(wxICON(sample));
|
// SetIcon(wxICON(sample));
|
||||||
|
|
||||||
// Make a menubar
|
// Make a menubar
|
||||||
wxMenuBar *menuBar = new wxMenuBar;
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
wxMenu *menu = new wxMenu;
|
wxMenu *menu = new wxMenu;
|
||||||
// menu->Append(wxID_NEW);
|
|
||||||
menu->Append(wxID_SET_FREQ_OFFSET, "Set Frequency Offset");
|
menu->Append(wxID_SET_FREQ_OFFSET, "Set Frequency Offset");
|
||||||
menu->Append(wxID_SET_PPM, "Set Device PPM");
|
menu->Append(wxID_SET_PPM, "Set Device PPM");
|
||||||
|
|
||||||
|
wxMenu *dsMenu = new wxMenu;
|
||||||
|
|
||||||
|
dsMenu->AppendRadioItem(wxID_SET_DS_OFF, "Off");
|
||||||
|
dsMenu->AppendRadioItem(wxID_SET_DS_I, "I-ADC");
|
||||||
|
dsMenu->AppendRadioItem(wxID_SET_DS_Q, "Q-ADC");
|
||||||
|
|
||||||
|
menu->AppendSubMenu(dsMenu, "Direct Sampling");
|
||||||
|
|
||||||
|
wxMenu *sessionMenu = new wxMenu;
|
||||||
|
sessionMenu->Append(wxID_OPEN, "&Open Session");
|
||||||
|
sessionMenu->Append(wxID_SAVE, "&Save Session");
|
||||||
|
sessionMenu->Append(wxID_SAVEAS, "Save Session &As..");
|
||||||
|
sessionMenu->AppendSeparator();
|
||||||
|
sessionMenu->Append(wxID_RESET, "&Reset Session");
|
||||||
|
|
||||||
|
menu->AppendSubMenu(sessionMenu, "Session");
|
||||||
|
|
||||||
menu->AppendSeparator();
|
menu->AppendSeparator();
|
||||||
menu->Append(wxID_OPEN, "&Open Session");
|
|
||||||
menu->Append(wxID_SAVE, "&Save Session");
|
|
||||||
menu->Append(wxID_SAVEAS, "Save Session &As..");
|
|
||||||
menu->AppendSeparator();
|
|
||||||
menu->Append(wxID_RESET, "&Reset Session");
|
|
||||||
menu->Append(wxID_CLOSE);
|
menu->Append(wxID_CLOSE);
|
||||||
|
|
||||||
menuBar->Append(menu, wxT("&File"));
|
menuBar->Append(menu, wxT("&File"));
|
||||||
@ -320,6 +334,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
|||||||
if (ofs != -1) {
|
if (ofs != -1) {
|
||||||
wxGetApp().setOffset(ofs);
|
wxGetApp().setOffset(ofs);
|
||||||
}
|
}
|
||||||
|
} else if (event.GetId() == wxID_SET_DS_OFF) {
|
||||||
|
wxGetApp().setDirectSampling(0);
|
||||||
|
} else if (event.GetId() == wxID_SET_DS_I) {
|
||||||
|
wxGetApp().setDirectSampling(1);
|
||||||
|
} else if (event.GetId() == wxID_SET_DS_Q) {
|
||||||
|
wxGetApp().setDirectSampling(2);
|
||||||
} else if (event.GetId() == wxID_SET_PPM) {
|
} else if (event.GetId() == wxID_SET_PPM) {
|
||||||
long ofs = wxGetNumberFromUser("Frequency correction for device in PPM.\ni.e. -51 for -51 PPM\n\nNote: you can adjust PPM interactively\nby holding ALT over the frequency tuning bar.\n", "Parts per million (PPM)",
|
long ofs = wxGetNumberFromUser("Frequency correction for device in PPM.\ni.e. -51 for -51 PPM\n\nNote: you can adjust PPM interactively\nby holding ALT over the frequency tuning bar.\n", "Parts per million (PPM)",
|
||||||
"Frequency Correction", wxGetApp().getPPM(), -1000, 1000, this);
|
"Frequency Correction", wxGetApp().getPPM(), -1000, 1000, this);
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
#define wxID_SET_FREQ_OFFSET 2001
|
#define wxID_SET_FREQ_OFFSET 2001
|
||||||
#define wxID_RESET 2002
|
#define wxID_RESET 2002
|
||||||
#define wxID_SET_PPM 2003
|
#define wxID_SET_PPM 2003
|
||||||
|
#define wxID_SET_DS_OFF 2004
|
||||||
|
#define wxID_SET_DS_I 2005
|
||||||
|
#define wxID_SET_DS_Q 2006
|
||||||
|
|
||||||
#define wxID_THEME_DEFAULT 2100
|
#define wxID_THEME_DEFAULT 2100
|
||||||
#define wxID_THEME_SHARP 2101
|
#define wxID_THEME_SHARP 2101
|
||||||
|
@ -45,6 +45,7 @@ bool CubicSDR::OnInit() {
|
|||||||
frequency = DEFAULT_FREQ;
|
frequency = DEFAULT_FREQ;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
ppm = 0;
|
ppm = 0;
|
||||||
|
directSamplingMode = 0;
|
||||||
|
|
||||||
audioVisualQueue = new DemodulatorThreadOutputQueue();
|
audioVisualQueue = new DemodulatorThreadOutputQueue();
|
||||||
audioVisualQueue->set_max_num_items(1);
|
audioVisualQueue->set_max_num_items(1);
|
||||||
@ -170,6 +171,17 @@ void CubicSDR::setOffset(long long ofs) {
|
|||||||
threadCmdQueueSDR->push(command);
|
threadCmdQueueSDR->push(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CubicSDR::setDirectSampling(int mode) {
|
||||||
|
directSamplingMode = mode;
|
||||||
|
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_SET_DIRECT_SAMPLING);
|
||||||
|
command.llong_value = mode;
|
||||||
|
threadCmdQueueSDR->push(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CubicSDR::getDirectSampling() {
|
||||||
|
return directSamplingMode;
|
||||||
|
}
|
||||||
|
|
||||||
long long CubicSDR::getFrequency() {
|
long long CubicSDR::getFrequency() {
|
||||||
return frequency;
|
return frequency;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,9 @@ public:
|
|||||||
void setOffset(long long ofs);
|
void setOffset(long long ofs);
|
||||||
long long getOffset();
|
long long getOffset();
|
||||||
|
|
||||||
|
void setDirectSampling(int mode);
|
||||||
|
int getDirectSampling();
|
||||||
|
|
||||||
void setSampleRate(long long rate_in);
|
void setSampleRate(long long rate_in);
|
||||||
long long getSampleRate();
|
long long getSampleRate();
|
||||||
|
|
||||||
@ -74,6 +77,7 @@ private:
|
|||||||
long long offset;
|
long long offset;
|
||||||
int ppm, snap;
|
int ppm, snap;
|
||||||
long long sampleRate;
|
long long sampleRate;
|
||||||
|
int directSamplingMode;
|
||||||
|
|
||||||
SDRThread *sdrThread;
|
SDRThread *sdrThread;
|
||||||
SDRPostThread *sdrPostThread;
|
SDRPostThread *sdrPostThread;
|
||||||
|
@ -140,6 +140,7 @@ void SDRThread::threadMain() {
|
|||||||
|
|
||||||
long long frequency = DEFAULT_FREQ;
|
long long frequency = DEFAULT_FREQ;
|
||||||
int ppm = wxGetApp().getConfig()->getDevice(devs[deviceId]->getDeviceId())->getPPM();
|
int ppm = wxGetApp().getConfig()->getDevice(devs[deviceId]->getDeviceId())->getPPM();
|
||||||
|
int direct_sampling_mode = 0;
|
||||||
|
|
||||||
rtlsdr_open(&dev, deviceId);
|
rtlsdr_open(&dev, deviceId);
|
||||||
rtlsdr_set_sample_rate(dev, sampleRate);
|
rtlsdr_set_sample_rate(dev, sampleRate);
|
||||||
@ -170,6 +171,7 @@ void SDRThread::threadMain() {
|
|||||||
bool rate_changed = false;
|
bool rate_changed = false;
|
||||||
bool device_changed = false;
|
bool device_changed = false;
|
||||||
bool ppm_changed = false;
|
bool ppm_changed = false;
|
||||||
|
bool direct_sampling_changed = false;
|
||||||
long long new_freq = frequency;
|
long long new_freq = frequency;
|
||||||
long long new_offset = offset;
|
long long new_offset = offset;
|
||||||
long long new_rate = sampleRate;
|
long long new_rate = sampleRate;
|
||||||
@ -209,6 +211,10 @@ void SDRThread::threadMain() {
|
|||||||
new_ppm = (int) command.llong_value;
|
new_ppm = (int) command.llong_value;
|
||||||
//std::cout << "Set PPM: " << new_ppm << std::endl;
|
//std::cout << "Set PPM: " << new_ppm << std::endl;
|
||||||
break;
|
break;
|
||||||
|
case SDRThreadCommand::SDR_THREAD_CMD_SET_DIRECT_SAMPLING:
|
||||||
|
direct_sampling_mode = (int)command.llong_value;
|
||||||
|
direct_sampling_changed = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -222,6 +228,7 @@ void SDRThread::threadMain() {
|
|||||||
rtlsdr_set_freq_correction(dev, ppm);
|
rtlsdr_set_freq_correction(dev, ppm);
|
||||||
rtlsdr_set_agc_mode(dev, 1);
|
rtlsdr_set_agc_mode(dev, 1);
|
||||||
rtlsdr_set_offset_tuning(dev, 0);
|
rtlsdr_set_offset_tuning(dev, 0);
|
||||||
|
rtlsdr_set_direct_sampling(dev, direct_sampling_mode);
|
||||||
rtlsdr_reset_buffer(dev);
|
rtlsdr_reset_buffer(dev);
|
||||||
}
|
}
|
||||||
if (offset_changed && !freq_changed) {
|
if (offset_changed && !freq_changed) {
|
||||||
@ -241,6 +248,9 @@ void SDRThread::threadMain() {
|
|||||||
ppm = new_ppm;
|
ppm = new_ppm;
|
||||||
rtlsdr_set_freq_correction(dev, ppm);
|
rtlsdr_set_freq_correction(dev, ppm);
|
||||||
}
|
}
|
||||||
|
if (direct_sampling_changed) {
|
||||||
|
rtlsdr_set_direct_sampling(dev, direct_sampling_mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rtlsdr_read_sync(dev, buf, BUF_SIZE, &n_read);
|
rtlsdr_read_sync(dev, buf, BUF_SIZE, &n_read);
|
||||||
|
@ -81,7 +81,7 @@ private:
|
|||||||
class SDRThreadCommand {
|
class SDRThreadCommand {
|
||||||
public:
|
public:
|
||||||
enum SDRThreadCommandEnum {
|
enum SDRThreadCommandEnum {
|
||||||
SDR_THREAD_CMD_NULL, SDR_THREAD_CMD_TUNE, SDR_THREAD_CMD_SET_OFFSET, SDR_THREAD_CMD_SET_SAMPLERATE, SDR_THREAD_CMD_SET_PPM, SDR_THREAD_CMD_SET_DEVICE
|
SDR_THREAD_CMD_NULL, SDR_THREAD_CMD_TUNE, SDR_THREAD_CMD_SET_OFFSET, SDR_THREAD_CMD_SET_SAMPLERATE, SDR_THREAD_CMD_SET_PPM, SDR_THREAD_CMD_SET_DEVICE, SDR_THREAD_CMD_SET_DIRECT_SAMPLING
|
||||||
};
|
};
|
||||||
|
|
||||||
SDRThreadCommand() :
|
SDRThreadCommand() :
|
||||||
|
Loading…
Reference in New Issue
Block a user