Interleaving.

This commit is contained in:
John Greb 2015-01-31 23:41:06 +00:00
parent bfdd03e903
commit 36f92a89e1
3 changed files with 16 additions and 11 deletions

View File

@ -4,15 +4,16 @@
*/
// Needs adjusting for different sizes
void LoRaDemod::interleave(short* inout)
void LoRaDemod::interleave(char* inout)
{
int i, index = 6;
short in[index * 2];
char in[index * 2];
for (i = 0; i < index; i++)
in[i] = inout[i];
// top bits are swapped ?
for (i = 0; i < index; i++) {
inout[i] = (1 & in[0 + i]) | (2 & in[1 + i]) | (4 & in[2 + i])
| (8 & in[3 + i]) | (16 & in[4 + i]) | (32 & in[5 + i]);
inout[i] = (32 & in[1 + i]) | (16 & in[0 + i]) | (8 & in[2 + i])
| (4 & in[3 + i]) | (2 & in[4 + i]) | (1 & in[5 + i]);
in[i + index] = in[i];
}
}

View File

@ -74,16 +74,20 @@ void LoRaDemod::configure(MessageQueue* messageQueue, Real Bandwidth)
void LoRaDemod::dumpRaw()
{
short bin, j, max;
max = m_time / 4 - 1;
if (max > 32)
max = 32;
max = m_time / 4 - 3;
if (max > 36)
max = 36;
char text[256];
for ( j=0; j < max; j++) {
bin = (history[j * 4 + 4] + m_tune) & (LORA_SFFT_LEN - 1);
text[j] = 32 + (toGray(bin) >> 1);
bin = (history[j * 4 + 12] + m_tune ) & (LORA_SFFT_LEN - 1);
text[j] = toGray(bin >> 1);
}
for ( j=0; j < max; j+=6)
interleave(&text[j]);
for ( j=0; j < max; j++)
text[j] += 32;
text[j] = 0;
printf(">%s..(%d)\n", text, m_time / 4);
printf(">%s..(%d)\n", text, m_time / 4 - 2);
}
short LoRaDemod::synch(short bin)

View File

@ -44,7 +44,7 @@ public:
private:
int detect(Complex sample, Complex angle);
void interleave(short* inout);
void interleave(char* inout);
void dumpRaw(void);
short synch (short bin);
short toGray(short bin);