[Solved] classes

hi all
i am having trouble understanding how to go about making this work
i have pieced together code from various sources and created a library for stepper movements
and am having trouble figuring out how i can pass direction variables into the function and have it output to proper pin on arduino
the catch is there are several instances of the class with all different direction output pins i guess i would like to know is there a way to pass a 1 into function call and have it digital write to the pin in the calling instance
im not really sure how to return data from functions or if thats what im even looking for

here is a copy of the source file and header file

// Header file


#ifndef accel_h
#define accel_h

#include "Arduino.h"

class step_Accel {

  private:
     int _steps;
     byte _step_Pin;
     byte _DIR;
    
    
  public:
    
    
     step_Accel(int steps, byte step_Pin, byte Dir);
     void Move(int steps, byte step_Pin, byte Dir);

};
#endif
// Source file

#include "arduino.h"
#include "accel.h"

step_Accel::step_Accel(int steps, byte step_Pin, byte Dir) {
    _steps = steps;
    _step_Pin = step_Pin;
    _DIR = Dir;
	
   
    
}                                                **not sure if this is what i need to pass in the (byte Dir)
void step_Accel::Move(int steps, byte step_Pin, byte Dir) {

	 if (_DIR == 1)                 ***this is what i have added for picking direction of rotation and it 
        digitalWrite(Dir, HIGH);        works on my test sketch but as a tab of the sketch***

       else  
        digitalWrite(Dir, LOW);

         
  int lowSpeed = 2000;                                  // Adjust for lowest speed 
  int highSpeed = 300;                                  // Highest speed is 200 with 400 steps per revolution
  int change = 2;

  int rampUpStop = (lowSpeed - highSpeed) / change;
  if ( rampUpStop > _steps / 2 )
    rampUpStop = _steps / 2;
  int rampDownStart = _steps - rampUpStop;

  int d = lowSpeed;

  for (int i = 0; i < _steps; i++) {
    digitalWrite(step_Pin, HIGH);
    digitalWrite(step_Pin, LOW);
    delayMicroseconds(d);

    if ( i < rampUpStop )
      d -= change;
    else if ( i > rampDownStart )
      d += change;
  } // close for loop
  
} // close function

here is a copy of the instances i created and a function call

step_Accel cell_Pickup_Extend1 = step_Accel(extend1_Steps, 2, pickup_Dir_Pin);
step_Accel cell_Pickup_Extend2 = step_Accel(extend2_Steps, 2, pickup_Dir_Pin);
step_Accel carriage_Extend = step_Accel(10000, 6, carriage_Dir_Pin);

 cell_Pickup_Extend1.Move(extend1_Steps, 2, 1);

a few of the different distances to move
int extend1_Steps = 6000;                   
int extend2_Steps = 1000;

It's really quite simple. You just need to change the return value to a type you choose, such as 'int' or 'long' instead of void. Then when you plan to exit, you use the return statement, with the desired value, e.g. 'return steps'. Then you can assign the result of the call to a variable as you seem to be doing.

so

long step_Accel::Move(int steps, byte step_Pin, byte Dir) {

instead of

void step_Accel::Move(int steps, byte step_Pin, byte Dir) {

Disclaimer: it's not clear to me what the nature of the variable you're passing is. So I couldn't see in the code exactly what variable or result to return from the function.

thank you for the reply
its very hard to explain what im trying to do but i will give it another try
i have a bunch of moves on a bunch of different steppers so basically i want to move the direction pins into the library i put together
the problem is that there are 3 different steppers and i have 3 dir pins with different names so when i call the move function
cell_Pickup_Extend1.Move(extend1_Steps, 2, 1); extend1 steps is 6000 steps and its on step pin 2 but i pass in a 1 or a 0 for the if statement
if (_DIR == 1)
digitalWrite(Dir, HIGH);

else
digitalWrite(Dir, LOW); and it only goes one direction like its defaulting to high or low
and i have other calls to Move() function for carriages that have different pins
if that makes any sense at all

basically if i call cell_Pickup_Extend1.Move(extend1_Steps, 2, 1); i want it to digitalWrite pickup_Dir_Pin high

but if i call the move function with carriage_Extend.Move(10000, 5, 1); i want to digitalWrite to the carriage dir pin instead

:astonished:

i can post the whole sketch but its rather long if that would help

I think i figured it out i had to add another variable to my function call one for steps one for step pin one for direction if statement and the last for direction pin
Ex: cell_Pickup_Extend1.Move(extend1_Steps, 2, 1, 3);
And in my instance i created

step_Accel cell_Pickup_Extend2 = step_Accel(extend2_Steps, 2, 1, pickup_Dir_Pin