mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-22 17:45:48 -05:00
Fine tune.
This commit is contained in:
parent
1982574527
commit
bfdd03e903
@ -48,6 +48,7 @@ LoRaDemod::LoRaDemod(SampleSink* sampleSink) :
|
|||||||
|
|
||||||
mov = new float[4*LORA_SFFT_LEN];
|
mov = new float[4*LORA_SFFT_LEN];
|
||||||
history = new short[1024];
|
history = new short[1024];
|
||||||
|
finetune = new short[16];
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaDemod::~LoRaDemod()
|
LoRaDemod::~LoRaDemod()
|
||||||
@ -60,6 +61,8 @@ LoRaDemod::~LoRaDemod()
|
|||||||
delete [] mov;
|
delete [] mov;
|
||||||
if (history)
|
if (history)
|
||||||
delete [] history;
|
delete [] history;
|
||||||
|
if (finetune)
|
||||||
|
delete [] finetune;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRaDemod::configure(MessageQueue* messageQueue, Real Bandwidth)
|
void LoRaDemod::configure(MessageQueue* messageQueue, Real Bandwidth)
|
||||||
@ -70,33 +73,40 @@ void LoRaDemod::configure(MessageQueue* messageQueue, Real Bandwidth)
|
|||||||
|
|
||||||
void LoRaDemod::dumpRaw()
|
void LoRaDemod::dumpRaw()
|
||||||
{
|
{
|
||||||
int i, j, max;
|
short bin, j, max;
|
||||||
max = m_time - 4;
|
max = m_time / 4 - 1;
|
||||||
if (max > 32 * 4)
|
if (max > 32)
|
||||||
max = 32 * 4;
|
max = 32;
|
||||||
char text[256];
|
char text[256];
|
||||||
for ( i=0; i < max; i+=4) {
|
for ( j=0; j < max; j++) {
|
||||||
j = i / 4;
|
bin = (history[j * 4 + 4] + m_tune) & (LORA_SFFT_LEN - 1);
|
||||||
text[j] = 32 + (toGray(127 & history[i + 4]) >> 1);
|
text[j] = 32 + (toGray(bin) >> 1);
|
||||||
}
|
}
|
||||||
text[i / 4] = 0;
|
text[j] = 0;
|
||||||
printf(">%s..(%d)\n", text, m_time / 4);
|
printf(">%s..(%d)\n", text, m_time / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
short LoRaDemod::synch(short bin)
|
short LoRaDemod::synch(short bin)
|
||||||
{
|
{
|
||||||
|
short i, j;
|
||||||
if (bin < 0) {
|
if (bin < 0) {
|
||||||
if (m_time > 70)
|
if (m_time > 70)
|
||||||
dumpRaw();
|
dumpRaw();
|
||||||
m_time = 0;
|
m_time = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
history[m_time] = (bin + m_tune) & (LORA_SFFT_LEN - 1);
|
history[m_time] = bin;
|
||||||
if (m_time > 12)
|
if (m_time > 12)
|
||||||
if (history[m_time] == history[m_time - 6])
|
if (bin == history[m_time - 6])
|
||||||
if (history[m_time] == history[m_time - 12]) {
|
if (bin == history[m_time - 12]) {
|
||||||
m_time = 0;
|
|
||||||
m_tune = LORA_SFFT_LEN - bin;
|
m_tune = LORA_SFFT_LEN - bin;
|
||||||
|
j = 0;
|
||||||
|
for (i=0; i<12; i++)
|
||||||
|
j += finetune[15 & (m_time - i)];
|
||||||
|
if (j < 0)
|
||||||
|
m_tune += 1;
|
||||||
|
m_tune &= (LORA_SFFT_LEN - 1);
|
||||||
|
m_time = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +119,7 @@ short LoRaDemod::synch(short bin)
|
|||||||
|
|
||||||
int LoRaDemod::detect(Complex c, Complex a)
|
int LoRaDemod::detect(Complex c, Complex a)
|
||||||
{
|
{
|
||||||
|
int p, q;
|
||||||
short i, result, negresult, movpoint;
|
short i, result, negresult, movpoint;
|
||||||
float peak, negpeak, tfloat;
|
float peak, negpeak, tfloat;
|
||||||
float mag[LORA_SFFT_LEN];
|
float mag[LORA_SFFT_LEN];
|
||||||
@ -139,11 +150,14 @@ int LoRaDemod::detect(Complex c, Complex a)
|
|||||||
}
|
}
|
||||||
mov[movpoint * LORA_SFFT_LEN + i] = mag[i];
|
mov[movpoint * LORA_SFFT_LEN + i] = mag[i];
|
||||||
}
|
}
|
||||||
if (peak > negpeak * 4) {
|
|
||||||
|
p = (result - 1 + LORA_SFFT_LEN) & (LORA_SFFT_LEN -1);
|
||||||
|
q = (result + 1) & (LORA_SFFT_LEN -1);
|
||||||
|
finetune[15 & m_time] = (mag[p] > mag[q]) ? -1 : 1;
|
||||||
|
|
||||||
|
if (peak < negpeak * 4)
|
||||||
|
result = -1;
|
||||||
result = synch(result);
|
result = synch(result);
|
||||||
} else {
|
|
||||||
result = synch(-1);
|
|
||||||
}
|
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
m_result = result;
|
m_result = result;
|
||||||
return m_result;
|
return m_result;
|
||||||
|
@ -85,6 +85,7 @@ private:
|
|||||||
sfft* negaFilter;
|
sfft* negaFilter;
|
||||||
float* mov;
|
float* mov;
|
||||||
short* history;
|
short* history;
|
||||||
|
short* finetune;
|
||||||
|
|
||||||
NCO m_nco;
|
NCO m_nco;
|
||||||
Interpolator m_interpolator;
|
Interpolator m_interpolator;
|
||||||
|
Loading…
Reference in New Issue
Block a user