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'])
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))
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkToggleAction" id="serial_act">
- <property name="label" translatable="yes">Serial</property>
- <property name="stock_id">gtk-connect</property>
- <signal name="activate" handler="on_serial" swapped="no"/>
- </object>
- <object class="GtkAction" id="settings_act">
- <property name="label" translatable="yes">Settings</property>
- <property name="stock_id">gtk-preferences</property>
- <signal name="activate" handler="on_show" swapped="no"/>
- </object>
- <object class="GtkToggleAction" id="xively_act">
- <property name="label" translatable="yes">Xively</property>
- <property name="stock_id">gtk-connect</property>
- <signal name="activate" handler="on_xively" swapped="no"/>
- </object>
<object class="GtkAdjustment" id="a2d_adj">
<property name="upper">100</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAction" id="settings_act">
+ <property name="label" translatable="yes">Settings</property>
+ <property name="stock_id">gtk-preferences</property>
+ <signal name="activate" handler="on_show" swapped="no"/>
+ </object>
+ <object class="GtkToggleAction" id="xively_act">
+ <property name="label" translatable="yes">Xively</property>
+ <property name="stock_id">gtk-connect</property>
+ <signal name="activate" handler="on_xively" swapped="no"/>
+ </object>
+ <object class="GtkAdjustment" id="axis_adj">
+ <property name="lower">1</property>
+ <property name="upper">6</property>
+ <property name="value">1</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">1</property>
+ </object>
<object class="GtkAdjustment" id="datab_adj">
<property name="lower">6</property>
<property name="upper">8</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkListStore" id="sensors">
+ <columns>
+ <!-- column-name value -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">acc</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">mag</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">tch</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">lgt</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">a2d</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkToggleAction" id="serial_act">
+ <property name="label" translatable="yes">Serial</property>
+ <property name="stock_id">gtk-connect</property>
+ <signal name="activate" handler="on_serial" swapped="no"/>
+ </object>
<object class="GtkTextBuffer" id="serial_buf"/>
<object class="GtkDialog" id="settings">
<property name="can_focus">False</property>
</packing>
</child>
<child>
- <object class="GtkDrawingArea" id="plot">
+ <object class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <signal name="expose-event" handler="on_expose" swapped="no"/>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="axis_lbl">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Axis:</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="axis">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">axis_adj</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkViewport" id="plot_view">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkDrawingArea" id="plot">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="expose-event" handler="on_expose" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="sns_lbl">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Sensor:</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="sns">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">sensors</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText" id="sensor"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">2</property>