Implementing Accelstepper.h with (ps2) ps2x.h

(Sorry for my bad English, I’m not native speaker so)

So, I’m currently working on a project in which involves controlling a drilling tank. The tank’s arduino board(a mega in case you’re wondering, which also means I use only one to control everything) consist of various components:
ps2x receiver, slider(where I’m stuck at debugging, and the drill is attached to it), controller(for the wheels/trackers, not important to what I’m trying to fix), the relay(for the drill itself to spin CCW,CW, and stop, of course).

Now, I hope to make the slider to move down and up as I press a desired button on ps2, be it with acceleration or with constant speed(though I prefer the former).

void drilldown()
{
stepper.move(-20000);
stepper.runToPosition();
}

void drillup()
{
stepper.move(20000);
stepper.runToPosition();
}

//i use these voids just to “simplify” the code a bit

if (ps2x.ButtonPressed(PSB_CROSS))//something wrong with this
{

Serial.println(“manually going down”);
drilldown();
Serial.println(“going up”);
drillup();

}

Yet, whenever I press that button(cross,aka x) it will go up and down, but it will then execute all other buttons i designed in the code as well, which are,

void motorstop()
{
digitalWrite(drillpul, LOW);
digitalWrite(drilldir, LOW);
Serial.println(“drill off”);
}

void motorON()
{
digitalWrite(drillpul, LOW);
digitalWrite(drilldir, HIGH);
Serial.println(“drill on”);
}

if (ps2x.ButtonPressed(PSB_SQUARE))
{
motorON();
Serial.println(“square”);

}

if (ps2x.ButtonPressed(PSB_CIRCLE))
{
motorstop();
Serial.println(“circle”);
}

if (ps2x.ButtonPressed(PSB_SELECT))
{
Serial.println(“stop”);
stop();
}
delay(20);

AND

if (ps2x.ButtonPressed(PSB_START))
{
speed = 100;
for ( int i = 0; i < 3; i++) //not me bro
{

forward(speed);
delay(1500);
stop();
motorON();
drilldown();
drillup();
delay(100);
motorstop();
delay(1500);
Serial.println(“execute”);
delay(100);
}
}

As of now, I know the bug is due to the function stepper.runToPosition(); is a blocking function, so it will stop program execution until it is done(though I’m not yet grasp the idea of that fully). Therefore, it somehow neglects the if statements and run all functions in the button anyways.

Hence, is there anyway for me to make the slider move down with a buttonpressed, and perhaps with acceleration?And it would be very much helpful for you to send a solution with some explanation about the code and on what is a blocking function, as well as how the libraries work.

tank_3.3_testing_controls.ino (8.64 KB)

https://imgur.com/dJNv1KT

this is the screenshot of my screen, and is it normal for me not having the tool bar like yours????????????