pavels / spektrum

rtl-sdr spectrum analyzer
BSD 3-Clause "New" or "Revised" License
577 stars 91 forks source link

Avr/Max function and dB scale offset #18

Closed artmaen closed 5 years ago

artmaen commented 5 years ago

Hi. Here's some suggestions. When using as spectrum analyzer, normal (averaging) graph shows really low spikes especially with wider sweep. Dynamic suffers and different signal leves are quite off. Min/Max function shows better but all 3 graphs is not useful for this.

Maybe another button for this? I tested next code where replaced Min/Max function as Avr/Max, normally average and Max as one graph for analyzer.

Next, dB scale. I tested additional function for change scale offset as required. Useful to compare levels or set dB scale to show dBm. As gain=0 and offset -45 seems to be quite close to dBm scale on my dongle (at VHF).

I haven't try more as editing config to save settings etc... These just for ideas.

regards


Avr/Max function: spektrum.pde:

--edited this, Min/max button text--

cp5.addToggle("minmaxToggle") .setPosition(x + 70, y) .setSize(20,20) .setValue(false) .getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Avr/Max") ;

--disabed this--

/
if(minmaxDisplay){ graphDrawLine(lastPoint.x, (int)((lastPoint.yMin - scaleMin)
scaleFactor), point.x, (int)((point.yMin - scaleMin) scaleFactor), #C23B22, 255); graphDrawLine(lastPoint.x, (int)((lastPoint.yMax - scaleMin) scaleFactor), point.x, (int)((point.yMax - scaleMin) * scaleFactor), #03C03C, 255);

}

*/


scale.pde

--edited, added lines (minmaxDisp..)--

while (position < length) { if (oldIndex != (int)position) { DataPoint dp = new DataPoint(); dp.x = (int)position - 1; dp.yMin = minValue; dp.yMax = maxValue; if(minmaxDisplay){ dp.yAvg = maxValue; } else { dp.yAvg = (double)sum / (double)count; } ret[oldIndex] = dp;


Db scale function: spektrum.pde

--added--

int dboffSet = 0;

cp5.addTextfield("dboffsetTxt") .setPosition(x + 100 , y) .setSize(30, 20) .setText(str(dboffSet)) .setAutoClear(false) .getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Db offset") ;

public void dboffsetTxt(String tmpText){

dboffSet = parseInt(tmpText); cp5.get(Textfield.class,"dboffsetTxt").setText(str(dboffSet));

}


graph.pde:

--edited--

double yPos = maxValue to: double yPos = maxValue + dboffSet;