action

package
v0.0.0-...-c5124e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSwPWM

func NewSwPWM(pin io.Setter) *swPwm

NewPWM creates a new s/w PWM controller.

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

func NewStepper(rev int, pin1, pin2, pin3, pin4 io.Setter) *Stepper

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) Close

func (s *Stepper) Close()

Close stops the motor and frees any resources.

func (*Stepper) GetStep

func (s *Stepper) GetStep() int64

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) Restore

func (s *Stepper) Restore(i int)

Restore initialises the sequence index to this value and sets the outputs

func (*Stepper) State

func (s *Stepper) State() int

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

func (s *Stepper) Step(rpm float64, halfSteps int)

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.

func (*Stepper) Stop

func (s *Stepper) Stop()

Stop aborts any current stepping, and flushes all queued requests.

func (*Stepper) Wait

func (s *Stepper) Wait()

Wait waits for all requests to complete

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL