mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 20:28:40 -05:00
Working demodulator lock status text
This commit is contained in:
parent
2ca6786be7
commit
9e1601c446
@ -21,6 +21,7 @@ DemodulatorInstance::DemodulatorInstance() :
|
|||||||
demodulatorThread->setAudioOutputQueue(audioInputQueue);
|
demodulatorThread->setAudioOutputQueue(audioInputQueue);
|
||||||
|
|
||||||
currentDemodType = demodulatorThread->getDemodulatorType();
|
currentDemodType = demodulatorThread->getDemodulatorType();
|
||||||
|
currentDemodLock = demodulatorThread->getDemodulatorLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorInstance::~DemodulatorInstance() {
|
DemodulatorInstance::~DemodulatorInstance() {
|
||||||
@ -50,6 +51,7 @@ 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;
|
||||||
|
|
||||||
@ -264,6 +266,19 @@ int DemodulatorInstance::getDemodulatorType() {
|
|||||||
return currentDemodType;
|
return currentDemodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DemodulatorInstance::setDemodulatorLock(bool demod_lock_in) {
|
||||||
|
if(demod_lock_in) {
|
||||||
|
currentDemodLock = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentDemodLock = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DemodulatorInstance::getDemodulatorLock() {
|
||||||
|
return currentDemodLock;
|
||||||
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setBandwidth(int bw) {
|
void DemodulatorInstance::setBandwidth(int bw) {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
currentBandwidth = bw;
|
currentBandwidth = bw;
|
||||||
|
@ -64,6 +64,9 @@ public:
|
|||||||
|
|
||||||
void setDemodulatorType(int demod_type_in);
|
void setDemodulatorType(int demod_type_in);
|
||||||
int getDemodulatorType();
|
int getDemodulatorType();
|
||||||
|
|
||||||
|
void setDemodulatorLock(bool demod_lock_in);
|
||||||
|
int getDemodulatorLock();
|
||||||
|
|
||||||
void setBandwidth(int bw);
|
void setBandwidth(int bw);
|
||||||
int getBandwidth();
|
int getBandwidth();
|
||||||
@ -98,6 +101,7 @@ 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;
|
||||||
|
@ -162,6 +162,7 @@ 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();
|
||||||
@ -191,6 +192,14 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ 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);
|
||||||
@ -52,6 +55,7 @@ private:
|
|||||||
|
|
||||||
int lastBandwidth;
|
int lastBandwidth;
|
||||||
int lastDemodType;
|
int lastDemodType;
|
||||||
|
bool lastDemodLock;
|
||||||
bool lastSquelchEnabled;
|
bool lastSquelchEnabled;
|
||||||
float lastSquelch;
|
float lastSquelch;
|
||||||
float lastGain;
|
float lastGain;
|
||||||
|
@ -178,7 +178,6 @@ void DemodulatorThread::threadMain() {
|
|||||||
} else {
|
} else {
|
||||||
float p;
|
float p;
|
||||||
unsigned int bitstream;
|
unsigned int bitstream;
|
||||||
int temp;
|
|
||||||
switch (demodulatorType.load()) {
|
switch (demodulatorType.load()) {
|
||||||
case DEMOD_TYPE_LSB:
|
case DEMOD_TYPE_LSB:
|
||||||
for (int i = 0; i < bufSize; i++) { // Reject upper band
|
for (int i = 0; i < bufSize; i++) { // Reject upper band
|
||||||
@ -203,57 +202,62 @@ void DemodulatorThread::threadMain() {
|
|||||||
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);
|
||||||
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);
|
||||||
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);
|
||||||
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);
|
||||||
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);
|
||||||
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);
|
||||||
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);
|
||||||
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);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
if(modem_get_demodulator_evm(demodQPSK) <= 0.8f) {
|
updateDemodulatorLock(demodQPSK);
|
||||||
std::cout << "Lock!" << std::endl;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,6 +462,10 @@ void DemodulatorThread::threadMain() {
|
|||||||
demodAM = demodAM_DSB_CSP;
|
demodAM = demodAM_DSB_CSP;
|
||||||
ampmodem_reset(demodAM);
|
ampmodem_reset(demodAM);
|
||||||
break;
|
break;
|
||||||
|
case DEMOD_TYPE_QPSK:
|
||||||
|
std::cout << "reset modem qpsk" << std::endl;
|
||||||
|
modem_reset(demodQPSK);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
demodulatorType = newDemodType;
|
demodulatorType = newDemodType;
|
||||||
}
|
}
|
||||||
@ -553,3 +561,20 @@ int DemodulatorThread::getDemodulatorType() {
|
|||||||
return demodulatorType;
|
return demodulatorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DemodulatorThread::setDemodulatorLock(bool demod_lock_in) {
|
||||||
|
if(demod_lock_in) {
|
||||||
|
currentDemodLock = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentDemodLock = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DemodulatorThread::getDemodulatorLock() {
|
||||||
|
return currentDemodLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorThread::updateDemodulatorLock(modem demod) {
|
||||||
|
modem_get_demodulator_evm(demod) <= 0.8f ? setDemodulatorLock(true) : setDemodulatorLock(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,9 @@ public:
|
|||||||
|
|
||||||
void setDemodulatorType(int demod_type_in);
|
void setDemodulatorType(int demod_type_in);
|
||||||
int getDemodulatorType();
|
int getDemodulatorType();
|
||||||
|
|
||||||
|
void setDemodulatorLock(bool demod_lock_in);
|
||||||
|
int getDemodulatorLock();
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
static void *pthread_helper(void *context) {
|
static void *pthread_helper(void *context) {
|
||||||
@ -92,4 +95,7 @@ protected:
|
|||||||
std::atomic<float> squelchLevel;
|
std::atomic<float> squelchLevel;
|
||||||
std::atomic<float> signalLevel;
|
std::atomic<float> signalLevel;
|
||||||
bool squelchEnabled;
|
bool squelchEnabled;
|
||||||
|
|
||||||
|
bool currentDemodLock = false;
|
||||||
|
void updateDemodulatorLock(modem demod);
|
||||||
};
|
};
|
||||||
|
@ -305,6 +305,12 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBColor color, lon
|
|||||||
demodAlign = GLFont::GLFONT_ALIGN_CENTER;
|
demodAlign = GLFont::GLFONT_ALIGN_CENTER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// add lock to string if we have an lock
|
||||||
|
if(demod->getDemodulatorLock()) {
|
||||||
|
demodStr = demodStr + " Lock";
|
||||||
|
}
|
||||||
|
|
||||||
glColor3f(0, 0, 0);
|
glColor3f(0, 0, 0);
|
||||||
getFont(PrimaryGLContext::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs, -1.0 + hPos - yOfs, 16, demodAlign,
|
getFont(PrimaryGLContext::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs, -1.0 + hPos - yOfs, 16, demodAlign,
|
||||||
|
Loading…
Reference in New Issue
Block a user