@@ -869,9 +869,11 @@ proc watchHAL {which} {
869869 set label [lindex [split $which +] end]
870870
871871 # check if pin or param is writable
872+ # var writable: 1=yes, 0=no, -1=writable but connected to signal
872873 set writable 0
873874 set showret [join [hal show $vartype $label ] " " ]
874875 if {$vartype == " pin" } {
876+ # check if pin is input
875877 if {[string index [lindex $showret 9] 0] == " I" } {
876878 # check if signals are connected to pin
877879 if {[string first " ==" [lindex $showret 12] 0] < 0} {
@@ -881,9 +883,16 @@ proc watchHAL {which} {
881883 }
882884 }
883885 } elseif {$vartype == " param" } {
886+ # check if parameter is writable
884887 if {[lindex $showret 8] == " RW" } {
885888 set writable 1
886889 }
890+ } elseif {$vartype == " sig" } {
891+ # puts stderr "return $showret, found: [string first "<==" $showret 0]"
892+ # check if signal has no writers
893+ if {[string first " <==" $showret 0] < 0} {
894+ set writable 1
895+ }
887896 }
888897
889898 $::cisp create text $::col1_width [expr $i * 20 + 13] -text $label \
@@ -893,26 +902,38 @@ proc watchHAL {which} {
893902 $::cisp create oval 10 [expr $i * 20 + 5] 25 [expr $i * 20 + 20] \
894903 -fill lightgray -tag oval$i
895904 if {$writable == 1} {
896- canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
897- [expr {$i * 20 + 4}] 24 17 " Set" [list hal_setp $label 1] 1
898- canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 20] \
899- [expr {$i * 20 + 4}] 24 17 " Clr" [list hal_setp $label 0] 1
905+ if {$vartype == " sig" } {
906+ canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
907+ [expr {$i * 20 + 4}] 24 17 " Set" [list hal_sets $label 1] 1
908+ canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 20] \
909+ [expr {$i * 20 + 4}] 24 17 " Clr" [list hal_sets $label 0] 1
910+ } else {
911+ canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
912+ [expr {$i * 20 + 4}] 24 17 " Set" [list hal_setp $label 1] 1
913+ canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 20] \
914+ [expr {$i * 20 + 4}] 24 17 " Clr" [list hal_setp $label 0] 1
915+ }
900916 } elseif {$writable == -1} {
901917 canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
902- [expr $i * 20 + 4] 24 17 " Set" [list hal_setp $label 1 ] 0
918+ [expr $i * 20 + 4] 24 17 " Set" [] 0
903919 canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 20] \
904- [expr $i * 20 + 4] 24 17 " Clr" [list hal_setp $label 0 ] 0
920+ [expr $i * 20 + 4] 24 17 " Clr" [] 0
905921 }
906922 } else {
907923 $::cisp create text 10 [expr $i * 20 + 12] -text " " \
908924 -anchor w -tag text$i
909925
910926 if {$writable == 1} {
911- canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
912- [expr $i * 20 + 4] 52 17 " Set val" [list setValue $label ] 1
927+ if {$vartype == " sig" } {
928+ canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
929+ [expr $i * 20 + 4] 52 17 " Set val" [list setsValue $label ] 1
930+ } else {
931+ canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
932+ [expr $i * 20 + 4] 52 17 " Set val" [list setpValue $label ] 1
933+ }
913934 } elseif {$writable == -1} {
914935 canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
915- [expr $i * 20 + 4] 52 17 " Set val" [list setValue $label ] 0
936+ [expr $i * 20 + 4] 52 17 " Set val" [] 0
916937 }
917938 }
918939 if {$i > 1} {$::cisp create line 10 [expr $i * 20 + 3] [expr $canvaswidth - 52] \
@@ -988,19 +1009,31 @@ proc hal_setp {label val} {
9881009 eval hal " setp $label $val "
9891010}
9901011
1012+ proc hal_sets {label val} {
1013+ eval hal " sets $label $val "
1014+ }
1015+
9911016proc copyName {label} {
9921017 clipboard clear
9931018 clipboard append $label
9941019}
9951020
996- proc setValue {label} {
1021+ proc setpValue {label} {
9971022 set val [eval hal " getp $label " ]
9981023 set val [entrybox $val [msgcat::mc " Set" ] $label ]
9991024 if {$val ! = " cancel" } {
10001025 eval hal " setp $label $val "
10011026 }
10021027}
10031028
1029+ proc setsValue {label} {
1030+ set val [eval hal " gets $label " ]
1031+ set val [entrybox $val [msgcat::mc " Set" ] $label ]
1032+ if {$val ! = " cancel" } {
1033+ eval hal " sets $label $val "
1034+ }
1035+ }
1036+
10041037proc unlinkp {label i} {
10051038 # when unlink command successful --> rebuild list
10061039 if {[eval hal " unlinkp $label " ] == " Pin '$label ' unlinked" } {
0 commit comments