mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
windows fix-up
This commit is contained in:
commit
c77d2c9408
@ -35,11 +35,10 @@ EVT_CLOSE(AppFrame::OnClose)
|
||||
EVT_MENU(wxID_ANY, AppFrame::OnMenu)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread)
|
||||
EVT_IDLE(AppFrame::OnIdle)
|
||||
EVT_TIMER(FRAME_TIMER_ID, AppFrame::OnTimer)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
AppFrame::AppFrame() :
|
||||
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL), frame_timer(this, FRAME_TIMER_ID) {
|
||||
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
|
||||
#ifdef __linux__
|
||||
SetIcon(wxICON(cubicsdr));
|
||||
@ -107,6 +106,7 @@ AppFrame::AppFrame() :
|
||||
demodGainMeter = new MeterCanvas(this, attribList);
|
||||
demodGainMeter->setMax(2.0);
|
||||
demodGainMeter->setHelpTip("Current Demodulator Gain Level. Click / Drag to set Gain level.");
|
||||
demodGainMeter->setShowUserInput(false);
|
||||
demodTray->Add(demodGainMeter, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
vbox->Add(demodTray, 12, wxEXPAND | wxALL, 0);
|
||||
@ -118,9 +118,10 @@ AppFrame::AppFrame() :
|
||||
wxGetApp().getSpectrumProcesor()->attachOutput(spectrumCanvas->getVisualDataQueue());
|
||||
|
||||
spectrumAvgMeter = new MeterCanvas(this, attribList);
|
||||
spectrumAvgMeter->setMax(3.0);
|
||||
spectrumAvgMeter->setInputValue(1.0);
|
||||
|
||||
spectrumAvgMeter->setMax(1.0);
|
||||
spectrumAvgMeter->setLevel(0.65);
|
||||
spectrumAvgMeter->setShowUserInput(false);
|
||||
|
||||
spectrumSizer->Add(spectrumCanvas, 63, wxEXPAND | wxALL, 0);
|
||||
spectrumSizer->AddSpacer(1);
|
||||
spectrumSizer->Add(spectrumAvgMeter, 1, wxEXPAND | wxALL, 0);
|
||||
@ -143,7 +144,8 @@ AppFrame::AppFrame() :
|
||||
|
||||
waterfallSpeedMeter = new MeterCanvas(this, attribList);
|
||||
waterfallSpeedMeter->setMax(sqrt(1024));
|
||||
waterfallSpeedMeter->setInputValue(sqrt(DEFAULT_WATERFALL_LPS));
|
||||
waterfallSpeedMeter->setLevel(sqrt(DEFAULT_WATERFALL_LPS));
|
||||
waterfallSpeedMeter->setShowUserInput(false);
|
||||
|
||||
wfSizer->Add(waterfallCanvas, 63, wxEXPAND | wxALL, 0);
|
||||
wfSizer->AddSpacer(1);
|
||||
@ -261,7 +263,7 @@ AppFrame::AppFrame() :
|
||||
// sampleRateMenuItems[wxID_BANDWIDTH_3000M] = menu->AppendRadioItem(wxID_BANDWIDTH_3000M, "3.0M");
|
||||
sampleRateMenuItems[wxID_BANDWIDTH_3200M] = menu->AppendRadioItem(wxID_BANDWIDTH_3200M, "3.2M");
|
||||
|
||||
sampleRateMenuItems[wxID_BANDWIDTH_2400M]->Check(true);
|
||||
sampleRateMenuItems[wxID_BANDWIDTH_2048M]->Check(true);
|
||||
|
||||
menuBar->Append(menu, wxT("&Input Bandwidth"));
|
||||
|
||||
@ -402,11 +404,6 @@ void AppFrame::initDeviceParams(std::string deviceId) {
|
||||
if (devConfig->getIQSwap()) {
|
||||
iqSwapMenuItem->Check();
|
||||
}
|
||||
|
||||
if (!frame_timer.IsRunning()) {
|
||||
// frame rate = 1000 / 30 = 33ms
|
||||
frame_timer.Start(25);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -601,10 +598,6 @@ void AppFrame::OnThread(wxCommandEvent& event) {
|
||||
}
|
||||
|
||||
void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void AppFrame::OnTimer(wxTimerEvent& event) {
|
||||
|
||||
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
@ -719,9 +712,15 @@ void AppFrame::OnTimer(wxTimerEvent& event) {
|
||||
|
||||
wxGetApp().getScopeProcessor()->run();
|
||||
wxGetApp().getSpectrumDistributor()->run();
|
||||
|
||||
|
||||
SpectrumVisualProcessor *proc = wxGetApp().getSpectrumProcesor();
|
||||
|
||||
if (spectrumAvgMeter->inputChanged()) {
|
||||
float val = spectrumAvgMeter->getInputValue();
|
||||
spectrumAvgMeter->setLevel(val);
|
||||
proc->setFFTAverageRate(val);
|
||||
}
|
||||
|
||||
proc->setView(spectrumCanvas->getViewState());
|
||||
proc->setBandwidth(spectrumCanvas->getBandwidth());
|
||||
proc->setCenterFrequency(spectrumCanvas->getCenterFrequency());
|
||||
@ -747,7 +746,8 @@ void AppFrame::OnTimer(wxTimerEvent& event) {
|
||||
}
|
||||
|
||||
if (waterfallSpeedMeter->inputChanged()) {
|
||||
int val = (int)waterfallSpeedMeter->getInputValue();
|
||||
float val = waterfallSpeedMeter->getInputValue();
|
||||
waterfallSpeedMeter->setLevel(val);
|
||||
fftDistrib.setLinesPerSecond((int)ceil(val*val));
|
||||
wxGetApp().getWaterfallVisualQueue()->set_max_num_items((int)ceil(val*val));
|
||||
}
|
||||
@ -761,33 +761,15 @@ void AppFrame::OnTimer(wxTimerEvent& event) {
|
||||
while (!wproc->isInputEmpty()) {
|
||||
wproc->run();
|
||||
}
|
||||
|
||||
waterfallCanvas->processInputQueue();
|
||||
demodWaterfallCanvas->processInputQueue();
|
||||
|
||||
#ifndef _WIN32
|
||||
usleep(5000);
|
||||
#endif
|
||||
|
||||
scopeCanvas->Refresh();
|
||||
|
||||
waterfallCanvas->Refresh();
|
||||
spectrumCanvas->Refresh();
|
||||
|
||||
demodWaterfallCanvas->Refresh();
|
||||
demodSpectrumCanvas->Refresh();
|
||||
|
||||
demodSignalMeter->Refresh();
|
||||
demodGainMeter->Refresh();
|
||||
|
||||
if (demodTuner->getMouseTracker()->mouseInView() || demodTuner->changed()) {
|
||||
demodTuner->Refresh();
|
||||
}
|
||||
if (demodModeSelector->getMouseTracker()->mouseInView()) {
|
||||
demodModeSelector->Refresh();
|
||||
}
|
||||
if (waterfallSpeedMeter->getMouseTracker()->mouseInView()) {
|
||||
waterfallSpeedMeter->Refresh();
|
||||
}
|
||||
if (spectrumAvgMeter->getMouseTracker()->mouseInView()) {
|
||||
spectrumAvgMeter->Refresh();
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
void AppFrame::saveSession(std::string fileName) {
|
||||
|
@ -50,8 +50,6 @@
|
||||
#define wxID_AUDIO_BANDWIDTH_BASE 9000
|
||||
#define wxID_AUDIO_DEVICE_MULTIPLIER 50
|
||||
|
||||
#define FRAME_TIMER_ID 1000
|
||||
|
||||
// Define a new frame type
|
||||
class AppFrame: public wxFrame {
|
||||
public:
|
||||
@ -69,7 +67,6 @@ private:
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void OnNewWindow(wxCommandEvent& event);
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
void OnTimer(wxTimerEvent& event);
|
||||
|
||||
ScopeCanvas *scopeCanvas;
|
||||
SpectrumCanvas *spectrumCanvas;
|
||||
@ -96,7 +93,6 @@ private:
|
||||
wxMenuItem *iqSwapMenuItem;
|
||||
|
||||
std::string currentSessionFile;
|
||||
wxTimer frame_timer;
|
||||
|
||||
FFTDataDistributor fftDistrib;
|
||||
DemodulatorThreadInputQueue fftQueue;
|
||||
|
@ -78,9 +78,11 @@ bool CubicSDR::OnInit() {
|
||||
scopeProcessor.setInput(pipeAudioVisualData);
|
||||
|
||||
// I/Q Data
|
||||
pipeSDRIQData = new SDRThreadIQDataQueue;
|
||||
pipeSDRIQData = new SDRThreadIQDataQueue();
|
||||
pipeSDRCommand = new SDRThreadCommandQueue();
|
||||
|
||||
pipeSDRIQData->set_max_num_items(1);
|
||||
|
||||
sdrThread = new SDRThread();
|
||||
sdrThread->setInputQueue("SDRCommandQueue",pipeSDRCommand);
|
||||
sdrThread->setOutputQueue("IQDataOutput",pipeSDRIQData);
|
||||
|
@ -27,10 +27,10 @@ const char filePathSeparator =
|
||||
|
||||
#define BUF_SIZE (16384*6)
|
||||
|
||||
#define DEFAULT_SAMPLE_RATE 2400000
|
||||
#define DEFAULT_SAMPLE_RATE 2048000
|
||||
#define DEFAULT_FFT_SIZE 2048
|
||||
|
||||
#define DEFAULT_DEMOD_TYPE 1
|
||||
#define DEFAULT_DEMOD_BW 200000
|
||||
|
||||
#define DEFAULT_WATERFALL_LPS 24
|
||||
#define DEFAULT_WATERFALL_LPS 30
|
@ -5,6 +5,7 @@
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "ThreadQueue.h"
|
||||
|
||||
@ -63,6 +64,10 @@ public:
|
||||
return buf;
|
||||
}
|
||||
|
||||
// if (outputBuffers.size() > 100) {
|
||||
// std::cout << "Buffer over 100.." << std::endl;
|
||||
// }
|
||||
|
||||
buf = new BufferType();
|
||||
outputBuffers.push_back(buf);
|
||||
|
||||
|
@ -94,7 +94,7 @@ void DemodulatorThread::run() {
|
||||
while (!terminated) {
|
||||
DemodulatorThreadPostIQData *inp;
|
||||
iqInputQueue->pop(inp);
|
||||
std::lock_guard < std::mutex > lock(inp->m_mutex);
|
||||
// std::lock_guard < std::mutex > lock(inp->m_mutex);
|
||||
|
||||
int bufSize = inp->data.size();
|
||||
|
||||
|
@ -15,6 +15,7 @@ SpectrumVisualProcessor::SpectrumVisualProcessor() : lastInputBandwidth(0), last
|
||||
fft_ceil_ma = fft_ceil_maa = 100.0;
|
||||
fft_floor_ma = fft_floor_maa = 0.0;
|
||||
desiredInputSize = 0;
|
||||
fft_average_rate = 0.65;
|
||||
}
|
||||
|
||||
SpectrumVisualProcessor::~SpectrumVisualProcessor() {
|
||||
@ -29,6 +30,9 @@ void SpectrumVisualProcessor::setView(bool bView) {
|
||||
is_view.store(bView);
|
||||
}
|
||||
|
||||
void SpectrumVisualProcessor::setFFTAverageRate(float fftAverageRate) {
|
||||
this->fft_average_rate = fftAverageRate;
|
||||
}
|
||||
|
||||
void SpectrumVisualProcessor::setCenterFrequency(long long centerFreq_in) {
|
||||
centerFreq.store(centerFreq_in);
|
||||
@ -260,11 +264,11 @@ void SpectrumVisualProcessor::process() {
|
||||
|
||||
for (int i = 0, iMax = fftSize; i < iMax; i++) {
|
||||
if (is_view.load()) {
|
||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * 0.65;
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * 0.65;
|
||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate;
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
||||
} else {
|
||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * 0.65;
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * 0.65;
|
||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate;
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
||||
}
|
||||
|
||||
if (fft_result_maa[i] > fft_ceil) {
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
bool isView();
|
||||
void setView(bool bView);
|
||||
|
||||
void setFFTAverageRate(float fftAverageRate);
|
||||
|
||||
void setCenterFrequency(long long centerFreq_in);
|
||||
long long getCenterFrequency();
|
||||
|
||||
@ -50,6 +52,7 @@ private:
|
||||
|
||||
double fft_ceil_ma, fft_ceil_maa;
|
||||
double fft_floor_ma, fft_floor_maa;
|
||||
float fft_average_rate;
|
||||
|
||||
std::vector<double> fft_result;
|
||||
std::vector<double> fft_result_ma;
|
||||
|
@ -86,11 +86,14 @@ void SDRPostThread::run() {
|
||||
std::vector<liquid_float_complex> fpData;
|
||||
std::vector<liquid_float_complex> dataOut;
|
||||
|
||||
iqDataInQueue->set_max_num_items(0);
|
||||
|
||||
while (!terminated) {
|
||||
SDRThreadIQData *data_in;
|
||||
|
||||
iqDataInQueue->pop(data_in);
|
||||
// std::lock_guard < std::mutex > lock(data_in->m_mutex);
|
||||
int num_vis_samples = this->num_vis_samples;
|
||||
|
||||
if (data_in && data_in->data.size()) {
|
||||
int dataSize = data_in->data.size()/2;
|
||||
@ -120,6 +123,10 @@ void SDRPostThread::run() {
|
||||
visualDataOut->busy_rw.lock();
|
||||
visualDataOut->setRefCount(1);
|
||||
|
||||
if (num_vis_samples > dataOut.size()) {
|
||||
num_vis_samples = dataOut.size();
|
||||
}
|
||||
|
||||
if (visualDataOut->data.size() < num_vis_samples) {
|
||||
if (visualDataOut->data.capacity() < num_vis_samples) {
|
||||
visualDataOut->data.reserve(num_vis_samples);
|
||||
@ -198,8 +205,12 @@ void SDRPostThread::run() {
|
||||
}
|
||||
|
||||
if (iqDataOutQueue != NULL) {
|
||||
iqDataOutQueue->push(demodDataOut);
|
||||
pushedData = true;
|
||||
if (!iqDataOutQueue->full()) {
|
||||
iqDataOutQueue->push(demodDataOut);
|
||||
pushedData = true;
|
||||
} else {
|
||||
demodDataOut->decRefCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (!pushedData && iqDataOutQueue == NULL) {
|
||||
|
@ -25,7 +25,7 @@ EVT_ENTER_WINDOW(MeterCanvas::OnMouseEnterWindow)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
MeterCanvas::MeterCanvas(wxWindow *parent, int *attribList) :
|
||||
InteractiveCanvas(parent, attribList), level(0), level_max(1), inputValue(0), userInputValue(0) {
|
||||
InteractiveCanvas(parent, attribList), level(0), level_max(1), inputValue(0), userInputValue(0), showUserInput(true) {
|
||||
|
||||
glContext = new MeterContext(this, &wxGetApp().GetContext(this));
|
||||
}
|
||||
@ -58,6 +58,10 @@ float MeterCanvas::getInputValue() {
|
||||
return userInputValue;
|
||||
}
|
||||
|
||||
void MeterCanvas::setShowUserInput(bool showUserInput) {
|
||||
this->showUserInput = showUserInput;
|
||||
}
|
||||
|
||||
void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
wxPaintDC dc(this);
|
||||
const wxSize ClientSize = GetClientSize();
|
||||
@ -68,18 +72,23 @@ void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
||||
|
||||
glContext->DrawBegin();
|
||||
glContext->Draw(ThemeMgr::mgr.currentTheme->generalBackground.r, ThemeMgr::mgr.currentTheme->generalBackground.g, ThemeMgr::mgr.currentTheme->generalBackground.b, 0.5, 1.0);
|
||||
|
||||
if (mouseTracker.mouseInView()) {
|
||||
glContext->Draw(0.4, 0.4, 0.4, 0.5, mouseTracker.getMouseY());
|
||||
}
|
||||
glContext->Draw(ThemeMgr::mgr.currentTheme->meterLevel.r, ThemeMgr::mgr.currentTheme->meterLevel.g, ThemeMgr::mgr.currentTheme->meterLevel.b, 0.5, level / level_max);
|
||||
glContext->Draw(ThemeMgr::mgr.currentTheme->meterValue.r, ThemeMgr::mgr.currentTheme->meterValue.g, ThemeMgr::mgr.currentTheme->meterValue.b, 0.5, userInputValue / level_max);
|
||||
if (showUserInput) {
|
||||
glContext->Draw(ThemeMgr::mgr.currentTheme->meterValue.r, ThemeMgr::mgr.currentTheme->meterValue.g, ThemeMgr::mgr.currentTheme->meterValue.b, 0.5, userInputValue / level_max);
|
||||
}
|
||||
glContext->DrawEnd();
|
||||
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
void MeterCanvas::OnIdle(wxIdleEvent &event) {
|
||||
event.Skip();
|
||||
Refresh();
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
void MeterCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
void setInputValue(float slider_in);
|
||||
bool inputChanged();
|
||||
float getInputValue();
|
||||
void setShowUserInput(bool showUserInput);
|
||||
|
||||
void setHelpTip(std::string tip);
|
||||
|
||||
@ -48,6 +49,8 @@ private:
|
||||
float inputValue;
|
||||
float userInputValue;
|
||||
|
||||
bool showUserInput;
|
||||
|
||||
std::string helpTip;
|
||||
//
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
@ -72,7 +72,8 @@ void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::OnIdle(wxIdleEvent &event) {
|
||||
event.Skip();
|
||||
Refresh();
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
|
@ -87,7 +87,8 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void ScopeCanvas::OnIdle(wxIdleEvent &event) {
|
||||
event.Skip();
|
||||
Refresh();
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
ScopeRenderDataQueue *ScopeCanvas::getInputQueue() {
|
||||
|
@ -85,7 +85,8 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
|
||||
|
||||
void SpectrumCanvas::OnIdle(wxIdleEvent &event) {
|
||||
event.Skip();
|
||||
Refresh();
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
|
||||
|
@ -252,6 +252,10 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
|
||||
dragging = false;
|
||||
}
|
||||
}
|
||||
if (mouseTracker.mouseInView() || changed()) {
|
||||
Refresh();
|
||||
}
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
|
@ -68,6 +68,25 @@ void WaterfallCanvas::attachSpectrumCanvas(SpectrumCanvas *canvas_in) {
|
||||
spectrumCanvas = canvas_in;
|
||||
}
|
||||
|
||||
void WaterfallCanvas::processInputQueue() {
|
||||
if (!glContext) {
|
||||
return;
|
||||
}
|
||||
glContext->SetCurrent(*this);
|
||||
|
||||
while (!visualDataQueue.empty()) {
|
||||
SpectrumVisualData *vData;
|
||||
|
||||
visualDataQueue.pop(vData);
|
||||
|
||||
if (vData) {
|
||||
waterfallPanel.setPoints(vData->spectrum_points);
|
||||
waterfallPanel.step();
|
||||
vData->decRefCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
wxPaintDC dc(this);
|
||||
|
||||
@ -139,18 +158,6 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
glContext->SetCurrent(*this);
|
||||
initGLExtensions();
|
||||
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
||||
|
||||
while (!visualDataQueue.empty()) {
|
||||
SpectrumVisualData *vData;
|
||||
|
||||
visualDataQueue.pop(vData);
|
||||
|
||||
if (vData) {
|
||||
waterfallPanel.setPoints(vData->spectrum_points);
|
||||
waterfallPanel.step();
|
||||
vData->decRefCount();
|
||||
}
|
||||
}
|
||||
|
||||
glContext->BeginDraw(0,0,0);
|
||||
|
||||
@ -347,7 +354,8 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
}
|
||||
}
|
||||
void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
|
||||
event.Skip();
|
||||
Refresh();
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
DragState getNextDragState();
|
||||
|
||||
void attachSpectrumCanvas(SpectrumCanvas *canvas_in);
|
||||
void processInputQueue();
|
||||
SpectrumVisualDataQueue *getVisualDataQueue();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user