Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Stepper ¶
type Stepper struct {
// contains filtered or unexported fields
}
Stepper represents a stepper motor. All actual stepping is done in a background goroutine, so requests can be queued. All step values assume half-steps. The current step number is maintained as an absolute number, referenced from 0 when the stepper is first initialised. This can be a negative or positive number, depending on the movement.
func NewStepper ¶
NewStepper creates and initialises a Stepper struct, representing a stepper motor controlled by 4 GPIO pins. rev is the number of steps per revolution as a reference value for determining the delays between steps.
func (*Stepper) GetStep ¶
GetStep returns the current step number, which is an accumulative signed value representing the steps moved, with 0 as the starting location.
func (*Stepper) Off ¶
func (s *Stepper) Off()
Off turns off the GPIOs to remove the power from the motor.
func (*Stepper) State ¶
State returns the current sequence index, so that the current state of the motor can be saved and then restored in a new instance. This allows the exact state of the motor to be restored across process restarts so that the maximum accuracy can be guaranteed.
func (*Stepper) Step ¶
Step queues a request to step the motor at the RPM selected for the number of half-steps. If halfSteps is positive, then the motor is run clockwise, otherwise ccw. A number of requests can be queued.