#%TITLE% JOY.MAC
#%NAME%
# Joystick for SPEC motors
#
#%CATEGORY% Positioning
#
#%DESCRIPTION%
# This is a single macro file to move up and down a motor by using
# "k" and "l" keys. The macro allows to change the stepsize on the fly.
#
#%END%
##
# joy
##
#%UU% motor stepsize
#%MDESC%
#
# Starts the joystick function
#
def joy '
JOYTRUE=1
JOYFALSE=0
#
# Usage.
if ($# != 2) {
print "Usage: joy motor stepsize "
exit
}
_joystep=$2
#
# Header
#
printf("\nSPEC Joystick on %s\n",motor_name($1))
printf("(k=up;l=down;n=new step;other=exit)")
printf("\n%10.9s\n", motor_name($1))
printf("%10.4f\r", A[$1])
#
# Main loop
#
JOY=JOYTRUE
while(JOY) {
joy_clean_buffer
sleep(0.1)
po=input(-1)
if (po=="k") {
#
# Positive movement
#
mvr $1 _joystep
waitmove;get_angles
printf("%10.4f\r", A[$1])
} else if (po=="l") {
#
# Negative movement
#
mvr $1 -_joystep
waitmove;get_angles
printf("%10.4f\r", A[$1])
} else if (po == "n") {
#
# New step
#
joy_clean_buffer
input(1)
_joystep=getval("New step",_joystep)
printf("%10.4f\r", A[$1])
} else if (po != "" && po != "\004") JOY=JOYFALSE
}
#
# Clear and goodbye
#
joy_clean_buffer
input(1)
waitmove;get_angles
printf("%10.4f\n", A[$1])
'
#%IU%
def joy_clean_buffer '
while((po=input(-1)) != "" && po != "\004") {}
'
#%MACROS%
#%IMACROS%
#%AUTHOR% Vicente Rey 23 Jan. 1995
#%TOC%
|