mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-27 14:09:11 -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);
|
||||
|
||||
currentDemodType = demodulatorThread->getDemodulatorType();
|
||||
currentDemodLock = demodulatorThread->getDemodulatorLock();
|
||||
}
|
||||
|
||||
DemodulatorInstance::~DemodulatorInstance() {
|
||||
@ -50,6 +51,7 @@ void DemodulatorInstance::run() {
|
||||
|
||||
currentFrequency = demodulatorPreThread->getParams().frequency;
|
||||
currentDemodType = demodulatorThread->getDemodulatorType();
|
||||
currentDemodLock = demodulatorThread->getDemodulatorLock();
|
||||
currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()];
|
||||
demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate;
|
||||
|
||||
@ -264,6 +266,19 @@ int DemodulatorInstance::getDemodulatorType() {
|
||||
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) {
|
||||
if (!active) {
|
||||
currentBandwidth = bw;
|
||||
|
@ -65,6 +65,9 @@ public:
|
||||
void setDemodulatorType(int demod_type_in);
|
||||
int getDemodulatorType();
|
||||
|
||||
void setDemodulatorLock(bool demod_lock_in);
|
||||
int getDemodulatorLock();
|
||||
|
||||
void setBandwidth(int bw);
|
||||
int getBandwidth();
|
||||
|
||||
@ -98,6 +101,7 @@ private:
|
||||
long long currentFrequency;
|
||||
int currentBandwidth;
|
||||
int currentDemodType;
|
||||
bool currentDemodLock = false;
|
||||
int currentOutputDevice;
|
||||
int currentAudioSampleRate;
|
||||
bool follow, tracking;
|
||||
|
@ -162,6 +162,7 @@ void DemodulatorMgr::updateLastState() {
|
||||
if (lastActiveDemodulator) {
|
||||
lastBandwidth = lastActiveDemodulator->getBandwidth();
|
||||
lastDemodType = lastActiveDemodulator->getDemodulatorType();
|
||||
lastDemodLock = lastActiveDemodulator->getDemodulatorLock();
|
||||
lastSquelchEnabled = lastActiveDemodulator->isSquelchEnabled();
|
||||
lastSquelch = lastActiveDemodulator->getSquelchLevel();
|
||||
lastGain = lastActiveDemodulator->getGain();
|
||||
@ -191,6 +192,14 @@ void DemodulatorMgr::setLastDemodulatorType(int lastDemodType) {
|
||||
this->lastDemodType = lastDemodType;
|
||||
}
|
||||
|
||||
bool DemodulatorMgr::getLastDemodulatorLock() const {
|
||||
return lastDemodLock;
|
||||
}
|
||||
|
||||
void DemodulatorMgr::setLastDemodulatorLock(bool lastDemodLock) {
|
||||
this->lastDemodLock = lastDemodLock;
|
||||
}
|
||||
|
||||
float DemodulatorMgr::getLastGain() const {
|
||||
return lastGain;
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ public:
|
||||
int getLastDemodulatorType() const;
|
||||
void setLastDemodulatorType(int lastDemodType);
|
||||
|
||||
bool getLastDemodulatorLock() const;
|
||||
void setLastDemodulatorLock(bool lastDemodLock);
|
||||
|
||||
float getLastGain() const;
|
||||
void setLastGain(float lastGain);
|
||||
|
||||
@ -52,6 +55,7 @@ private:
|
||||
|
||||
int lastBandwidth;
|
||||
int lastDemodType;
|
||||
bool lastDemodLock;
|
||||
bool lastSquelchEnabled;
|
||||
float lastSquelch;
|
||||
float lastGain;
|
||||
|
@ -178,7 +178,6 @@ void DemodulatorThread::threadMain() {
|
||||
} else {
|
||||
float p;
|
||||
unsigned int bitstream;
|
||||
int temp;
|
||||
switch (demodulatorType.load()) {
|
||||
case DEMOD_TYPE_LSB:
|
||||
for (int i = 0; i < bufSize; i++) { // Reject upper band
|
||||
@ -203,57 +202,62 @@ void DemodulatorThread::threadMain() {
|
||||
modem_demodulate(demodASK, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodASK);
|
||||
break;
|
||||
case DEMOD_TYPE_BPSK:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodBPSK, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodBPSK);
|
||||
break;
|
||||
case DEMOD_TYPE_DPSK:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodDPSK, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodDPSK);
|
||||
break;
|
||||
case DEMOD_TYPE_PSK:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodPSK, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodPSK);
|
||||
break;
|
||||
case DEMOD_TYPE_OOK:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodOOK, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodOOK);
|
||||
break;
|
||||
case DEMOD_TYPE_SQAM:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodSQAM, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodSQAM);
|
||||
break;
|
||||
case DEMOD_TYPE_ST:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodST, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodST);
|
||||
break;
|
||||
case DEMOD_TYPE_QAM:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodQAM, inp->data[i], &bitstream);
|
||||
std::cout << bitstream << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodQAM);
|
||||
break;
|
||||
case DEMOD_TYPE_QPSK:
|
||||
for (int i = 0; i < bufSize; i++) {
|
||||
modem_demodulate(demodQPSK, inp->data[i], &bitstream);
|
||||
// std::cout << bitstream << std::endl;
|
||||
}
|
||||
if(modem_get_demodulator_evm(demodQPSK) <= 0.8f) {
|
||||
std::cout << "Lock!" << std::endl;
|
||||
}
|
||||
updateDemodulatorLock(demodQPSK);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -458,6 +462,10 @@ void DemodulatorThread::threadMain() {
|
||||
demodAM = demodAM_DSB_CSP;
|
||||
ampmodem_reset(demodAM);
|
||||
break;
|
||||
case DEMOD_TYPE_QPSK:
|
||||
std::cout << "reset modem qpsk" << std::endl;
|
||||
modem_reset(demodQPSK);
|
||||
break;
|
||||
}
|
||||
demodulatorType = newDemodType;
|
||||
}
|
||||
@ -553,3 +561,20 @@ int DemodulatorThread::getDemodulatorType() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,9 @@ public:
|
||||
void setDemodulatorType(int demod_type_in);
|
||||
int getDemodulatorType();
|
||||
|
||||
void setDemodulatorLock(bool demod_lock_in);
|
||||
int getDemodulatorLock();
|
||||
|
||||
#ifdef __APPLE__
|
||||
static void *pthread_helper(void *context) {
|
||||
return ((DemodulatorThread *) context)->threadMain();
|
||||
@ -92,4 +95,7 @@ protected:
|
||||
std::atomic<float> squelchLevel;
|
||||
std::atomic<float> signalLevel;
|
||||
bool squelchEnabled;
|
||||
|
||||
bool currentDemodLock = false;
|
||||
void updateDemodulatorLock(modem demod);
|
||||
};
|
||||
|
@ -306,6 +306,12 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBColor color, lon
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// add lock to string if we have an lock
|
||||
if(demod->getDemodulatorLock()) {
|
||||
demodStr = demodStr + " Lock";
|
||||
}
|
||||
|
||||
glColor3f(0, 0, 0);
|
||||
getFont(PrimaryGLContext::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs, -1.0 + hPos - yOfs, 16, demodAlign,
|
||||
GLFont::GLFONT_ALIGN_CENTER);
|
||||
|
Loading…
Reference in New Issue
Block a user