Propagate Constelattion setting to demodulator, not working properly yet.

This commit is contained in:
Dantali0n 2015-06-10 10:50:14 +02:00
parent b76eafe8df
commit f71d04eb75
8 changed files with 84 additions and 4 deletions

View File

@ -504,8 +504,10 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
scopeCanvas->setDeviceName(outputDevices[outputDevice].name);
outputDeviceMenuItems[outputDevice]->Check(true);
int dType = demod->getDemodulatorType();
int dCons = demod->getDemodulatorCons();
demodModeSelector->setSelection(dType);
demodModeSelectorAdv->setSelection(dType);
demodModeSelectorCons->setSelection(dCons);
}
if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) {
long long centerFreq = demod->getFrequency();
@ -534,12 +536,16 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
}
int dSelection = demodModeSelector->getSelection();
int dSelectionadv = demodModeSelectorAdv->getSelection();
// basic demodulators
if (dSelection != -1 && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection);
demodModeSelectorAdv->setSelection(-1);
}
// advanced demodulators
else if(dSelectionadv != -1 && dSelectionadv != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelectionadv);
demod->setDemodulatorCons(demodModeSelectorCons->getSelection());
// std::cout << "updating demodulator" << std::endl;
demodModeSelector->setSelection(-1);
}
@ -561,12 +567,15 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
int dSelection = demodModeSelector->getSelection();
int dSelectionadv = demodModeSelectorAdv->getSelection();
// basic demodulators
if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection);
demodModeSelectorAdv->setSelection(-1);
}
// advanced demodulators
else if(dSelectionadv != -1 && dSelectionadv != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelectionadv);
mgr->setLastDemodulatorCons(demodModeSelectorCons->getSelection());
demodModeSelector->setSelection(-1);
}

View File

