From 8f1763987ca9fb5666efdb03abf99624eec66d30 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Fri, 14 Feb 2014 08:47:31 +0000 Subject: [PATCH] Add plot selector --- vis/visual.py | 13 ++++- vis/visual.ui | 155 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 149 insertions(+), 19 deletions(-) diff --git a/vis/visual.py b/vis/visual.py index 737e2d9..c4a266f 100644 --- a/vis/visual.py +++ b/vis/visual.py @@ -41,6 +41,8 @@ class Visual: self.builder.connect_signals(self) self.window = self.builder.get_object("window") self.settings = self.builder.get_object("settings") + self.plotsns = self.builder.get_object('sns') + self.plotaxis = self.builder.get_object('axis') self.accs = get_objects(['accx', 'accy', 'accz']) self.mags = get_objects(['magx', 'magy', 'magz']) @@ -173,8 +175,15 @@ class Visual: self.rate_cnt['a2d'] += setval(self.a2ds, state.a2d, []) # Save history - if state.a2d[0] != None: - self.history = self.history[1:] + [state.a2d[0]] + idxs = ['acc', 'mag', 'tch', 'lgt', 'a2d'] + sns = idxs[self.plotsns.get_active()] + axis = int(self.plotaxis.get_value()) + if hasattr(state, sns): + data = getattr(state, sns) + axis = min(axis-1, len(data)-1) + item = data[axis] + if item != None: + self.history = self.history[1:] + [item] def debug(self, state): print('update: ' + str(state)) diff --git a/vis/visual.ui b/vis/visual.ui index 9ec396d..3211896 100644 --- a/vis/visual.ui +++ b/vis/visual.ui @@ -2,21 +2,6 @@ - - Serial - gtk-connect - - - - Settings - gtk-preferences - - - - Xively - gtk-connect - - 100 1 @@ -34,6 +19,23 @@ 1 10 + + Settings + gtk-preferences + + + + Xively + gtk-connect + + + + 1 + 6 + 1 + 1 + 1 + 6 8 @@ -62,6 +64,34 @@ 1 10 + + + + + + + + acc + + + mag + + + tch + + + lgt + + + a2d + + + + + Serial + gtk-connect + + False @@ -1282,10 +1312,101 @@ - + True False - + 3 + 2 + 10 + + + True + False + 0 + Axis: + + + + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + True + ● + False + False + True + True + axis_adj + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + False + + + True + False + + + + + + 2 + 2 + 3 + + + + + True + False + 0 + Sensor: + + + + + + GTK_FILL + GTK_FILL + + + + + True + False + sensors + 0 + + + + 0 + + + + + 1 + 2 + GTK_FILL + + 2 -- 2.43.2