fix demod plot on first sample, remove spurious vertical line

This commit is contained in:
Philippe Teuwen 2021-08-01 19:52:45 +02:00
parent f65bc9af36
commit 6e3eff356b

View file

@ -443,9 +443,6 @@ void ProxWidget::resizeEvent(QResizeEvent *event) {
//----------- Plotting
int Plot::xCoordOf(int i, QRect r) {
if (i < 0) {
i = 0;
}
return r.left() + (int)((i - GraphStart) * GraphPixelsPerPoint);
}
@ -536,25 +533,19 @@ void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotati
painter->setPen(getColor(graphNum));
char str[5];
int absVMax = (int)(100 * 1.05 + 1);
int x = xCoordOf(DemodStart, plotRect);
int y = 0;
if (DemodStart >= 0) {
y = yCoordOf((buffer[BitStart] * 200 - 100) * -1, plotRect, absVMax);
} else {
y = yCoordOf(0, plotRect, absVMax);
}
penPath.moveTo(x, y);
delta_x = 0;
int clk = first_delta_x;
for (int i = BitStart; i < (int)len && xCoordOf(delta_x + DemodStart, plotRect) < plotRect.right(); i++) {
for (int j = 0; j < (clk) && i < (int)len && xCoordOf(DemodStart + delta_x + j, plotRect) < plotRect.right() ; j++) {
x = xCoordOf(DemodStart + delta_x + j, plotRect);
int x = xCoordOf(DemodStart + delta_x + j, plotRect);
int v = buffer[i] * 200 - 100;
y = yCoordOf(v, plotRect, absVMax);
penPath.lineTo(x, y);
int y = yCoordOf(v, plotRect, absVMax);
if ((i == BitStart) && (j == 0)) { // First point
penPath.moveTo(x, y);
} else {
penPath.lineTo(x, y);
}
if (GraphPixelsPerPoint > 10) {
QRect f(QPoint(x - 3, y - 3), QPoint(x + 3, y + 3));
painter->fillRect(f, getColor(graphNum));