Index: trunk/3DEES/UserInterface.tcl
===================================================================
--- trunk/3DEES/UserInterface.tcl	(revision 184)
+++ trunk/3DEES/UserInterface.tcl	(revision 186)
@@ -56,16 +56,20 @@
         {3_2} 13
         {3_3} 14
+        {3_4} 15
         {4_0} 3
-        {4_1} 15
-        {4_2} 16
-        {4_3} 17
+        {4_1} 16
+        {4_2} 17
+        {4_3} 18
+        {4_4} 19
         {5_0} 4
-        {5_1} 18
-        {5_2} 19
-        {5_3} 20
+        {5_1} 20
+        {5_2} 21
+        {5_3} 22
+        {5_4} 23
         {6_0} 5
-        {6_1} 21
-        {6_2} 22
-        {6_3} 23
+        {6_1} 24
+        {6_2} 25
+        {6_3} 26
+        {6_4} 27
     }
 # -------------------------------------------------------------------------
@@ -82,22 +86,26 @@
         11 3000
         2    10
-        12   31
-        13   52
-        14   79
-        3    60
-        15  135
-        16  171
-        17  233
-        4   249
-        18  348
-        19  495
-        20  693
-        5   505
-        21  606
-        22  707
-        23  808
-    }
-
-    
+        12   10
+        13   31
+        14   52
+        15   79
+        3    10
+        16   60
+        17  135
+        18  171
+        19  233
+        4    10
+        20  249
+        21  348
+        22  495
+        23  693
+        5    10
+        24  505
+        25  606
+        26  707
+        27  808
+    }
+
+
 # -------------------------------------------------------------------------
 
@@ -109,4 +117,5 @@
         3 {af}
         4 {bn}
+        5 {bf}
     }
 
@@ -328,5 +337,5 @@
         trace add variable [myvar delay] write [myproc delay_update]
         trace add variable [myvar thrs] write [myproc thrs_update]
-        
+
         my delay_update
         my thrs_update
@@ -342,4 +351,5 @@
 
         set thrs [frame ${master}.thrs]
+        set bins [frame ${master}.bins]
         set clip [frame ${master}.clip]
 
@@ -347,5 +357,5 @@
 
         set column 0
-        foreach {input} [list "ADC" "thrs 1" "thrs 2" "thrs 3" "thrs 4"] {
+        foreach {input} [list "ADC" "e thrs min" "e thrs max" "p thrs min" "p thrs max"] {
             label ${config(thrs)}.label_${column} -text "${input}"
             grid ${config(thrs)}.label_${column} -row 0 -column ${column} -sticky ew -padx 5 -pady 7
@@ -353,5 +363,5 @@
         }
 
-        foreach {ch id} [array get adcCodes] {
+        foreach {ch id} [array get adcCodes {[1-2]}] {
             label ${config(thrs)}.chan_${ch} -text "${id} "
             grid ${config(thrs)}.chan_${ch} -row ${ch} -column 0 -sticky ew -padx 5 -pady 7
@@ -367,4 +377,28 @@
 
         grid $config(thrs) -row 0 -column 0 -sticky news -padx 10
+
+        set config(bins) [labelframe ${bins}.frame -borderwidth 1 -relief sunken -text {Bins}]
+
+        set column 0
+        foreach {input} [list "ADC" "thrs 0" "thrs 1" "thrs 2" "thrs 3" "thrs 4"] {
+            label ${config(bins)}.label_${column} -text "${input}"
+            grid ${config(bins)}.label_${column} -row 0 -column ${column} -sticky ew -padx 5 -pady 7
+            incr column
+        }
+
+        foreach {ch id} [array get adcCodes {[3-6]}] {
+            label ${config(bins)}.chan_${ch} -text "${id} "
+            grid ${config(bins)}.chan_${ch} -row ${ch} -column 0 -sticky ew -padx 5 -pady 7
+            foreach {num} [list 0 1 2 3 4] {
+                set column [expr {$num + 1}]
+                set value $cfgCodes(${ch}_${num})
+                spinbox ${config(bins)}.bins_${value} -from 0 -to 4095 \
+                  -increment 10 -width 10 -textvariable [myvar thrs($value)] \
+                  -validate all -vcmd {::mca::validate 4095 4 %P}
+                grid ${config(bins)}.bins_${value} -row ${ch} -column ${column} -sticky w -padx 5 -pady 7
+            }
+        }
+
+        grid $config(bins) -row 0 -column 0 -sticky news -padx 10
 
         set config(clip) [labelframe ${clip}.frame -borderwidth 1 -relief sunken -text {Signal clipping}]
@@ -392,12 +426,15 @@
         grid $config(clip) -row 0 -column 0 -sticky news -padx 10
 
-        grid ${thrs} -row 0 -column 1 -sticky news
+        grid ${thrs} -row 0 -column 2 -sticky news
+        grid ${bins} -row 0 -column 1 -sticky news
         grid ${clip} -row 0 -column 0 -sticky news
 
         grid columnconfigure ${master} 0 -weight 1
         grid columnconfigure ${master} 1 -weight 1
+        grid columnconfigure ${master} 2 -weight 1
         grid rowconfigure ${master} 0 -weight 1
 
         grid rowconfigure ${thrs} 0 -weight 0
+        grid rowconfigure ${bins} 0 -weight 0
         grid rowconfigure ${clip} 0 -weight 0
     }
@@ -413,5 +450,5 @@
             set b $decay($i).0
             set value [expr int(exp(-${a}/${b})*1024*20)]
-            append command [format {000200%02x0004%04x} [expr {34 + 2 * (${i} - 1)}] $value]
+            append command [format {000200%02x0004%04x} [expr {36 + 2 * (${i} - 1)}] $value]
         }
 
@@ -440,5 +477,5 @@
 
         set command {}
-        for {set i 0} {$i <= 23} {incr i} {
+        for {set i 0} {$i <= 27} {incr i} {
             append command [format {000200%02x0004%04x} [expr {10 + ${i}}] $thrs($i)]
         }
@@ -639,9 +676,9 @@
         my set data {}
 
-        vector create [myvar xvec](64)
-        vector create [myvar yvec](64)
-
-        # fill one vector for the x axis with 64 points
-        [myvar xvec] seq -0.5 63.5
+        vector create [myvar xvec](80)
+        vector create [myvar yvec](80)
+
+        # fill one vector for the x axis with 80 points
+        [myvar xvec] seq -0.5 79.5
 
         my setup
@@ -684,5 +721,5 @@
         $graph grid configure -hide no
         $graph legend configure -hide yes
-        $graph axis configure x -min 0 -max 64
+        $graph axis configure x -min 0 -max 80
 
         set config [frame ${master}.config -width 170]
@@ -845,5 +882,5 @@
         my instvar controller config number
 
-        set size 64
+        set size 80
 
         set prefix [format {%x} [expr {$number + 2}]]
@@ -892,5 +929,5 @@
 
     HstDisplay instproc register {} {
-        my save_data [join [[myvar yvec] range 0 63] \n]
+        my save_data [join [[myvar yvec] range 0 79] \n]
     }
 
