Blame view

telemetry/code/monitor/graph_plotter_rewrite.py 1.29 KB
001c428d   Christopher Stone   Beginnings of a c...
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/env python

import pyglet
#import math
#import time
#import serial

from colours import *

class Plot:
    def __init__(self, title="Unknown", size=(640, 480)):
948da001   Christopher Stone   More progress on ...
12
13
14
15
16
17
18
19
20
21
22
        self.title = 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.on_resize = self.resize
        self.window.on_draw = self.draw
    
    def resize(width, height):
        self.size = (width, height)
        
001c428d   Christopher Stone   Beginnings of a c...
23
    def draw(self):
948da001   Christopher Stone   More progress on ...
24
25
26
        self.drawBackground()
        self.drawHeading()
        
001c428d   Christopher Stone   Beginnings of a c...
27
28
29
30
31
32
33
34
35
36
37
38
39
    def drawBackground(self):
        pyglet.image.SolidColorImagePattern(WHITE).create_image(self.size[0], self.size[1]).blit(0, 0)
        
    def drawHeading(self):
        heading = pyglet.text.Label(self.title, color=BLACK,
                            font_name=self.font, font_size=self.size[0]/50, x=self.size[0]/2, y=self.size[1],
                            anchor_x='center', anchor_y='top')
        heading.draw()
        

plots = []         
plots.append(Plot("This is a test plot"))

948da001   Christopher Stone   More progress on ...
40
41
42
43
44
45
46
def pollSerial():
    pass

#def update(foo):
#    for plot in plots:
#        plot.window.clear()
#        plot.draw()   
001c428d   Christopher Stone   Beginnings of a c...
47

948da001   Christopher Stone   More progress on ...
48
pyglet.clock.schedule_interval(pollSerial, 0.1)
001c428d   Christopher Stone   Beginnings of a c...
49
50

pyglet.app.run()