Fix lock UI update and start on constellation implementation

This commit is contained in:
Dantali0n 2015-06-09 17:00:05 +02:00
parent 9e1601c446
commit b76eafe8df
9 changed files with 72 additions and 82 deletions

View File

@ -61,20 +61,33 @@ AppFrame::AppFrame() :
demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band."); demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band.");
demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0); demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);
demodModeSelectoradv = new ModeSelectorCanvas(this, attribList); demodModeSelectorAdv = new ModeSelectorCanvas(this, attribList);
demodModeSelectoradv->addChoice(DEMOD_TYPE_ASK, "ASK"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_ASK, "ASK");
demodModeSelectoradv->addChoice(DEMOD_TYPE_APSK, "APSK"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_APSK, "APSK");
demodModeSelectoradv->addChoice(DEMOD_TYPE_BPSK, "BPSK"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_BPSK, "BPSK");
demodModeSelectoradv->addChoice(DEMOD_TYPE_DPSK, "DPSK"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_DPSK, "DPSK");
demodModeSelectoradv->addChoice(DEMOD_TYPE_PSK, "PSK"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_PSK, "PSK");
demodModeSelectoradv->addChoice(DEMOD_TYPE_OOK, "OOK"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_OOK, "OOK");
demodModeSelectoradv->addChoice(DEMOD_TYPE_ST, "ST"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_ST, "ST");
demodModeSelectoradv->addChoice(DEMOD_TYPE_SQAM, "SQAM"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_SQAM, "SQAM");
demodModeSelectoradv->addChoice(DEMOD_TYPE_QAM, "QAM"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_QAM, "QAM");
demodModeSelectoradv->addChoice(DEMOD_TYPE_QPSK, "QPSK"); demodModeSelectorAdv->addChoice(DEMOD_TYPE_QPSK, "QPSK");
demodModeSelectoradv->setSelection(DEMOD_TYPE_ASK); demodModeSelectorAdv->setSelection(DEMOD_TYPE_ASK);
demodModeSelectoradv->setHelpTip("Choose advanced modulation types."); demodModeSelectorAdv->setHelpTip("Choose advanced modulation types.");
demodTray->Add(demodModeSelectoradv, 3, wxEXPAND | wxALL, 0); demodTray->Add(demodModeSelectorAdv, 3, wxEXPAND | wxALL, 0);
demodModeSelectorCons = new ModeSelectorCanvas(this, attribList);
demodModeSelectorCons->addChoice(1, "auto");
demodModeSelectorCons->addChoice(2, "2");
demodModeSelectorCons->addChoice(4, "4");
demodModeSelectorCons->addChoice(8, "8");
demodModeSelectorCons->addChoice(16, "16");
demodModeSelectorCons->addChoice(32, "32");
demodModeSelectorCons->addChoice(64, "64");
demodModeSelectorCons->addChoice(128, "128");
demodModeSelectorCons->addChoice(256, "256");
demodModeSelectorCons->setHelpTip("Choose number of constallations types.");
demodTray->Add(demodModeSelectorCons, 2, wxEXPAND | wxALL, 0);
// demodTray->AddSpacer(2); // demodTray->AddSpacer(2);
@ -492,7 +505,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
outputDeviceMenuItems[outputDevice]->Check(true); outputDeviceMenuItems[outputDevice]->Check(true);
int dType = demod->getDemodulatorType(); int dType = demod->getDemodulatorType();
demodModeSelector->setSelection(dType); demodModeSelector->setSelection(dType);
demodModeSelectoradv->setSelection(dType); demodModeSelectorAdv->setSelection(dType);
} }
if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) { if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) {
long long centerFreq = demod->getFrequency(); long long centerFreq = demod->getFrequency();
@ -520,10 +533,10 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
demodSpectrumCanvas->setCenterFrequency(centerFreq); demodSpectrumCanvas->setCenterFrequency(centerFreq);
} }
int dSelection = demodModeSelector->getSelection(); int dSelection = demodModeSelector->getSelection();
int dSelectionadv = demodModeSelectoradv->getSelection(); int dSelectionadv = demodModeSelectorAdv->getSelection();
if (dSelection != -1 && dSelection != demod->getDemodulatorType()) { if (dSelection != -1 && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection); demod->setDemodulatorType(dSelection);
demodModeSelectoradv->setSelection(-1); demodModeSelectorAdv->setSelection(-1);
} }
else if(dSelectionadv != -1 && dSelectionadv != demod->getDemodulatorType()) { else if(dSelectionadv != -1 && dSelectionadv != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelectionadv); demod->setDemodulatorType(dSelectionadv);
@ -547,10 +560,10 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr(); DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
int dSelection = demodModeSelector->getSelection(); int dSelection = demodModeSelector->getSelection();
int dSelectionadv = demodModeSelectoradv->getSelection(); int dSelectionadv = demodModeSelectorAdv->getSelection();
if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) { if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection); mgr->setLastDemodulatorType(dSelection);
demodModeSelectoradv->setSelection(-1); demodModeSelectorAdv->setSelection(-1);
} }
else if(dSelectionadv != -1 && dSelectionadv != mgr->getLastDemodulatorType()) { else if(dSelectionadv != -1 && dSelectionadv != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelectionadv); mgr->setLastDemodulatorType(dSelectionadv);

View File

@ -62,7 +62,8 @@ private:
SpectrumCanvas *spectrumCanvas; SpectrumCanvas *spectrumCanvas;
WaterfallCanvas *waterfallCanvas; WaterfallCanvas *waterfallCanvas;
ModeSelectorCanvas *demodModeSelector; ModeSelectorCanvas *demodModeSelector;
ModeSelectorCanvas *demodModeSelectoradv; ModeSelectorCanvas *demodModeSelectorAdv;
ModeSelectorCanvas *demodModeSelectorCons;
SpectrumCanvas *demodSpectrumCanvas; SpectrumCanvas *demodSpectrumCanvas;
WaterfallCanvas *demodWaterfallCanvas; WaterfallCanvas *demodWaterfallCanvas;
MeterCanvas *demodSignalMeter; MeterCanvas *demodSignalMeter;

View File

@ -21,7 +21,6 @@ DemodulatorInstance::DemodulatorInstance() :
demodulatorThread->setAudioOutputQueue(audioInputQueue); demodulatorThread->setAudioOutputQueue(audioInputQueue);
currentDemodType = demodulatorThread->getDemodulatorType(); currentDemodType = demodulatorThread->getDemodulatorType();
currentDemodLock = demodulatorThread->getDemodulatorLock();
} }
DemodulatorInstance::~DemodulatorInstance() { DemodulatorInstance::~DemodulatorInstance() {
@ -51,7 +50,6 @@ void DemodulatorInstance::run() {
currentFrequency = demodulatorPreThread->getParams().frequency; currentFrequency = demodulatorPreThread->getParams().frequency;
currentDemodType = demodulatorThread->getDemodulatorType(); currentDemodType = demodulatorThread->getDemodulatorType();
currentDemodLock = demodulatorThread->getDemodulatorLock();
currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()]; currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()];
demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate; demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate;
@ -267,16 +265,11 @@ int DemodulatorInstance::getDemodulatorType() {
} }
void DemodulatorInstance::setDemodulatorLock(bool demod_lock_in) { void DemodulatorInstance::setDemodulatorLock(bool demod_lock_in) {
if(demod_lock_in) { demodulatorThread->setDemodulatorLock(demod_lock_in);
currentDemodLock = true;
}
else {
currentDemodLock = false;
}
} }
int DemodulatorInstance::getDemodulatorLock() { int DemodulatorInstance::getDemodulatorLock() {
return currentDemodLock; return demodulatorThread->getDemodulatorLock();
} }
void DemodulatorInstance::setBandwidth(int bw) { void DemodulatorInstance::setBandwidth(int bw) {

View File

@ -101,7 +101,6 @@ private:
long long currentFrequency; long long currentFrequency;
int currentBandwidth; int currentBandwidth;
int currentDemodType; int currentDemodType;
bool currentDemodLock = false;
int currentOutputDevice; int currentOutputDevice;
int currentAudioSampleRate; int currentAudioSampleRate;
bool follow, tracking; bool follow, tracking;

View File

@ -162,7 +162,6 @@ void DemodulatorMgr::updateLastState() {
if (lastActiveDemodulator) { if (lastActiveDemodulator) {
lastBandwidth = lastActiveDemodulator->getBandwidth(); lastBandwidth = lastActiveDemodulator->getBandwidth();
lastDemodType = lastActiveDemodulator->getDemodulatorType(); lastDemodType = lastActiveDemodulator->getDemodulatorType();
lastDemodLock = lastActiveDemodulator->getDemodulatorLock();
lastSquelchEnabled = lastActiveDemodulator->isSquelchEnabled(); lastSquelchEnabled = lastActiveDemodulator->isSquelchEnabled();
lastSquelch = lastActiveDemodulator->getSquelchLevel(); lastSquelch = lastActiveDemodulator->getSquelchLevel();
lastGain = lastActiveDemodulator->getGain(); lastGain = lastActiveDemodulator->getGain();
@ -192,14 +191,6 @@ void DemodulatorMgr::setLastDemodulatorType(int lastDemodType) {
this->lastDemodType = lastDemodType; this->lastDemodType = lastDemodType;
} }
bool DemodulatorMgr::getLastDemodulatorLock() const {
return lastDemodLock;
}
void DemodulatorMgr::setLastDemodulatorLock(bool lastDemodLock) {
this->lastDemodLock = lastDemodLock;
}
float DemodulatorMgr::getLastGain() const { float DemodulatorMgr::getLastGain() const {
return lastGain; return lastGain;
} }

View File

@ -27,9 +27,6 @@ public:
int getLastDemodulatorType() const; int getLastDemodulatorType() const;
void setLastDemodulatorType(int lastDemodType); void setLastDemodulatorType(int lastDemodType);
bool getLastDemodulatorLock() const;
void setLastDemodulatorLock(bool lastDemodLock);
float getLastGain() const; float getLastGain() const;
void setLastGain(float lastGain); void setLastGain(float lastGain);
@ -55,7 +52,6 @@ private:
int lastBandwidth; int lastBandwidth;
int lastDemodType; int lastDemodType;
bool lastDemodLock;
bool lastSquelchEnabled; bool lastSquelchEnabled;
float lastSquelch; float lastSquelch;
float lastGain; float lastGain;

View File

@ -26,17 +26,19 @@ DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQue
demodAM = demodAM_DSB_CSP; demodAM = demodAM_DSB_CSP;
// advanced demodulators // advanced demodulators
demodASK = modem_create(LIQUID_MODEM_ASK2); demodASK = modem_create(LIQUID_MODEM_ASK256);
demodAPSK = modem_create(LIQUID_MODEM_APSK4); demodAPSK = modem_create(LIQUID_MODEM_APSK256);
demodBPSK = modem_create(LIQUID_MODEM_BPSK); demodBPSK = modem_create(LIQUID_MODEM_BPSK);
demodDPSK = modem_create(LIQUID_MODEM_DPSK4); demodDPSK = modem_create(LIQUID_MODEM_DPSK256);
demodPSK = modem_create(LIQUID_MODEM_PSK2); demodPSK = modem_create(LIQUID_MODEM_PSK256);
demodOOK = modem_create(LIQUID_MODEM_OOK); demodOOK = modem_create(LIQUID_MODEM_OOK);
demodSQAM = modem_create(LIQUID_MODEM_SQAM32); demodSQAM = modem_create(LIQUID_MODEM_SQAM128);
demodST = modem_create(LIQUID_MODEM_V29); demodST = modem_create(LIQUID_MODEM_V29);
demodQAM = modem_create(LIQUID_MODEM_QAM4); demodQAM = modem_create(LIQUID_MODEM_QAM256);
demodQPSK = modem_create(LIQUID_MODEM_QPSK); demodQPSK = modem_create(LIQUID_MODEM_QPSK);
currentDemodLock = false;
} }
DemodulatorThread::~DemodulatorThread() { DemodulatorThread::~DemodulatorThread() {
} }
@ -200,64 +202,65 @@ void DemodulatorThread::threadMain() {
case DEMOD_TYPE_ASK: case DEMOD_TYPE_ASK:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodASK, inp->data[i], &bitstream); modem_demodulate(demodASK, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodASK); updateDemodulatorLock(demodASK, 0.8f);
break; break;
case DEMOD_TYPE_BPSK: case DEMOD_TYPE_BPSK:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodBPSK, inp->data[i], &bitstream); modem_demodulate(demodBPSK, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodBPSK); updateDemodulatorLock(demodBPSK, 0.8f);
break; break;
case DEMOD_TYPE_DPSK: case DEMOD_TYPE_DPSK:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodDPSK, inp->data[i], &bitstream); modem_demodulate(demodDPSK, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodDPSK); updateDemodulatorLock(demodDPSK, 0.8f);
break; break;
case DEMOD_TYPE_PSK: case DEMOD_TYPE_PSK:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodPSK, inp->data[i], &bitstream); modem_demodulate(demodPSK, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodPSK); updateDemodulatorLock(demodPSK, 0.8f);
break; break;
case DEMOD_TYPE_OOK: case DEMOD_TYPE_OOK:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodOOK, inp->data[i], &bitstream); modem_demodulate(demodOOK, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodOOK); updateDemodulatorLock(demodOOK, 0.8f);
break; break;
case DEMOD_TYPE_SQAM: case DEMOD_TYPE_SQAM:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodSQAM, inp->data[i], &bitstream); modem_demodulate(demodSQAM, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodSQAM); updateDemodulatorLock(demodSQAM, 0.8f);
break; break;
case DEMOD_TYPE_ST: case DEMOD_TYPE_ST:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodST, inp->data[i], &bitstream); modem_demodulate(demodST, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodST); updateDemodulatorLock(demodST, 0.8f);
break; break;
case DEMOD_TYPE_QAM: case DEMOD_TYPE_QAM:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodQAM, inp->data[i], &bitstream); modem_demodulate(demodQAM, inp->data[i], &bitstream);
std::cout << bitstream << std::endl; // std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodQAM); updateDemodulatorLock(demodQAM, 0.5f);
break; break;
case DEMOD_TYPE_QPSK: case DEMOD_TYPE_QPSK:
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodQPSK, inp->data[i], &bitstream); modem_demodulate(demodQPSK, inp->data[i], &bitstream);
// std::cout << bitstream << std::endl;
} }
updateDemodulatorLock(demodQPSK); updateDemodulatorLock(demodQPSK, 0.8f);
break; break;
} }
@ -462,10 +465,10 @@ void DemodulatorThread::threadMain() {
demodAM = demodAM_DSB_CSP; demodAM = demodAM_DSB_CSP;
ampmodem_reset(demodAM); ampmodem_reset(demodAM);
break; break;
case DEMOD_TYPE_QPSK: // case DEMOD_TYPE_QPSK:
std::cout << "reset modem qpsk" << std::endl; // std::cout << "reset modem qpsk" << std::endl;
modem_reset(demodQPSK); // modem_reset(demodQPSK);
break; // break;
} }
demodulatorType = newDemodType; demodulatorType = newDemodType;
} }
@ -562,19 +565,14 @@ int DemodulatorThread::getDemodulatorType() {
} }
void DemodulatorThread::setDemodulatorLock(bool demod_lock_in) { void DemodulatorThread::setDemodulatorLock(bool demod_lock_in) {
if(demod_lock_in) { demod_lock_in ? currentDemodLock = true : currentDemodLock = false;
currentDemodLock = true;
}
else {
currentDemodLock = false;
}
} }
int DemodulatorThread::getDemodulatorLock() { int DemodulatorThread::getDemodulatorLock() {
return currentDemodLock; return currentDemodLock;
} }
void DemodulatorThread::updateDemodulatorLock(modem demod) { void DemodulatorThread::updateDemodulatorLock(modem demod, float sensitivity) {
modem_get_demodulator_evm(demod) <= 0.8f ? setDemodulatorLock(true) : setDemodulatorLock(false); modem_get_demodulator_evm(demod) <= sensitivity ? setDemodulatorLock(true) : setDemodulatorLock(false);
} }

View File

@ -96,6 +96,6 @@ protected:
std::atomic<float> signalLevel; std::atomic<float> signalLevel;
bool squelchEnabled; bool squelchEnabled;
bool currentDemodLock = false; bool currentDemodLock;
void updateDemodulatorLock(modem demod); void updateDemodulatorLock(modem demod, float sensitivity);
}; };

View File

@ -306,7 +306,6 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBColor color, lon
break; break;
} }
// add lock to string if we have an lock // add lock to string if we have an lock
if(demod->getDemodulatorLock()) { if(demod->getDemodulatorLock()) {
demodStr = demodStr + " Lock"; demodStr = demodStr + " Lock";