Bi-directional homing with central limit switch

Hi,

I am currently using the marlin firmware on a CNC board and motor set up for a robotics project, rather than a 3D printer, to make use of all the pre-written functions in the G-Code. It has been working really well so far.

For my next stage, the home position must be at the centre of the linear actuator leadscrew. My idea is to place a limit switch in the central location and jog the actuator mount left or right until it reaches this spot. I have already coded this up with G1 etc.

I wondered if there was a simpler way, using G28.

For example: for the linear actuator X, if the user could feed in G28 X_1 to home from the right towards the centre, and feed in X_2 to home from the left towards the centre.

I have tried to implement this, but it seems that two limit switches are required - could I essentially just split my limit switch wires and do a hardware fix, or does anyone know a better software fix?

Thanks so much!