@ -21,6 +21,7 @@ DemodulatorInstance::DemodulatorInstance() :
demodulatorThread->setAudioOutputQueue(audioInputQueue);
currentDemodType = demodulatorThread->getDemodulatorType();
currentDemodCons = demodulatorThread->getDemodulatorCons();
}
DemodulatorInstance::~DemodulatorInstance() {
@ -50,6 +51,7 @@ void DemodulatorInstance::run() {
currentFrequency = demodulatorPreThread->getParams().frequency;
currentDemodType = demodulatorThread->getDemodulatorType();
currentDemodCons = demodulatorThread->getDemodulatorCons();
currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()];
demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate;
@ -272,6 +274,14 @@ int DemodulatorInstance::getDemodulatorLock() {
return demodulatorThread->getDemodulatorLock();
}
void DemodulatorInstance::setDemodulatorCons(int demod_cons_in) {
demodulatorThread->setDemodulatorCons(demod_cons_in);
}
int DemodulatorInstance::getDemodulatorCons() {
return demodulatorThread->getDemodulatorCons();
}
void DemodulatorInstance::setBandwidth(int bw) {
if (!active) {
currentBandwidth = bw;

View File

@ -67,6 +67,9 @@ public:
void setDemodulatorLock(bool demod_lock_in);
int getDemodulatorLock();
void setDemodulatorCons(int demod_cons_in);
int getDemodulatorCons();
void setBandwidth(int bw);
int getBandwidth();
@ -101,6 +104,7 @@ private:
long long currentFrequency;
int currentBandwidth;
int currentDemodType;
int currentDemodCons;
int currentOutputDevice;
int currentAudioSampleRate;
bool follow, tracking;

View File

@ -162,6 +162,8 @@ void DemodulatorMgr::updateLastState() {
if (lastActiveDemodulator) {
lastBandwidth = lastActiveDemodulator->getBandwidth();
lastDemodType = lastActiveDemodulator->getDemodulatorType();
lastDemodLock = lastActiveDemodulator->getDemodulatorLock();
lastDemodCons = lastActiveDemodulator->getDemodulatorCons();
lastSquelchEnabled = lastActiveDemodulator->isSquelchEnabled();
lastSquelch = lastActiveDemodulator->getSquelchLevel();
lastGain = lastActiveDemodulator->getGain();
@ -191,6 +193,14 @@ void DemodulatorMgr::setLastDemodulatorType(int lastDemodType) {
this->lastDemodType = lastDemodType;
}
int DemodulatorMgr::getLastDemodulatorCons() const {
return lastDemodCons;
}
void DemodulatorMgr::setLastDemodulatorCons(int lastDemodCons) {
this->lastDemodCons = lastDemodCons;
}
float DemodulatorMgr::getLastGain() const {
return lastGain;
}

View File

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

View File

@ -26,7 +26,20 @@ DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQue
demodAM = demodAM_DSB_CSP;
// advanced demodulators
demodASK = modem_create(LIQUID_MODEM_ASK256);
// This could properly be done easier.
demodulatorCons = 2;
demodASK = modem_create(LIQUID_MODEM_ASK2);
demodASK2 = modem_create(LIQUID_MODEM_ASK2);
demodASK4 = modem_create(LIQUID_MODEM_ASK4);
demodASK8 = modem_create(LIQUID_MODEM_ASK8);
demodASK16 = modem_create(LIQUID_MODEM_ASK16);
demodASK32 = modem_create(LIQUID_MODEM_ASK32);
demodASK64 = modem_create(LIQUID_MODEM_ASK64);
demodASK128 = modem_create(LIQUID_MODEM_ASK128);
demodASK256 = modem_create(LIQUID_MODEM_ASK256);
demodAPSK = modem_create(LIQUID_MODEM_APSK256);
demodBPSK = modem_create(LIQUID_MODEM_BPSK);
demodDPSK = modem_create(LIQUID_MODEM_DPSK256);
@ -200,11 +213,14 @@ void DemodulatorThread::threadMain() {
}
break;
case DEMOD_TYPE_ASK:
if(demodulatorCons == 2) {
demodASK = demodASK2;
}
for (int i = 0; i < bufSize; i++) {
modem_demodulate(demodASK, inp->data[i], &bitstream);
// std::cout << bitstream << std::endl;
}
updateDemodulatorLock(demodASK, 0.8f);
updateDemodulatorLock(demodASK, 0.5f);
break;
case DEMOD_TYPE_BPSK:
for (int i = 0; i < bufSize; i++) {
@ -572,6 +588,15 @@ int DemodulatorThread::getDemodulatorLock() {
return currentDemodLock;
}
void DemodulatorThread::setDemodulatorCons(int demod_cons_in) {
std::cout << "Updating constellations" << std::endl;
demodulatorCons = demod_cons_in;
}
int DemodulatorThread::getDemodulatorCons() {
return demodulatorCons;
}
void DemodulatorThread::updateDemodulatorLock(modem demod, float sensitivity) {
modem_get_demodulator_evm(demod) <= sensitivity ? setDemodulatorLock(true) : setDemodulatorLock(false);
}

View File

@ -40,6 +40,9 @@ public:
void setDemodulatorLock(bool demod_lock_in);
int getDemodulatorLock();
void setDemodulatorCons(int demod_cons_in);
int getDemodulatorCons();
#ifdef __APPLE__
static void *pthread_helper(void *context) {
@ -68,7 +71,17 @@ protected:
ampmodem demodAM_DSB;
ampmodem demodAM_LSB;
ampmodem demodAM_USB;
modem demodASK;
modem demodASK;
modem demodASK2;
modem demodASK4;
modem demodASK8;
modem demodASK16;
modem demodASK32;
modem demodASK64;
modem demodASK128;
modem demodASK256;
modem demodAPSK;
modem demodBPSK;
modem demodDPSK;
@ -88,6 +101,7 @@ protected:
std::atomic<bool> stereo;
std::atomic<bool> terminated;
std::atomic<int> demodulatorType;
std::atomic<int> demodulatorCons;
int audioSampleRate;
DemodulatorThreadCommandQueue* threadQueueNotify;

View File

@ -309,7 +309,10 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBColor color, lon
// add lock to string if we have an lock
if(demod->getDemodulatorLock()) {
demodStr = demodStr + " Lock";
}
}
// else {
// demodStr = demodStr + " UnLock";
// }
glColor3f(0, 0, 0);
getFont(PrimaryGLContext::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs, -1.0 + hPos - yOfs, 16, demodAlign,