]> Pileus Git - ~andy/csm213a-hw/commitdiff
Add device name
authorAndy Spencer <andy753421@gmail.com>
Sun, 2 Feb 2014 09:09:45 +0000 (09:09 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 2 Feb 2014 09:09:45 +0000 (09:09 +0000)
vis/config.py
vis/settings.cfg
vis/visual.py
vis/visual.ui

index c3ea321978c41e635b2805e9b4c83698920aef1d..79da22307c552a657dae2059da8e5078a953fe3f 100644 (file)
@@ -5,6 +5,7 @@ class Config:
        filename = "settings.cfg"
 
        defaults = {
+               'baudrate': '/dev/ttyACM0',
                'baudrate': '9600',
                'parity':   'N',
                'databits': '8',
@@ -25,6 +26,7 @@ class Config:
        def load(self):
                self.parser.read(self.filename)
 
+               self.device   = self.parser.get('serial', 'device')
                self.baudrate = self.parser.getint('serial', 'baudrate')
                self.parity   = self.parser.get('serial', 'parity')
                self.databits = self.parser.getint('serial', 'databits')
index e83fece414dbc8d0e432bd2e19be13562f819b4d..8757c24b8defa6cfc5c4072c06af8bb79d9e7f61 100644 (file)
@@ -1,4 +1,5 @@
 [serial]
+device   = /dev/ttyACM0
 buadrate = 9600
 parity   = N
 databits = 8
index f07ea0d11c2b0a4858803892992c997f60392c01..0b21349b76bb6a4aa12afef8626b473af3b6a441 100644 (file)
@@ -66,10 +66,12 @@ class Visual:
         # Methods
        def load_config(self):
                # Serial settings
+               device = self.builder.get_object("device")
                baud   = self.builder.get_object("baudrate")
                parity = self.builder.get_object("parity")
                datab  = self.builder.get_object("databits")
                stopb  = self.builder.get_object("stopbits")
+               device.set_text(self.config.device)
                baud.set_value(self.config.baudrate)
                parity.set_text(self.config.parity)
                datab.set_value(self.config.databits)
index 96915dff690391b988dfd1a6e172d76eb5d7ae1c..6ef41b13bd2e2f923c8ba52ca8f6b81c251a58a5 100644 (file)
@@ -2,6 +2,21 @@
 <interface>
   <requires lib="gtk+" version="2.24"/>
   <!-- interface-naming-policy project-wide -->
+  <object class="GtkToggleAction" id="serial_con">
+    <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_con">
+    <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="page_increment">10</property>
   </object>
   <object class="GtkTextBuffer" id="serial_buf"/>
-  <object class="GtkToggleAction" id="serial_con">
-    <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_con">
-    <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="GtkDialog" id="settings">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
                   <object class="GtkTable" id="table1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">4</property>
+                    <property name="n_rows">5</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">20</property>
                     <child>
                         <property name="label" translatable="yes">Baud rate</property>
                       </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>
                         <property name="label" translatable="yes">Stop bits</property>
                       </object>
                       <packing>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                         <property name="label" translatable="yes">Data bits</property>
                       </object>
                       <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                       <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>
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
                         <property name="label" translatable="yes">Parity</property>
                       </object>
                       <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                       <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="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="device_lbl">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Device</property>
+                      </object>
+                      <packing>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="device">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="invisible_char_set">True</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>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>