Skip to content

Commit 23db1d6

Browse files
authored
Merge pull request #2023 from hansu/halshow-add-buttons-for-signals
Halshow: add buttons for signals
2 parents 1374b76 + 941cbae commit 23db1d6

1 file changed

Lines changed: 47 additions & 12 deletions

File tree

tcl/bin/halshow.tcl

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -867,11 +867,13 @@ proc watchHAL {which} {
867867
set ::watchlist_len [llength $::watchlist]
868868
set i $::watchlist_len
869869
set label [lindex [split $which +] end]
870-
870+
set labelcolor black
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,38 +883,59 @@ 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+
set labelcolor #6e3400
891+
} elseif {$vartype == "sig"} {
892+
# puts stderr "return $showret, found: [string first "<==" $showret 0]"
893+
# check if signal has no writers
894+
if {[string first "<==" $showret 0] < 0} {
895+
set writable 1
896+
}
897+
set labelcolor blue3
887898
}
888899

889900
$::cisp create text $::col1_width [expr $i * 20 + 13] -text $label \
890-
-anchor w -tag $label
901+
-anchor w -tag $label -fill $labelcolor
891902
set canvaswidth [winfo width $::cisp]
892903
if {$type == "bit"} {
893904
$::cisp create oval 10 [expr $i * 20 + 5] 25 [expr $i * 20 + 20] \
894905
-fill lightgray -tag oval$i
895906
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
907+
if {$vartype == "sig"} {
908+
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
909+
[expr {$i * 20 + 4}] 24 17 "Set" [list hal_sets $label 1] 1
910+
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 20] \
911+
[expr {$i * 20 + 4}] 24 17 "Clr" [list hal_sets $label 0] 1
912+
} else {
913+
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
914+
[expr {$i * 20 + 4}] 24 17 "Set" [list hal_setp $label 1] 1
915+
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 20] \
916+
[expr {$i * 20 + 4}] 24 17 "Clr" [list hal_setp $label 0] 1
917+
}
900918
} elseif {$writable == -1} {
901919
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
902-
[expr $i * 20 + 4] 24 17 "Set" [list hal_setp $label 1] 0
920+
[expr $i * 20 + 4] 24 17 "Set" [] 0
903921
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 20] \
904-
[expr $i * 20 + 4] 24 17 "Clr" [list hal_setp $label 0] 0
922+
[expr $i * 20 + 4] 24 17 "Clr" [] 0
905923
}
906924
} else {
907925
$::cisp create text 10 [expr $i * 20 + 12] -text "" \
908926
-anchor w -tag text$i
909927

910928
if {$writable == 1} {
911-
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
912-
[expr $i * 20 + 4] 52 17 "Set val" [list setValue $label] 1
929+
if {$vartype == "sig"} {
930+
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
931+
[expr $i * 20 + 4] 52 17 "Set val" [list setsValue $label] 1
932+
} else {
933+
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
934+
[expr $i * 20 + 4] 52 17 "Set val" [list setpValue $label] 1
935+
}
913936
} elseif {$writable == -1} {
914937
canvasbutton::canvasbutton $::cisp [expr $canvaswidth - 48] \
915-
[expr $i * 20 + 4] 52 17 "Set val" [list setValue $label] 0
938+
[expr $i * 20 + 4] 52 17 "Set val" [] 0
916939
}
917940
}
918941
if {$i > 1} {$::cisp create line 10 [expr $i * 20 + 3] [expr $canvaswidth - 52] \
@@ -988,19 +1011,31 @@ proc hal_setp {label val} {
9881011
eval hal "setp $label $val"
9891012
}
9901013

1014+
proc hal_sets {label val} {
1015+
eval hal "sets $label $val"
1016+
}
1017+
9911018
proc copyName {label} {
9921019
clipboard clear
9931020
clipboard append $label
9941021
}
9951022

996-
proc setValue {label} {
1023+
proc setpValue {label} {
9971024
set val [eval hal "getp $label"]
9981025
set val [entrybox $val [msgcat::mc "Set"] $label]
9991026
if {$val != "cancel"} {
10001027
eval hal "setp $label $val"
10011028
}
10021029
}
10031030

1031+
proc setsValue {label} {
1032+
set val [eval hal "gets $label"]
1033+
set val [entrybox $val [msgcat::mc "Set"] $label]
1034+
if {$val != "cancel"} {
1035+
eval hal "sets $label $val"
1036+
}
1037+
}
1038+
10041039
proc unlinkp {label i} {
10051040
# when unlink command successful --> rebuild list
10061041
if {[eval hal "unlinkp $label"] == "Pin '$label' unlinked"} {

0 commit comments

Comments
 (0)