waveform: add LogWaveform

This commit is contained in:
Simon Renblad 2024-01-26 13:29:35 +08:00
parent 09462442f7
commit 2473dd2f6e

View File

@ -104,6 +104,33 @@ class ReceiverProxyClient(_BaseProxyClient):
async def disconnect_cr(self):
await self.receiver.close()
class LogWaveform(_BaseWaveform):
def __init__(self, name, width, parent=None):
_BaseWaveform.__init__(self, name, width, parent, pen=None, symbol="x")
def onDataChange(self, data):
try:
x_data = zip(*data)[0]
self.plot_data_item.setData(
x=x_data, y=np.ones(len(x_data)))
old_msg = ""
old_x = 0
for x, msg in data:
if x == old_x:
old_msg += "\n" + msg
else:
lbl = pg.TextItem(old_msg)
self.addItem(lbl)
lbl.setPos(old_x, 1)
old_msg = msg
old_x = x
lbl = pg.TextItem(old_msg)
self.addItem(lbl)
lbl.setPos(old_x, 1)
except:
logger.error('Error when displaying waveform: {}'.format(self.name), exc_info=True)
self.plot_data_item.setData(x=[], y=[])
class _BackgroundItem(pg.GraphicsWidgetAnchor, pg.GraphicsWidget):
def __init__(self, parent, rect):