rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes
StepDirectionStepper Class Referencefinal

#include <stepper.h>

Inheritance diagram for StepDirectionStepper:
Inheritance graph
[legend]
Collaboration diagram for StepDirectionStepper:
Collaboration graph
[legend]

Public Member Functions

void initialize (brain_pin_e stepPin, brain_pin_e directionPin, pin_output_mode_e directionPinMode, float reactionTime, brain_pin_e enablePin, pin_output_mode_e enablePinMode)
 
bool step (bool positive) override
 
- Public Member Functions inherited from StepperHw
void pause (int divisor=1) const
 
virtual void sleep ()
 

Private Member Functions

bool pulse ()
 
void setDirection (bool isIncrementing)
 

Private Attributes

bool m_currentDirection = false
 
OutputPin directionPin
 
OutputPin stepPin
 
OutputPin enablePin
 
pin_output_mode_e directionPinMode
 
pin_output_mode_e stepPinMode
 
pin_output_mode_e enablePinMode
 

Additional Inherited Members

- Protected Member Functions inherited from StepperHw
void setReactionTime (float ms)
 

Detailed Description

Definition at line 30 of file stepper.h.

Member Function Documentation

◆ initialize()

void StepDirectionStepper::initialize ( brain_pin_e  stepPin,
brain_pin_e  directionPin,
pin_output_mode_e  directionPinMode,
float  reactionTime,
brain_pin_e  enablePin,
pin_output_mode_e  enablePinMode 
)

Definition at line 213 of file stepper.cpp.

213 {
214 if (!isBrainPinValid(p_stepPin) || !isBrainPinValid(p_directionPin)) {
215 return;
216 }
217
218 setReactionTime(reactionTime);
219
220 directionPinMode = p_directionPinMode;
221 directionPin.initPin("Stepper DIR", p_directionPin, directionPinMode);
222
223 stepPinMode = OM_DEFAULT; // todo: do we need configurable stepPinMode?
224 stepPin.initPin("Stepper step", p_stepPin, stepPinMode);
225
226 enablePinMode = p_enablePinMode;
227 enablePin.initPin("Stepper EN", p_enablePin, enablePinMode);
228
229 // All pins must be 0 for correct hardware startup (e.g. stepper auto-disabling circuit etc.).
230 enablePin.setValue(true); // disable stepper
231 stepPin.setValue(false);
232 directionPin.setValue(false);
233 m_currentDirection = false;
234}
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:712
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:605
pin_output_mode_e enablePinMode
Definition stepper.h:43
OutputPin enablePin
Definition stepper.h:42
pin_output_mode_e stepPinMode
Definition stepper.h:43
OutputPin stepPin
Definition stepper.h:42
OutputPin directionPin
Definition stepper.h:42
pin_output_mode_e directionPinMode
Definition stepper.h:43
void setReactionTime(float ms)
Definition stepper.cpp:198
bool isBrainPinValid(brain_pin_e brainPin)

Referenced by applyIACposition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pulse()

bool StepDirectionStepper::pulse ( )
private

Definition at line 175 of file stepper.cpp.

175 {
176 enablePin.setValue(false); // enable stepper
177
178 stepPin.setValue(true);
179 pause();
180
181 stepPin.setValue(false);
182 pause();
183
184 enablePin.setValue(true); // disable stepper
185
186 return true;
187}
void pause(int divisor=1) const
Definition stepper.cpp:193

Referenced by step().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDirection()

void StepDirectionStepper::setDirection ( bool  isIncrementing)
private

Definition at line 165 of file stepper.cpp.

165 {
166 if (isIncrementing != m_currentDirection) {
167 // compensate stepper motor inertia
168 pause();
169 m_currentDirection = isIncrementing;
170 }
171
172 directionPin.setValue(isIncrementing);
173}

Referenced by step().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ step()

bool StepDirectionStepper::step ( bool  positive)
overridevirtual

Implements StepperHw.

Definition at line 202 of file stepper.cpp.

202 {
203 setDirection(positive);
204 return pulse();
205}
void setDirection(bool isIncrementing)
Definition stepper.cpp:165
Here is the call graph for this function:

Field Documentation

◆ directionPin

OutputPin StepDirectionStepper::directionPin
private

Definition at line 42 of file stepper.h.

Referenced by initialize(), and setDirection().

◆ directionPinMode

pin_output_mode_e StepDirectionStepper::directionPinMode
private

Definition at line 43 of file stepper.h.

Referenced by initialize().

◆ enablePin

OutputPin StepDirectionStepper::enablePin
private

Definition at line 42 of file stepper.h.

Referenced by initialize(), and pulse().

◆ enablePinMode

pin_output_mode_e StepDirectionStepper::enablePinMode
private

Definition at line 43 of file stepper.h.

Referenced by initialize().

◆ m_currentDirection

bool StepDirectionStepper::m_currentDirection = false
private

Definition at line 40 of file stepper.h.

Referenced by initialize(), and setDirection().

◆ stepPin

OutputPin StepDirectionStepper::stepPin
private

Definition at line 42 of file stepper.h.

Referenced by initialize(), and pulse().

◆ stepPinMode

pin_output_mode_e StepDirectionStepper::stepPinMode
private

Definition at line 43 of file stepper.h.

Referenced by initialize().


The documentation for this class was generated from the following files: