1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Spectrum analyser working

This commit is contained in:
Bertrand Songis 2019-02-07 10:58:14 +01:00
parent d01f1e8b3e
commit 2fc96cf14d
2 changed files with 17 additions and 12 deletions

View file

@ -98,23 +98,23 @@ bool Pxx2Pulses::setupSpectrumAnalyser(uint8_t module)
addFrameType(PXX2_TYPE_C_POWER_METER, PXX2_TYPE_ID_SPECTRUM);
Pxx2Transport::addByte(0x00);
uint32_t fq = 2500000000;
uint32_t fq = 2440000000; // 2440MHz
Pxx2Transport::addByte(fq);
Pxx2Transport::addByte(fq >> 8);
Pxx2Transport::addByte(fq >> 16);
Pxx2Transport::addByte(fq >> 24);
uint32_t span = 10000;
uint32_t span = 40000000; // 40MHz
Pxx2Transport::addByte(span);
Pxx2Transport::addByte(span >> 8);
Pxx2Transport::addByte(span >> 16);
Pxx2Transport::addByte(span >> 24);
uint32_t bandwidth = 10000;
Pxx2Transport::addByte(bandwidth);
Pxx2Transport::addByte(bandwidth >> 8);
Pxx2Transport::addByte(bandwidth >> 16);
Pxx2Transport::addByte(bandwidth >> 24);
uint32_t step = 100000; // 100KHz
Pxx2Transport::addByte(step);
Pxx2Transport::addByte(step >> 8);
Pxx2Transport::addByte(step >> 16);
Pxx2Transport::addByte(step >> 24);
static bool done = false;
@ -125,7 +125,6 @@ bool Pxx2Pulses::setupSpectrumAnalyser(uint8_t module)
return true;
}
bool Pxx2Pulses::setupFrame(uint8_t module)
{
initFrame();

View file

@ -139,11 +139,17 @@ void processSpectrumFrame(uint8_t module, uint8_t * frame)
uint32_t * frequency = (uint32_t *)&frame[4];
int8_t * power = (int8_t *)&frame[8];
// center = 2500000000
// left = 2500000000 - 5000
// span = 10000
// center = 2440000000; // 2440MHz
// span = 40000000; // 40MHz
// left = 2440000000 - 20000000
// step = 10000
// reusableBuffer.spectrum.bars[(*frequency - (2500000000 - 5000)) * 128 / 10000] = 127 + *power;
int32_t D = *frequency - (2440000000 - 40000000 / 2);
// TRACE("Fq=%u, Pw=%d, X=%d, Y=%d", *frequency, int32_t(*power), D * 128 / 40000000, int32_t(127 + *power));
uint8_t x = D * 128 / 40000000;
reusableBuffer.spectrum.bars[x] = 127 + *power;
}
void processRadioFrame(uint8_t module, uint8_t * frame)