instead of using a function you could use a task. So when you press the function “StartTask(whatever);” when you press it again “StopTask(whatever);” thats how you would do it in RobotC i don’t know the coding for EasyC But basically I would use tasks instead of functions, unless there is a way to do it with functions that I don’t know about.
OP said EasyC (which does not have tasks) not RobotC.
The simplest usual way for this kind of thing in EasyC is to call your function conditionally from the main event loop.
Make sure your function only takes a short time to execute, or it will slow down the entire event loop.
As for the “toggle” function of the joystick button, I think there is a relatively new EasyC function with “toggle” in the name to toggle a variable when a button is pressed. If not, you’ll have to find one previously posted, or write your own.