diff --git a/telemetry/code/monitor/graph_plotter_rewrite.py b/telemetry/code/monitor/graph_plotter_rewrite.py index 57e2c9f..2eba4ed 100755 --- a/telemetry/code/monitor/graph_plotter_rewrite.py +++ b/telemetry/code/monitor/graph_plotter_rewrite.py @@ -7,14 +7,27 @@ import pyglet from colours import * +class Series: + def __init__(self, points=100, title="Series title", xname="x-axis name", yname="y-axis name"): + self.title = title + self.xname = xname + self.yname = yname + self.data = [] + self.points = points + def addpoint(self, point): + self.data.append(point) + if len(self.data) > self.points: + del self.points[-1] + class Plot: - def __init__(self, title="Unknown", size=(640, 480)): + def __init__(self, series, size=(640, 480)): """Setup a the details of a plot, and create a corresponding window""" - self.title = title + self.series = series + self.title = self.series.title self.size = size self.font = 'Arkhip' self.window = pyglet.window.Window(self.size[0], self.size[1], resizable=True) - self.window.set_caption(title) + self.window.set_caption(self.title) self.window.on_resize = self.resize self.window.on_draw = self.draw @@ -39,8 +52,10 @@ class Plot: anchor_x='center', anchor_y='top') heading.draw() +testseries = Series() + plots = [] -plots.append(Plot("This is a test plot")) +plots.append(Plot(testseries)) def pollSerial(foo): """Dummy, will check serial port for incoming data""" -- libgit2 0.21.2