mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 22:35:12 +03:00
Improve spectrum
This commit is contained in:
parent
f528de89c2
commit
5eda7dc6dd
3 changed files with 36 additions and 17 deletions
|
@ -32,8 +32,24 @@ void menuRadioSpectrum(event_t event)
|
|||
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_SPECTRUM_ANALYSER;
|
||||
}
|
||||
|
||||
uint8_t peak=1;
|
||||
uint32_t peak_x=0;
|
||||
for (uint8_t i=0; i<LCD_W; i++) {
|
||||
uint8_t h = reusableBuffer.spectrum.bars[i] >> 2;
|
||||
uint8_t h = reusableBuffer.spectrum.bars[i];
|
||||
if(h > peak) {
|
||||
peak_x = i;
|
||||
peak=h;
|
||||
}
|
||||
lcdDrawSolidVerticalLine(i, LCD_H - h, h);
|
||||
}
|
||||
lcdDrawText(1,10, "F:", 0);
|
||||
lcdDrawNumber(lcdLastRightPos, 10, reusableBuffer.spectrum.fq/10000000,PREC2);
|
||||
lcdDrawText(lcdLastRightPos, 10, "GHz");
|
||||
lcdDrawText(1,10+FH, "S:", 0);
|
||||
lcdDrawNumber(lcdLastRightPos, 10+FH, reusableBuffer.spectrum.span/1000000,0);
|
||||
lcdDrawText(lcdLastRightPos, 10+FH, "MHz");
|
||||
|
||||
lcdDrawText(80,10, "P:", 0);
|
||||
lcdDrawNumber(lcdLastRightPos, 10, ((reusableBuffer.spectrum.fq - reusableBuffer.spectrum.span/2) + peak_x * (reusableBuffer.spectrum.span / 128)) / 10000000,PREC2);
|
||||
lcdDrawText(lcdLastRightPos, 10, "GHz");
|
||||
}
|
||||
|
|
|
@ -1161,6 +1161,9 @@ union ReusableBuffer
|
|||
struct
|
||||
{
|
||||
uint8_t bars[128];
|
||||
uint32_t fq;
|
||||
uint32_t span;
|
||||
uint32_t step;
|
||||
} spectrum;
|
||||
|
||||
#if defined(STM32)
|
||||
|
|
|
@ -104,23 +104,23 @@ bool Pxx2Pulses::setupSpectrumAnalyser(uint8_t module)
|
|||
addFrameType(PXX2_TYPE_C_POWER_METER, PXX2_TYPE_ID_SPECTRUM);
|
||||
Pxx2Transport::addByte(0x00);
|
||||
|
||||
uint32_t fq = 2440000000; // 2440MHz
|
||||
Pxx2Transport::addByte(fq);
|
||||
Pxx2Transport::addByte(fq >> 8);
|
||||
Pxx2Transport::addByte(fq >> 16);
|
||||
Pxx2Transport::addByte(fq >> 24);
|
||||
reusableBuffer.spectrum.fq = 2440000000; // 2440MHz
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.fq);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.fq >> 8);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.fq >> 16);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.fq >> 24);
|
||||
|
||||
uint32_t span = 40000000; // 40MHz
|
||||
Pxx2Transport::addByte(span);
|
||||
Pxx2Transport::addByte(span >> 8);
|
||||
Pxx2Transport::addByte(span >> 16);
|
||||
Pxx2Transport::addByte(span >> 24);
|
||||
reusableBuffer.spectrum.span = 40000000; // 40MHz
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.span);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.span >> 8);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.span >> 16);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.span >> 24);
|
||||
|
||||
uint32_t step = 100000; // 100KHz
|
||||
Pxx2Transport::addByte(step);
|
||||
Pxx2Transport::addByte(step >> 8);
|
||||
Pxx2Transport::addByte(step >> 16);
|
||||
Pxx2Transport::addByte(step >> 24);
|
||||
reusableBuffer.spectrum.step = 100000; // 100KHz
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.step);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.step >> 8);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.step >> 16);
|
||||
Pxx2Transport::addByte(reusableBuffer.spectrum.step >> 24);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue