[ui/plots] fixing error if nothing has been plotted, the gui could not close
This commit is contained in:
parent
75619cf1c8
commit
574e9a8110
@ -16,6 +16,7 @@ class Continously:
|
||||
self.figure = figure
|
||||
self.buffer = buffer
|
||||
self.last_plotted_index = 0
|
||||
self.timer = QTimer()
|
||||
|
||||
def plot(self, *args, **kwargs):
|
||||
self.figure.setBackground("w")
|
||||
@ -36,7 +37,6 @@ class Continously:
|
||||
)
|
||||
|
||||
# self.plot_index = 0
|
||||
self.timer = QTimer()
|
||||
self.CHUNK_PLOT = int(self.buffer.samplerate / 6)
|
||||
self.PLOT_HISTORY = 500_000 # The amount of data you want to keep on screen
|
||||
self.timer.setInterval(150)
|
||||
@ -70,18 +70,19 @@ class Continously:
|
||||
|
||||
def stop_plotting(self):
|
||||
self.timer.stop()
|
||||
total_count = self.buffer.totalcount()
|
||||
times, items = self.buffer.read(
|
||||
self.last_plotted_index,
|
||||
extend=total_count - self.last_plotted_index,
|
||||
)
|
||||
self.time = np.concatenate((self.time, times))[-self.PLOT_HISTORY :]
|
||||
self.data = np.concatenate((self.data, items))[-self.PLOT_HISTORY :]
|
||||
self.line.setData(
|
||||
self.time,
|
||||
self.data,
|
||||
)
|
||||
self.last_plotted_index += total_count - self.last_plotted_index
|
||||
if self.last_plotted_index > 0:
|
||||
total_count = self.buffer.totalcount()
|
||||
times, items = self.buffer.read(
|
||||
self.last_plotted_index,
|
||||
extend=total_count - self.last_plotted_index,
|
||||
)
|
||||
self.time = np.concatenate((self.time, times))[-self.PLOT_HISTORY :]
|
||||
self.data = np.concatenate((self.data, items))[-self.PLOT_HISTORY :]
|
||||
self.line.setData(
|
||||
self.time,
|
||||
self.data,
|
||||
)
|
||||
self.last_plotted_index += total_count - self.last_plotted_index
|
||||
|
||||
def refresh(self):
|
||||
self.continous_ax.enableAutoRange()
|
||||
|
Loading…
Reference in New Issue
Block a user