english
version "1.0"
identify "xyz"

module stepper

#: This module provides an interface to some stepper motors.

define stepper				#: Stepper motor state
    record
	debug_stream	out_stream	#: Debugging {out_stream}
	delay		delay		#: Delay object
	microseconds	unsigned	#: Number of microseconds between steps
	print_stream	out_stream	#: Print stream
	w		integer		#: Current W position
	w_offset	integer		#: Bit position for W
	w_maximum	integer		#: Maximum value of W
	w_minimum	integer		#: Minimum value of W
	x		integer		#: Current X position
	x_offset	integer		#: Bit position for X
	x_maximum	integer		#: Maximum value of X
	x_minimum	integer		#: Minimum value of X
	y		integer		#: Current Y position
	y_offset	integer		#: Bit position for Y
	y_maximum	integer		#: Maximum value of Y
	y_minimum	integer		#: Minimum value of Y
	z		integer		#: Current Z position
	z_offset	integer		#: Bit position for Z
	z_maximum	integer		#: Maximum value of Z
	z_minimum	integer		#: Minimum value of Z
    generate allocate, erase, print



procedure create@stepper
    takes
	w_maximum integer
	x_maximum integer
	y_maximum integer
	z_maximum integer
	debug_stream out_stream
    returns stepper

    #: This procedure will create and return a new {stepper} object.
    #, The maximum allowed values for the  w, x, y, and z axis are
    #, {w_maximum}, {x_maximum}, {y_maximum}, and {z_maximum}, respectively.


procedure goto@stepper
    takes
	stepper stepper
	w integer
	x integer
	y integer
	z integer
    returns_nothing

    #: This procedure will cause the stepper motors controlled by {stepper}
    #, to goto position ({w}, {x}, {y}, {z}) in a close approximiation to
    #, line in 4-space.



procedure step@stepper
    takes
	stepper stepper
    returns_nothing

    #: This procedure will cause the stepper motors controlled by {stepper}
    #, to goto the new values in {stepper}.  It is assumed that the new values
    #, in {stepper} have changed by at most +1 or -1.  This is a helper
    #, routine for {goto}@{stepper}.