sim_pin: support option --title title_string

Signed-off-by: Dewey Garrett <dgarrett@panix.com>
This commit is contained in:
Dewey Garrett 2017-02-15 17:53:46 -07:00
parent 45e6e66590
commit 9e2397632b
3 changed files with 30 additions and 4 deletions

View file

@ -27,7 +27,11 @@
\fBsim_pin\fR \- gui for displaying and setting one or more Hal inputs
.SH SYNOPSIS
.B \fBsim_pin\fR \fIname1\fR [\fIname2\fR [\fIname3\fR ...]]
.B \fBsim_pin\fR \fI[Options]\fR \fIname1\fR [\fIname2\fR [\fIname3\fR ...]]
\fIOptions\fR:
\fB--help\fR (shows help text)
\fB--title title_string\fR
For bit items, the name may include a /mode= specifier:
\fInamei\fR\fB/mode=\fR[\fBpulse\fR | \fBtoggle\fR | \fBhold\fR]

View file

@ -160,7 +160,11 @@ sim_pin is a command line utility to display and update any number of
writable pins, parameters or signals. Usage:
----
Usage:
sim_pin name1 [name2 ...] &
sim_pin [Options] name1 [name2 ...] &
Options:
--help (this text)
--title title_string (window title, default: sim_pin)
Note: LinuxCNC (or a standalone Hal application) must be running
A named item can specify a pin, param, or signal

View file

@ -10,7 +10,11 @@ if [catch {package require Hal} msg] {
proc usage {} {
puts "
Usage:
$::SP(progname) name1 \[name2 ...\] &
$::SP(progname) \[Options\] name1 \[name2 ...\] &
Options:
--help (this text)
--title title_string (window title, default: $::SP(progname))
Note: LinuxCNC (or a standalone Hal application) must be running
A named item can specify a pin, param, or signal
@ -514,13 +518,27 @@ if [catch {
set ::SP(iprefix) "Initial=" ;# initial value prefix
set ::SP(prefix) "Current=" ;# current value prefix
set ::SP(pulse,ms) 200 ;# pulse duration
wm title . $::SP(progname)
set ::SP(title) $::SP(progname)
set currentarg [lindex $::argv 0]
while {[string first "-" $currentarg] == 0} {
switch -- $currentarg {
--help {usage}
--title {set ::SP(title) [lindex $::argv 1]
set ::argv [lreplace $::argv 0 0]
}
}
set ::argv [lreplace $::argv 0 0]
set currentarg [lindex $::argv 0]
}
foreach itemname $::argv {
if [add_item_to_gui $::SP(id) $itemname] {
incr ::SP(id)
}
}
wm title . $::SP(title)
if {$::SP(id) < 1} usage
update_current_values
}