peak trace: fix for log scale
This commit is contained in:
@@ -191,12 +191,14 @@ void Measurements::drawWaterfall(const SpectrumDisplay& specDisplay,
|
|||||||
int count = std::min(screenRows, peakHistLen_);
|
int count = std::min(screenRows, peakHistLen_);
|
||||||
ImU32 traceCol = IM_COL32(255, 30, 30, 200);
|
ImU32 traceCol = IM_COL32(255, 30, 30, 200);
|
||||||
|
|
||||||
// Convert bin index to screen X via normalized frequency fraction
|
// Convert bin index to screen X (respects log scale)
|
||||||
|
double fMin = isIQ ? -sampleRate / 2.0 : 0.0;
|
||||||
|
double fMax = isIQ ? sampleRate / 2.0 : sampleRate / 2.0;
|
||||||
auto binToX = [&](int bin) -> float {
|
auto binToX = [&](int bin) -> float {
|
||||||
float frac = (static_cast<float>(bin) + 0.5f) / spectrumSize;
|
double freq = fMin + (static_cast<double>(bin) + 0.5) / spectrumSize * (fMax - fMin);
|
||||||
// Map through view range
|
return specDisplay.freqToScreenX(freq, posX, sizeX,
|
||||||
float viewFrac = (frac - viewLo) / (viewHi - viewLo);
|
sampleRate, isIQ, freqScale,
|
||||||
return posX + viewFrac * sizeX;
|
viewLo, viewHi);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Walk from newest (bottom) to oldest (top)
|
// Walk from newest (bottom) to oldest (top)
|
||||||
|
|||||||
Reference in New Issue
Block a user