Commit 001c428de519d831d8f7151c5c0af32be7f78876

Authored by Christopher Stone
1 parent ae0e1c6f
Exists in master

Beginnings of a complete rewrite for the plotting code, neater this time

telemetry/code/monitor/colours.py 0 โ†’ 100644
... ... @@ -0,0 +1,5 @@
  1 +WHITE = (255, 255, 255, 255)
  2 +BLACK = (0, 0, 0, 255)
  3 +RED = (255, 0, 0, 255)
  4 +GREEN = (0, 255, 0, 255)
  5 +BLUE = (0, 0, 255, 255)
0 6 \ No newline at end of file
... ...
telemetry/code/monitor/colours.pyc 0 โ†’ 100644
No preview for this file type
telemetry/code/monitor/graph_plotter_rewrite.py 0 โ†’ 100755
... ... @@ -0,0 +1,42 @@
  1 +#!/usr/bin/env python
  2 +
  3 +import pyglet
  4 +#import math
  5 +#import time
  6 +#import serial
  7 +
  8 +from colours import *
  9 +
  10 +class Plot:
  11 + def __init__(self, title="Unknown", size=(640, 480)):
  12 + self.title = title
  13 + self.size = size
  14 + self.font = 'Arkhip'
  15 + self.window = pyglet.window.Window(self.size[0], self.size[1], resizable=True)
  16 + self.window.set_caption(title)
  17 +
  18 + def draw(self):
  19 + self.drawBackground()
  20 + self.drawHeading()
  21 +
  22 + def drawBackground(self):
  23 + pyglet.image.SolidColorImagePattern(WHITE).create_image(self.size[0], self.size[1]).blit(0, 0)
  24 +
  25 + def drawHeading(self):
  26 + heading = pyglet.text.Label(self.title, color=BLACK,
  27 + font_name=self.font, font_size=self.size[0]/50, x=self.size[0]/2, y=self.size[1],
  28 + anchor_x='center', anchor_y='top')
  29 + heading.draw()
  30 +
  31 +
  32 +plots = []
  33 +plots.append(Plot("This is a test plot"))
  34 +
  35 +def update(foo):
  36 + for plot in plots:
  37 + plot.window.clear()
  38 + plot.draw()
  39 +
  40 +pyglet.clock.schedule_interval(update, 0.01)
  41 +
  42 +pyglet.app.run()
0 43 \ No newline at end of file
... ...