diff --git a/robots/little_john/telemetry/code/monitor/version1/main.py b/robots/little_john/telemetry/code/monitor/version1/main.py index 3eff5df..e91b7d9 100755 --- a/robots/little_john/telemetry/code/monitor/version1/main.py +++ b/robots/little_john/telemetry/code/monitor/version1/main.py @@ -8,7 +8,7 @@ # This code is incomplete, and is missing core features #import math -#import time +import time #import serial import pyglet @@ -57,6 +57,7 @@ class Series: self.ylimits = (0, 255) self.data = [] self.points = points + def addpoint(self, point): """Add a point to the dataset, and remove the oldest, if necessary""" self.data.append(point) @@ -177,10 +178,19 @@ def pollSerial(elapsed): values = datafeed.readline().strip().split(b", ") else: values = datafeed.readline().strip() - values = str(values).split(", ") + values = values.split(b', ') + for n, value in enumerate(values): + values[n] = float(value) + logging.info("Recieved data: " + str(values)) + testseries.addpoint(values) + +def fakePollSerial(elapsed): + """This function immitates the behaviour of pollSerial, for testing purposes""" + values = [time.time(), time.time()%10] + logging.info("Generated test data: " + str(values)) testseries.addpoint(values) # Pyglet looks after the main event loop, but this ensures that data keeps being read in -pyglet.clock.schedule_interval(pollSerial, 0.1) +pyglet.clock.schedule_interval(fakePollSerial, 0.1) pyglet.app.run() -- libgit2 0.21.2