mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-04-21 10:59:09 -04:00
Menu option for frequency offset (up/down converters)
This commit is contained in:
parent
726113e9ea
commit
1671e625e4
@ -6,6 +6,8 @@
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/numdlg.h"
|
||||
|
||||
#if !wxUSE_GLCANVAS
|
||||
#error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
|
||||
#endif
|
||||
@ -107,7 +109,8 @@ AppFrame::AppFrame() :
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
wxMenu *menu = new wxMenu;
|
||||
// menu->Append(wxID_NEW);
|
||||
// menu->AppendSeparator();
|
||||
menu->Append(wxID_SET_FREQ_OFFSET, "Set Frequency Offset");
|
||||
menu->AppendSeparator();
|
||||
menu->Append(wxID_CLOSE);
|
||||
|
||||
menuBar->Append(menu, wxT("&File"));
|
||||
@ -167,6 +170,9 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||
activeDemodulator->setOutputDevice(event.GetId() - wxID_RT_AUDIO_DEVICE);
|
||||
activeDemodulator = NULL;
|
||||
}
|
||||
} else if (event.GetId() == wxID_SET_FREQ_OFFSET) {
|
||||
long ofs = wxGetNumberFromUser ("Shift the displayed frequency by this amount.\ni.e. -125000000 for -125 MHz", "Frequency (Hz)", "Frequency Offset", 0, -2000000000, 2000000000, this);
|
||||
wxGetApp().setOffset(ofs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <map>
|
||||
|
||||
#define wxID_RT_AUDIO_DEVICE 1000
|
||||
#define wxID_SET_FREQ_OFFSET 2001
|
||||
|
||||
// Define a new frame type
|
||||
class AppFrame: public wxFrame {
|
||||
|
@ -20,6 +20,7 @@ bool CubicSDR::OnInit() {
|
||||
return false;
|
||||
|
||||
frequency = DEFAULT_FREQ;
|
||||
offset = 0;
|
||||
|
||||
audioVisualQueue = new DemodulatorThreadOutputQueue();
|
||||
audioVisualQueue->set_max_num_items(1);
|
||||
@ -110,6 +111,17 @@ void CubicSDR::setFrequency(long long freq) {
|
||||
threadCmdQueueSDR->push(command);
|
||||
}
|
||||
|
||||
long long CubicSDR::getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
void CubicSDR::setOffset(long long ofs) {
|
||||
offset = ofs;
|
||||
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_SET_OFFSET);
|
||||
command.llong_value = ofs;
|
||||
threadCmdQueueSDR->push(command);
|
||||
}
|
||||
|
||||
long long CubicSDR::getFrequency() {
|
||||
return frequency;
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ public:
|
||||
void setFrequency(long long freq);
|
||||
long long getFrequency();
|
||||
|
||||
void setOffset(long long ofs);
|
||||
long long getOffset();
|
||||
|
||||
DemodulatorThreadOutputQueue* getAudioVisualQueue();
|
||||
DemodulatorThreadInputQueue* getIQVisualQueue();
|
||||
DemodulatorMgr &getDemodMgr();
|
||||
@ -45,6 +48,7 @@ private:
|
||||
DemodulatorMgr demodMgr;
|
||||
|
||||
long long frequency;
|
||||
long long offset;
|
||||
|
||||
SDRThread *sdrThread;
|
||||
SDRPostThread *sdrPostThread;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "CubicSDR.h"
|
||||
|
||||
SDRThread::SDRThread(SDRThreadCommandQueue* pQueue) :
|
||||
commandQueue(pQueue), iqDataOutQueue(NULL), terminated(false) {
|
||||
commandQueue(pQueue), iqDataOutQueue(NULL), terminated(false), offset(0) {
|
||||
dev = NULL;
|
||||
sampleRate = SRATE;
|
||||
}
|
||||
@ -137,7 +137,9 @@ void SDRThread::threadMain() {
|
||||
|
||||
if (!cmdQueue->empty()) {
|
||||
bool freq_changed = false;
|
||||
bool offset_changed = false;
|
||||
long long new_freq;
|
||||
long long new_offset;
|
||||
|
||||
while (!cmdQueue->empty()) {
|
||||
SDRThreadCommand command;
|
||||
@ -152,14 +154,24 @@ void SDRThread::threadMain() {
|
||||
}
|
||||
std::cout << "Set frequency: " << new_freq << std::endl;
|
||||
break;
|
||||
case SDRThreadCommand::SDR_THREAD_CMD_SET_OFFSET:
|
||||
offset_changed = true;
|
||||
new_offset = command.llong_value;
|
||||
std::cout << "Set offset: " << new_offset << std::endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset_changed && !freq_changed) {
|
||||
new_freq = frequency;
|
||||
freq_changed = true;
|
||||
offset = new_offset;
|
||||
}
|
||||
if (freq_changed) {
|
||||
frequency = new_freq;
|
||||
rtlsdr_set_center_freq(dev, frequency);
|
||||
rtlsdr_set_center_freq(dev, frequency+offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
class SDRThreadCommand {
|
||||
public:
|
||||
enum SDRThreadCommandEnum {
|
||||
SDR_THREAD_CMD_NULL, SDR_THREAD_CMD_TUNE
|
||||
SDR_THREAD_CMD_NULL, SDR_THREAD_CMD_TUNE, SDR_THREAD_CMD_SET_OFFSET
|
||||
};
|
||||
|
||||
SDRThreadCommand() :
|
||||
@ -76,6 +76,7 @@ public:
|
||||
void terminate();
|
||||
protected:
|
||||
uint32_t sampleRate;
|
||||
long long offset;
|
||||
std::atomic<SDRThreadCommandQueue*> commandQueue;
|
||||
std::atomic<SDRThreadIQDataQueue*> iqDataOutQueue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user