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 217 of file stepper.cpp.

217 {
218 if (!isBrainPinValid(p_stepPin) || !isBrainPinValid(p_directionPin)) {
219 return;
220 }
221
222 setReactionTime(reactionTime);
223
224 directionPinMode = p_directionPinMode;
225 directionPin.initPin("Stepper DIR", p_directionPin, directionPinMode);
226
227 stepPinMode = OM_DEFAULT; // todo: do we need configurable stepPinMode?
228 stepPin.initPin("Stepper step", p_stepPin, stepPinMode);
229
230 enablePinMode = p_enablePinMode;
231 enablePin.initPin("Stepper EN", p_enablePin, enablePinMode);
232
233 // All pins must be 0 for correct hardware startup (e.g. stepper auto-disabling circuit etc.).
234 enablePin.setValue(true); // disable stepper
235 stepPin.setValue(false);
236 directionPin.setValue(false);
237 m_currentDirection = false;
238}
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
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:202
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 // we move the motor only of it is powered from the main relay
178 return false;
179
180 enablePin.setValue(false); // enable stepper
181
182 stepPin.setValue(true);
183 pause();
184
185 stepPin.setValue(false);
186 pause();
187
188 enablePin.setValue(true); // disable stepper
189
190 return true;
191}
bool isMainRelayEnabled() const
Definition engine.cpp:539
void pause(int divisor=1) const
Definition stepper.cpp:197
static EngineAccessor engine
Definition engine.h:413

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 206 of file stepper.cpp.

206 {
207 setDirection(positive);
208 return pulse();
209}
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: