Index: trunk/MultiChannelUSB/UserInterface.tcl
===================================================================
--- trunk/MultiChannelUSB/UserInterface.tcl	(revision 73)
+++ trunk/MultiChannelUSB/UserInterface.tcl	(revision 74)
@@ -61,9 +61,5 @@
         my instvar data xvec yvec
 
-        dict set data none {}
-        dict set data uwt1 {}
-        dict set data uwt2 {}
-        dict set data uwt3 {}
-#        dict set data sum8 {}
+        set data {}
 
         $yvec set {}
@@ -73,13 +69,20 @@
 
     OscDisplay instproc start {} {
-        my instvar config
-        
+        my instvar config trig_mux disp_mux
+
+        set trig_mux 2
+        set disp_mux 2
+
         trace add variable [myvar auto] write [myproc auto_update]
         trace add variable [myvar thrs] write [myproc thrs_update]
-        trace add variable [myvar fltr_val] write [myproc fltr_val_update]
-
-        ${config}.thrs_check deselect
-        ${config}.thrs_field set 10
-        ${config}.none select
+        trace add variable [myvar thrs_val] write [myproc thrs_val_update]
+        trace add variable [myvar disp_val] write [myproc disp_val_update]
+        trace add variable [myvar trig_val] write [myproc trig_val_update]
+
+        ${config}.auto_check select
+        ${config}.thrs_check select
+        ${config}.thrs_field set 60
+        ${config}.disp_uwt2 select
+        ${config}.trig_uwt2 select
     }
 
@@ -89,5 +92,5 @@
         my instvar number master
         my instvar data xvec yvec
-        my instvar config auto thrs thrs_val fltr_val
+        my instvar config auto thrs thrs_val disp_val trig_val
 
         my set restart_command [usb::convert 0001000${number}00000000]
@@ -114,12 +117,23 @@
         frame ${config}.spc2 -width 10 -height 10
 
-        label ${config}.fltr -text {low-pass filter}
-        radiobutton ${config}.none -text none -variable [myvar fltr_val] -value none
-        radiobutton ${config}.uwt1 -text uwt1 -variable [myvar fltr_val] -value uwt1
-        radiobutton ${config}.uwt2 -text uwt2 -variable [myvar fltr_val] -value uwt2
-        radiobutton ${config}.uwt3 -text uwt3 -variable [myvar fltr_val] -value uwt3
-#        radiobutton ${config}.sum8 -text sum8 -variable [myvar fltr_val] -value sum8
+        label ${config}.disp -text {display input}
+        radiobutton ${config}.disp_data -text {raw data} -variable [myvar disp_val] -value data
+        radiobutton ${config}.disp_uwt1 -text {filter 1} -variable [myvar disp_val] -value uwt1
+        radiobutton ${config}.disp_uwt2 -text {filter 2} -variable [myvar disp_val] -value uwt2
+        radiobutton ${config}.disp_uwt3 -text {filter 3} -variable [myvar disp_val] -value uwt3
+        radiobutton ${config}.disp_base -text {baseline} -variable [myvar disp_val] -value base
+#        radiobutton ${config}.disp_sum8 -text {sum of 8} -variable [myvar disp_val] -value sum8
 
         frame ${config}.spc3 -width 10 -height 10
+
+        label ${config}.trig -text {trigger input}
+        radiobutton ${config}.trig_data -text {raw data} -variable [myvar trig_val] -value data
+        radiobutton ${config}.trig_uwt1 -text {filter 1} -variable [myvar trig_val] -value uwt1
+        radiobutton ${config}.trig_uwt2 -text {filter 2} -variable [myvar trig_val] -value uwt2
+        radiobutton ${config}.trig_uwt3 -text {filter 3} -variable [myvar trig_val] -value uwt3
+        radiobutton ${config}.trig_base -text {baseline} -variable [myvar trig_val] -value base
+#        radiobutton ${config}.trig_sum8 -text {sum of 8} -variable [myvar trig_val] -value sum8
+
+        frame ${config}.spc4 -width 10 -height 10
 
         button ${config}.acquire -text Acquire \
@@ -135,11 +149,20 @@
         grid ${config}.thrs_field -sticky ew -pady 1 -padx 5
         grid ${config}.spc2
-        grid ${config}.fltr -sticky w -pady 1 -padx 3
-        grid ${config}.none -sticky w
-        grid ${config}.uwt1 -sticky w
-        grid ${config}.uwt2 -sticky w
-        grid ${config}.uwt3 -sticky w
-#        grid ${config}.sum8 -sticky w
+        grid ${config}.disp -sticky w -pady 1 -padx 3
+        grid ${config}.disp_data -sticky w
+        grid ${config}.disp_uwt1 -sticky w
+        grid ${config}.disp_uwt2 -sticky w
+        grid ${config}.disp_uwt3 -sticky w
+        grid ${config}.disp_base -sticky w
+#        grid ${config}.disp_sum8 -sticky w
         grid ${config}.spc3
+        grid ${config}.trig -sticky w -pady 1 -padx 3
+        grid ${config}.trig_data -sticky w
+        grid ${config}.trig_uwt1 -sticky w
+        grid ${config}.trig_uwt2 -sticky w
+        grid ${config}.trig_uwt3 -sticky w
+        grid ${config}.trig_base -sticky w
+#        grid ${config}.disp_sum8 -sticky w
+        grid ${config}.spc4
         grid ${config}.acquire -sticky ew -pady 3 -padx 5
         grid ${config}.restart -sticky ew -pady 3 -padx 5
@@ -161,5 +184,5 @@
 
     OscDisplay instproc auto_update args {
-        my instvar auto after_handle
+        my instvar config auto after_handle
 
         if {$auto} {
@@ -182,17 +205,96 @@
 
     OscDisplay instproc thrs_update args {
-        my instvar config thrs
+        my instvar config number thrs thrs_val
+
+        set val_addr [format %04x [expr {17 + ${number}}]]
+
         if {$thrs} {
             ${config}.thrs_field configure -state normal
+            my thrs_val_update
         } else {
             ${config}.thrs_field configure -state disabled
-        }
-    }
-
-# -------------------------------------------------------------------------
-
-    OscDisplay instproc fltr_val_update args {
-        my instvar yvec data fltr_val
-        $yvec set [dict get $data $fltr_val]
+            my send_data [usb::convert ${val_addr}000000000000]
+        }
+    }
+
+# -------------------------------------------------------------------------
+
+    OscDisplay instproc thrs_val_update args {
+        my instvar config number thrs_val
+
+        set val_addr [format %04x [expr {17 + ${number}}]]
+        set value [format %04x $thrs_val]
+
+        my send_data [usb::convert ${val_addr}${value}00000000]
+    }
+
+# -------------------------------------------------------------------------
+
+    OscDisplay instproc mux {} {
+        my instvar trig_mux disp_mux
+
+        format {00%x%x} $trig_mux $disp_mux
+    }
+
+# ------------------------------------------------------------------------
+
+    OscDisplay instproc disp_val_update args {
+        my instvar number disp_val disp_mux
+
+        set mux_addr [format %04x [expr {20 + ${number}}]]
+
+        switch -- $disp_val {
+            data {
+                set disp_mux 0
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            uwt1 {
+                set disp_mux 1
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            uwt2 {
+                set disp_mux 2
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            uwt3 {
+                set disp_mux 3
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            base {
+                set disp_mux 4
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+        }
+    }
+
+# ------------------------------------------------------------------------
+
+    OscDisplay instproc trig_val_update args {
+        my instvar number trig_val trig_mux
+
+        set mux_addr [format %04x [expr {20 + ${number}}]]
+
+        switch -- $trig_val {
+            data {
+                set trig_mux 0
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            uwt1 {
+                set trig_mux 1
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            uwt2 {
+                set trig_mux 2
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            uwt3 {
+                set trig_mux 3
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+            base {
+                set trig_mux 4
+                my send_data [usb::convert ${mux_addr}[my mux]00000000]
+            }
+        }
     }
 
@@ -246,5 +348,5 @@
     OscDisplay instproc acquire {} {
         global usb_handle
-        my instvar xvec yvec data fltr_val
+        my instvar xvec yvec data
         my instvar acquire_command
 
@@ -258,11 +360,7 @@
         }
 
-        dict set data none $usb_data
-        dict set data uwt1 [lindex [uwt 1 $usb_data] 1]
-        dict set data uwt2 [lindex [uwt 2 $usb_data] 1]
-        dict set data uwt3 [lindex [uwt 3 $usb_data] 1]
-#        dict set data sum8 [sum8 $usb_data]
-
-        $yvec set [dict get $data $fltr_val]
+        set data $usb_data
+
+        $yvec set $usb_data
     }
 
@@ -313,9 +411,5 @@
         my instvar data xvec yvec
 
-        dict set data none {}
-        dict set data uwt1 {}
-        dict set data uwt2 {}
-        dict set data uwt3 {}
-#        dict set data sum8 {}
+        set data {}
 
         $yvec set {}
@@ -325,12 +419,13 @@
 
     HstDisplay instproc start {} {
-        my instvar config peak_mux base_mux
-
+        my instvar config base_mux peak_mux
+
+        set base_mux 0
         set peak_mux 1
-        set base_mux 0
 
         trace add variable [myvar auto] write [myproc auto_update]
         trace add variable [myvar peak] write [myproc peak_update]
         trace add variable [myvar thrs] write [myproc thrs_update]
+        trace add variable [myvar thrs_val] write [myproc thrs_val_update]
         trace add variable [myvar base] write [myproc base_update]
         trace add variable [myvar base_typ] write [myproc base_typ_update]
@@ -446,7 +541,7 @@
 
     HstDisplay instproc mux {} {
-        my instvar peak_mux base_mux
-
-        format {%x%x%x%x} $base_mux $peak_mux 0 0
+        my instvar base_mux peak_mux
+
+        format {00%x%x} $base_mux $peak_mux
     }
 
@@ -456,5 +551,5 @@
         my instvar number peak peak_mux
 
-        set mux_addr [format %04x [expr {20 + ${number}}]]
+        set mux_addr [format %04x [expr {23 + ${number}}]]
 
         if {$peak} {
@@ -477,5 +572,5 @@
         if {$thrs} {
             ${config}.thrs_field configure -state normal
-            my send_data [usb::convert ${val_addr}${value}00000000]
+            my thrs_val_update
         } else {
             ${config}.thrs_field configure -state disabled
@@ -492,5 +587,4 @@
         set value [format %04x $thrs_val]
 
-        ${config}.base_field configure -state normal
         my send_data [usb::convert ${val_addr}${value}00000000]
     }
@@ -501,5 +595,5 @@
         my instvar config number base base_val base_mux
 
-        set mux_addr [format %04x [expr {20 + ${number}}]]
+        set mux_addr [format %04x [expr {23 + ${number}}]]
         set val_addr [format %04x [expr {11 + ${number}}]]
 
@@ -522,5 +616,5 @@
         my instvar config number base_typ base_val base_mux
 
-        set mux_addr [format %04x [expr {20 + ${number}}]]
+        set mux_addr [format %04x [expr {23 + ${number}}]]
         set val_addr [format %04x [expr {11 + ${number}}]]
         set value [format %04x $base_val]
