Requested Constellations & actual Constellations are now separated.

This commit is contained in:
Dantali0n 2015-06-10 19:39:08 +02:00
parent f71d04eb75
commit 951a1ee9c6
5 changed files with 368 additions and 18 deletions

View File

@ -536,19 +536,24 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
} }
int dSelection = demodModeSelector->getSelection(); int dSelection = demodModeSelector->getSelection();
int dSelectionadv = demodModeSelectorAdv->getSelection(); int dSelectionadv = demodModeSelectorAdv->getSelection();
int dSelectionCons = demodModeSelectorCons->getSelection();
// basic demodulators // basic demodulators
if (dSelection != -1 && dSelection != demod->getDemodulatorType()) { if (dSelection != -1 && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection); demod->setDemodulatorType(dSelection);
demodModeSelectorAdv->setSelection(-1); demodModeSelectorAdv->setSelection(-1);
} }
// advanced demodulators // advanced demodulators
else if(dSelectionadv != -1 && dSelectionadv != demod->getDemodulatorType()) { else if (dSelectionadv != -1 && dSelectionadv != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelectionadv); demod->setDemodulatorType(dSelectionadv);
demod->setDemodulatorCons(demodModeSelectorCons->getSelection());
// std::cout << "updating demodulator" << std::endl;
demodModeSelector->setSelection(-1); demodModeSelector->setSelection(-1);
} }
// set constellations
if (dSelectionCons != demod->getDemodulatorCons()) {
demod->setDemodulatorCons(dSelectionCons);
}
demodWaterfallCanvas->setBandwidth(demodBw); demodWaterfallCanvas->setBandwidth(demodBw);
demodSpectrumCanvas->setBandwidth(demodBw); demodSpectrumCanvas->setBandwidth(demodBw);
} }
@ -567,6 +572,8 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
int dSelection = demodModeSelector->getSelection(); int dSelection = demodModeSelector->getSelection();
int dSelectionadv = demodModeSelectorAdv->getSelection(); int dSelectionadv = demodModeSelectorAdv->getSelection();
int dSelectionCons = demodModeSelectorCons->getSelection();
// basic demodulators // basic demodulators
if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) { if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection); mgr->setLastDemodulatorType(dSelection);
@ -575,10 +582,14 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
// advanced demodulators // advanced demodulators
else if(dSelectionadv != -1 && dSelectionadv != mgr->getLastDemodulatorType()) { else if(dSelectionadv != -1 && dSelectionadv != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelectionadv); mgr->setLastDemodulatorType(dSelectionadv);
mgr->setLastDemodulatorCons(demodModeSelectorCons->getSelection());
demodModeSelector->setSelection(-1); demodModeSelector->setSelection(-1);
} }
// set constellations
if (dSelectionCons != mgr->getLastDemodulatorCons()) {
mgr->setLastDemodulatorCons(dSelectionCons);
}
demodGainMeter->setLevel(mgr->getLastGain()); demodGainMeter->setLevel(mgr->getLastGain());
if (demodSignalMeter->inputChanged()) { if (demodSignalMeter->inputChanged()) {
mgr->setLastSquelchLevel(demodSignalMeter->getInputValue()); mgr->setLastSquelchLevel(demodSignalMeter->getInputValue());

View File

@ -17,7 +17,6 @@ DemodulatorMgr::~DemodulatorMgr() {
DemodulatorInstance *DemodulatorMgr::newThread() { DemodulatorInstance *DemodulatorMgr::newThread() {
DemodulatorInstance *newDemod = new DemodulatorInstance; DemodulatorInstance *newDemod = new DemodulatorInstance;
demods.push_back(newDemod); demods.push_back(newDemod);
std::stringstream label; std::stringstream label;

View File

@ -26,11 +26,13 @@ DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQue
demodAM = demodAM_DSB_CSP; demodAM = demodAM_DSB_CSP;
// advanced demodulators // advanced demodulators
// This could properly be done easier. // needs refactoring
// should look into dynamicly creating modems, so only the required type exists.
demodulatorCons = 2; demodulatorCons = 2;
currentDemodCons = 0;
demodASK = modem_create(LIQUID_MODEM_ASK2); demodASK = demodASK2;
demodASK2 = modem_create(LIQUID_MODEM_ASK2); demodASK2 = modem_create(LIQUID_MODEM_ASK2);
demodASK4 = modem_create(LIQUID_MODEM_ASK4); demodASK4 = modem_create(LIQUID_MODEM_ASK4);
demodASK8 = modem_create(LIQUID_MODEM_ASK8); demodASK8 = modem_create(LIQUID_MODEM_ASK8);
@ -40,14 +42,54 @@ DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQue
demodASK128 = modem_create(LIQUID_MODEM_ASK128); demodASK128 = modem_create(LIQUID_MODEM_ASK128);
demodASK256 = modem_create(LIQUID_MODEM_ASK256); demodASK256 = modem_create(LIQUID_MODEM_ASK256);
demodAPSK = modem_create(LIQUID_MODEM_APSK256); demodAPSK = demodAPSK4;
demodAPSK4 = modem_create(LIQUID_MODEM_APSK4);
demodAPSK8 = modem_create(LIQUID_MODEM_APSK8);
demodAPSK16 = modem_create(LIQUID_MODEM_APSK16);
demodAPSK32 = modem_create(LIQUID_MODEM_APSK32);
demodAPSK64 = modem_create(LIQUID_MODEM_APSK64);
demodAPSK128 = modem_create(LIQUID_MODEM_APSK128);
demodAPSK256 = modem_create(LIQUID_MODEM_APSK256);
demodBPSK = modem_create(LIQUID_MODEM_BPSK); demodBPSK = modem_create(LIQUID_MODEM_BPSK);
demodDPSK = modem_create(LIQUID_MODEM_DPSK256);
demodPSK = modem_create(LIQUID_MODEM_PSK256); demodDPSK = demodDPSK2;
demodDPSK2 = modem_create(LIQUID_MODEM_DPSK2);
demodDPSK4 = modem_create(LIQUID_MODEM_DPSK4);
demodDPSK8 = modem_create(LIQUID_MODEM_DPSK8);
demodDPSK16 = modem_create(LIQUID_MODEM_DPSK16);
demodDPSK32 = modem_create(LIQUID_MODEM_DPSK32);
demodDPSK64 = modem_create(LIQUID_MODEM_DPSK64);
demodDPSK128 = modem_create(LIQUID_MODEM_DPSK128);
demodDPSK256 = modem_create(LIQUID_MODEM_DPSK256);
demodPSK = demodPSK2;
demodPSK2 = modem_create(LIQUID_MODEM_PSK2);
demodPSK4 = modem_create(LIQUID_MODEM_PSK4);
demodPSK8 = modem_create(LIQUID_MODEM_PSK8);
demodPSK16 = modem_create(LIQUID_MODEM_PSK16);
demodPSK32 = modem_create(LIQUID_MODEM_PSK32);
demodPSK64 = modem_create(LIQUID_MODEM_PSK64);
demodPSK128 = modem_create(LIQUID_MODEM_PSK128);
demodPSK256 = modem_create(LIQUID_MODEM_PSK256);
demodOOK = modem_create(LIQUID_MODEM_OOK); demodOOK = modem_create(LIQUID_MODEM_OOK);
demodSQAM = modem_create(LIQUID_MODEM_SQAM128);
demodSQAM = demodSQAM32;
demodSQAM32 = modem_create(LIQUID_MODEM_SQAM32);
demodSQAM128 = modem_create(LIQUID_MODEM_SQAM128);
demodST = modem_create(LIQUID_MODEM_V29); demodST = modem_create(LIQUID_MODEM_V29);
demodQAM = modem_create(LIQUID_MODEM_QAM256);
demodQAM = demodQAM4;
demodQAM4 = modem_create(LIQUID_MODEM_QAM4);
demodQAM8 = modem_create(LIQUID_MODEM_QAM8);
demodQAM16 = modem_create(LIQUID_MODEM_QAM16);
demodQAM32 = modem_create(LIQUID_MODEM_QAM32);
demodQAM64 = modem_create(LIQUID_MODEM_QAM64);
demodQAM128 = modem_create(LIQUID_MODEM_QAM128);
demodQAM256 = modem_create(LIQUID_MODEM_QAM256);
demodQPSK = modem_create(LIQUID_MODEM_QPSK); demodQPSK = modem_create(LIQUID_MODEM_QPSK);
currentDemodLock = false; currentDemodLock = false;
@ -188,19 +230,25 @@ void DemodulatorThread::threadMain() {
currentSignalLevel = agc_crcf_get_signal_level(iqAutoGain); currentSignalLevel = agc_crcf_get_signal_level(iqAutoGain);
} }
// Reset demodulator Constellations & Lock
updateDemodulatorCons(0);
if (demodulatorType == DEMOD_TYPE_FM) { if (demodulatorType == DEMOD_TYPE_FM) {
currentDemodLock = false;
freqdem_demodulate_block(demodFM, &agcData[0], bufSize, &demodOutputData[0]); freqdem_demodulate_block(demodFM, &agcData[0], bufSize, &demodOutputData[0]);
} else { } else {
float p; float p;
unsigned int bitstream; unsigned int bitstream;
switch (demodulatorType.load()) { switch (demodulatorType.load()) {
case DEMOD_TYPE_LSB: case DEMOD_TYPE_LSB:
currentDemodLock = false;
for (int i = 0; i < bufSize; i++) { // Reject upper band for (int i = 0; i < bufSize; i++) { // Reject upper band
resamp2_cccf_filter_execute(ssbFilt,inp->data[i],&x,&y); resamp2_cccf_filter_execute(ssbFilt,inp->data[i],&x,&y);
ampmodem_demodulate(demodAM, x, &demodOutputData[i]); ampmodem_demodulate(demodAM, x, &demodOutputData[i]);
} }
break; break;
case DEMOD_TYPE_USB: case DEMOD_TYPE_USB:
currentDemodLock = false;
for (int i = 0; i < bufSize; i++) { // Reject lower band for (int i = 0; i < bufSize; i++) { // Reject lower band
resamp2_cccf_filter_execute(ssbFilt,inp->data[i],&x,&y); resamp2_cccf_filter_execute(ssbFilt,inp->data[i],&x,&y);
ampmodem_demodulate(demodAM, y, &demodOutputData[i]); ampmodem_demodulate(demodAM, y, &demodOutputData[i]);
@ -208,20 +256,105 @@ void DemodulatorThread::threadMain() {
break; break;
case DEMOD_TYPE_AM: case DEMOD_TYPE_AM:
case DEMOD_TYPE_DSB: case DEMOD_TYPE_DSB:
currentDemodLock = false;
for (int i = 0; i < bufSize; i++) { for (int i = 0; i < bufSize; i++) {
ampmodem_demodulate(demodAM, inp->data[i], &demodOutputData[i]); ampmodem_demodulate(demodAM, inp->data[i], &demodOutputData[i]);
} }
break; break;
// advanced demodulators
// tneeds refactoring
case DEMOD_TYPE_ASK: case DEMOD_TYPE_ASK:
if(demodulatorCons == 2) {
switch (demodulatorCons) {
case 2:
demodASK = demodASK2; demodASK = demodASK2;
updateDemodulatorCons(2);
break;
case 4:
demodASK = demodASK4;
updateDemodulatorCons(4);
break;
case 8:
demodASK = demodASK8;
updateDemodulatorCons(8);
break;
case 16:
demodASK = demodASK16;
updateDemodulatorCons(16);
break;
case 32:
demodASK = demodASK32;
updateDemodulatorCons(32);
break;
case 64:
demodASK = demodASK64;
updateDemodulatorCons(64);
break;
case 128:
demodASK = demodASK128;
updateDemodulatorCons(128);
break;
case 256:
demodASK = demodASK256;
updateDemodulatorCons(256);
break;
default:
demodASK = demodASK2;
break;
} }
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, 0.5f); updateDemodulatorLock(demodASK, 0.5f);
break; break;
case DEMOD_TYPE_APSK:
switch (demodulatorCons) {
case 2:
demodAPSK = demodAPSK4;
updateDemodulatorCons(4);
break;
case 4:
demodAPSK = demodAPSK4;
updateDemodulatorCons(4);
break;
case 8:
demodAPSK = demodAPSK8;
updateDemodulatorCons(8);
break;
case 16:
demodAPSK = demodAPSK16;
updateDemodulatorCons(16);
break;
case 32:
demodAPSK = demodAPSK32;
updateDemodulatorCons(32);
break;
case 64:
demodAPSK = demodAPSK64;
updateDemodulatorCons(64);
break;
case 128:
demodAPSK = demodAPSK128;
updateDemodulatorCons(128);
break;
case 256:
demodAPSK = demodAPSK256;
updateDemodulatorCons(256);
break;
default:
demodAPSK = demodAPSK4;
break;
}
for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodAPSK, inp->data[i], &bitstream);
// std::cout << bitstream << std::endl;
}
updateDemodulatorLock(demodAPSK, 0.5f);
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);
@ -230,6 +363,45 @@ void DemodulatorThread::threadMain() {
updateDemodulatorLock(demodBPSK, 0.8f); updateDemodulatorLock(demodBPSK, 0.8f);
break; break;
case DEMOD_TYPE_DPSK: case DEMOD_TYPE_DPSK:
switch (demodulatorCons) {
case 2:
demodDPSK = demodDPSK2;
updateDemodulatorCons(2);
break;
case 4:
demodDPSK = demodDPSK4;
updateDemodulatorCons(4);
break;
case 8:
demodDPSK = demodDPSK8;
updateDemodulatorCons(8);
break;
case 16:
demodDPSK = demodDPSK16;
updateDemodulatorCons(16);
break;
case 32:
demodDPSK = demodDPSK32;
updateDemodulatorCons(32);
break;
case 64:
demodDPSK = demodDPSK64;
updateDemodulatorCons(64);
break;
case 128:
demodDPSK = demodDPSK128;
updateDemodulatorCons(128);
break;
case 256:
demodDPSK = demodDPSK256;
updateDemodulatorCons(256);
break;
default:
demodDPSK = demodDPSK2;
break;
}
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;
@ -237,6 +409,45 @@ void DemodulatorThread::threadMain() {
updateDemodulatorLock(demodDPSK, 0.8f); updateDemodulatorLock(demodDPSK, 0.8f);
break; break;
case DEMOD_TYPE_PSK: case DEMOD_TYPE_PSK:
switch (demodulatorCons) {
case 2:
demodPSK = demodPSK2;
updateDemodulatorCons(2);
break;
case 4:
demodPSK = demodPSK4;
updateDemodulatorCons(4);
break;
case 8:
demodPSK = demodPSK8;
updateDemodulatorCons(8);
break;
case 16:
demodPSK = demodPSK16;
updateDemodulatorCons(16);
break;
case 32:
demodPSK = demodPSK32;
updateDemodulatorCons(32);
break;
case 64:
demodPSK = demodPSK64;
updateDemodulatorCons(64);
break;
case 128:
demodPSK = demodPSK128;
updateDemodulatorCons(128);
break;
case 256:
demodPSK = demodPSK256;
updateDemodulatorCons(256);
break;
default:
demodPSK = demodPSK2;
break;
}
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;
@ -251,6 +462,45 @@ void DemodulatorThread::threadMain() {
updateDemodulatorLock(demodOOK, 0.8f); updateDemodulatorLock(demodOOK, 0.8f);
break; break;
case DEMOD_TYPE_SQAM: case DEMOD_TYPE_SQAM:
switch (demodulatorCons) {
case 2:
demodSQAM = demodSQAM32;
updateDemodulatorCons(32);
break;
case 4:
demodSQAM = demodSQAM32;
updateDemodulatorCons(32);
break;
case 8:
demodSQAM = demodSQAM32;
updateDemodulatorCons(32);
break;
case 16:
demodSQAM = demodSQAM32;
updateDemodulatorCons(32);
break;
case 32:
demodSQAM = demodSQAM32;
updateDemodulatorCons(32);
break;
case 64:
demodSQAM = demodSQAM32;
updateDemodulatorCons(32);
break;
case 128:
demodSQAM = demodSQAM128;
updateDemodulatorCons(128);
break;
case 256:
demodSQAM = demodSQAM128;
updateDemodulatorCons(128);
break;
default:
demodSQAM = demodSQAM32;
break;
}
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;
@ -265,6 +515,45 @@ void DemodulatorThread::threadMain() {
updateDemodulatorLock(demodST, 0.8f); updateDemodulatorLock(demodST, 0.8f);
break; break;
case DEMOD_TYPE_QAM: case DEMOD_TYPE_QAM:
switch (demodulatorCons) {
case 2:
demodQAM = demodQAM4;
updateDemodulatorCons(4);
break;
case 4:
demodQAM = demodQAM4;
updateDemodulatorCons(4);
break;
case 8:
demodQAM = demodQAM8;
updateDemodulatorCons(8);
break;
case 16:
demodQAM = demodQAM16;
updateDemodulatorCons(16);
break;
case 32:
demodQAM = demodQAM32;
updateDemodulatorCons(32);
break;
case 64:
demodQAM = demodQAM64;
updateDemodulatorCons(64);
break;
case 128:
demodQAM = demodQAM128;
updateDemodulatorCons(128);
break;
case 256:
demodQAM = demodQAM256;
updateDemodulatorCons(256);
break;
default:
demodQAM = demodQAM4;
break;
}
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;
@ -589,15 +878,19 @@ int DemodulatorThread::getDemodulatorLock() {
} }
void DemodulatorThread::setDemodulatorCons(int demod_cons_in) { void DemodulatorThread::setDemodulatorCons(int demod_cons_in) {
std::cout << "Updating constellations" << std::endl;
demodulatorCons = demod_cons_in; demodulatorCons = demod_cons_in;
} }
int DemodulatorThread::getDemodulatorCons() { int DemodulatorThread::getDemodulatorCons() {
return demodulatorCons; return currentDemodCons;
} }
void DemodulatorThread::updateDemodulatorLock(modem demod, float sensitivity) { void DemodulatorThread::updateDemodulatorLock(modem demod, float sensitivity) {
modem_get_demodulator_evm(demod) <= sensitivity ? setDemodulatorLock(true) : setDemodulatorLock(false); modem_get_demodulator_evm(demod) <= sensitivity ? setDemodulatorLock(true) : setDemodulatorLock(false);
} }
void DemodulatorThread::updateDemodulatorCons(int Cons) {
if (currentDemodCons != Cons) {
currentDemodCons = Cons;
}
}

View File

@ -83,13 +83,53 @@ protected:
modem demodASK256; modem demodASK256;
modem demodAPSK; modem demodAPSK;
modem demodAPSK4;
modem demodAPSK8;
modem demodAPSK16;
modem demodAPSK32;
modem demodAPSK64;
modem demodAPSK128;
modem demodAPSK256;
modem demodBPSK; modem demodBPSK;
modem demodDPSK; modem demodDPSK;
modem demodDPSK2;
modem demodDPSK4;
modem demodDPSK8;
modem demodDPSK16;
modem demodDPSK32;
modem demodDPSK64;
modem demodDPSK128;
modem demodDPSK256;
modem demodPSK; modem demodPSK;
modem demodPSK2;
modem demodPSK4;
modem demodPSK8;
modem demodPSK16;
modem demodPSK32;
modem demodPSK64;
modem demodPSK128;
modem demodPSK256;
modem demodOOK; modem demodOOK;
modem demodSQAM; modem demodSQAM;
modem demodSQAM32;
modem demodSQAM128;
modem demodST; modem demodST;
modem demodQAM; modem demodQAM;
modem demodQAM4;
modem demodQAM8;
modem demodQAM16;
modem demodQAM32;
modem demodQAM64;
modem demodQAM128;
modem demodQAM256;
modem demodQPSK; modem demodQPSK;
agc_crcf iqAutoGain; agc_crcf iqAutoGain;
@ -111,5 +151,8 @@ protected:
bool squelchEnabled; bool squelchEnabled;
bool currentDemodLock; bool currentDemodLock;
int currentDemodCons;
void updateDemodulatorCons(int Cons);
void updateDemodulatorLock(modem demod, float sensitivity); void updateDemodulatorLock(modem demod, float sensitivity);
}; };

View File

@ -306,6 +306,10 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBColor color, lon
break; break;
} }
if (demod->getDemodulatorCons() != NULL && demod->getDemodulatorCons() > 0) {
demodStr = demodStr + std::to_string(demod->getDemodulatorCons());
}
// 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";