fix
This commit is contained in:
@@ -10,6 +10,13 @@ import numpy as np
|
||||
from rfg_adc_plotter.constants import FFT_LEN, SWEEP_FREQ_MAX_GHZ, SWEEP_FREQ_MIN_GHZ
|
||||
from rfg_adc_plotter.processing.fft import compute_distance_axis, compute_fft_mag_row, fft_mag_to_db
|
||||
|
||||
# The device sweep length jitters by a few percent (e.g. 896..920). Only treat a
|
||||
# shrink as real when the new width drops below this fraction of the current width;
|
||||
# genuine format changes (e.g. 2048 -> 256, or halving) fall well below it. This
|
||||
# stops the ring from reallocating every frame — which churned the buffer and made
|
||||
# the B-scan flicker.
|
||||
RING_WIDTH_SHRINK_FRACTION = 0.8
|
||||
|
||||
|
||||
class RingBuffer:
|
||||
"""Store raw sweeps, FFT rows, and matching time markers."""
|
||||
@@ -103,7 +110,12 @@ class RingBuffer:
|
||||
self.ring_fft_input = np.full((self.max_sweeps, self.width), np.nan + 0j, dtype=np.complex64)
|
||||
self.head = 0
|
||||
changed = True
|
||||
elif target_width != self.width:
|
||||
elif target_width > self.width or target_width < int(self.width * RING_WIDTH_SHRINK_FRACTION):
|
||||
# Resize when the sweep grows, or shrinks by a meaningful fraction (a real
|
||||
# format change). Ignore small shrinks: the device sweep length jitters by
|
||||
# a few percent (e.g. 896 vs 920). Resizing on every such shrink churned
|
||||
# the ring every frame and made the B-scan flicker. A shorter sweep just
|
||||
# fills fewer columns (the rest stays NaN); the width converges to the max.
|
||||
new_ring = np.full((self.max_sweeps, target_width), np.nan, dtype=np.float32)
|
||||
new_fft_input = np.full((self.max_sweeps, target_width), np.nan + 0j, dtype=np.complex64)
|
||||
take = min(self.width, target_width)
|
||||
|
||||
Reference in New Issue
Block a user