Commit 01bfd701dd8cd1c32297b615cc1b004b2578a502
1 parent
44da1d6d
Exists in
master
Added docstrings
Showing
1 changed file
with
6 additions
and
0 deletions
Show diff stats
telemetry/code/monitor/graph_plotter_rewrite.py
| @@ -9,6 +9,7 @@ from colours import * | @@ -9,6 +9,7 @@ from colours import * | ||
| 9 | 9 | ||
| 10 | class Plot: | 10 | class Plot: |
| 11 | def __init__(self, title="Unknown", size=(640, 480)): | 11 | def __init__(self, title="Unknown", size=(640, 480)): |
| 12 | + """Setup a the details of a plot, and create a corresponding window""" | ||
| 12 | self.title = title | 13 | self.title = title |
| 13 | self.size = size | 14 | self.size = size |
| 14 | self.font = 'Arkhip' | 15 | self.font = 'Arkhip' |
| @@ -18,17 +19,21 @@ class Plot: | @@ -18,17 +19,21 @@ class Plot: | ||
| 18 | self.window.on_draw = self.draw | 19 | self.window.on_draw = self.draw |
| 19 | 20 | ||
| 20 | def resize(self, width, height): | 21 | def resize(self, width, height): |
| 22 | + """Handle a pyglet resize event, then give control back to the event loop""" | ||
| 21 | self.size = (width, height) | 23 | self.size = (width, height) |
| 22 | super(pyglet.window.Window, self.window).on_resize(width, height) | 24 | super(pyglet.window.Window, self.window).on_resize(width, height) |
| 23 | 25 | ||
| 24 | def draw(self): | 26 | def draw(self): |
| 27 | + """Draw all the components of the graph""" | ||
| 25 | self.drawBackground() | 28 | self.drawBackground() |
| 26 | self.drawHeading() | 29 | self.drawHeading() |
| 27 | 30 | ||
| 28 | def drawBackground(self): | 31 | def drawBackground(self): |
| 32 | + """Draw the graph background, currently a plain colour""" | ||
| 29 | pyglet.image.SolidColorImagePattern(WHITE).create_image(self.size[0], self.size[1]).blit(0, 0) | 33 | pyglet.image.SolidColorImagePattern(WHITE).create_image(self.size[0], self.size[1]).blit(0, 0) |
| 30 | 34 | ||
| 31 | def drawHeading(self): | 35 | def drawHeading(self): |
| 36 | + """Draw a title for the graph (duplicated in the window titlebar, if present""" | ||
| 32 | heading = pyglet.text.Label(self.title, color=BLACK, | 37 | heading = pyglet.text.Label(self.title, color=BLACK, |
| 33 | font_name=self.font, font_size=self.size[0]/50, x=self.size[0]/2, y=self.size[1], | 38 | font_name=self.font, font_size=self.size[0]/50, x=self.size[0]/2, y=self.size[1], |
| 34 | anchor_x='center', anchor_y='top') | 39 | anchor_x='center', anchor_y='top') |
| @@ -38,6 +43,7 @@ plots = [] | @@ -38,6 +43,7 @@ plots = [] | ||
| 38 | plots.append(Plot("This is a test plot")) | 43 | plots.append(Plot("This is a test plot")) |
| 39 | 44 | ||
| 40 | def pollSerial(foo): | 45 | def pollSerial(foo): |
| 46 | + """Dummy, will check serial port for incoming data""" | ||
| 41 | # Note, foo seems to be a float | 47 | # Note, foo seems to be a float |
| 42 | pass | 48 | pass |
| 43 | 49 |