#include "KMotionDef.h"
#include "SimpleHomeIndexFunction.c" 

main()
{
		int result;
	
//Test
	//int axis=2;
	//float speed=10;
	//int dir=1;
	//printf(axis, speed, dir, "\n");
	
// HOME Z
	
	//SetBit(146); //Enable the axis
	
	result = SimpleHomeIndexFunction(2,  // axis number to home
			   10000.0,	// speed to move toward home. This number is ignored!
			     1,  	// direction to move toward home (+1 or -1)
			    141,	// limit bit number to watch for
			      0,	// limit polarity to wait for (1 or 0)
              1000.0,	// speed to move while searching for index
			     141,	// index bit number to watch for (use -1 for none)
			      1, 	// index polarity to wait for (1 or 0)
			   5000);	// amount to move inside limits
			   
	printf("Got through Z  Index subroutine\n");
		   
	if (result==0)
	{
		printf("Home Z succeeded\n");
	}
	else
	{
		printf("Home Z failed\n");
		//return;
	}
	//ClearBit(146);
	
	
	// HOME X
	
	result = SimpleHomeIndexFunction(1,  // axis number to home
			   2000.0,  // speed to move toward home
			   1,      // direction to move toward home (+1 or -1)
			   142, 	// limit bit number to watch for
			   0,		// limit polarity to wait for (1 or 0)
               1000.0,	// speed to move while searching for index
			   142,		// index bit number to watch for (use -1 for none)
			   1, 		// index polarity to wait for (1 or 0)
			   5000);	// amount to move inside limits
			   
	if (result==0)
	{
		printf("Home X succeded\n");
	}
	else
	{
		printf("Home X failed\n");
		//return;
	}
	

	// Maybe change this to HOME Spindle when I connect the encoder's Reference Index output?
	/* 
	HOME Y

	result = SimpleHomeIndexFunction(1,  // axis number to home
		   1000.0,  // speed to move toward home
			   -1,      // direction to move toward home (+1 or -1)
			   137, 	// limit bit number to watch for
			   0,		// limit polarity to wait for (1 or 0)
               100.0,	// speed to move while searching for index
			   -1,		// index bit number to watch for  (use -1 for none)
			   1, 		// index polarity to wait for (1 or 0)
			   5000);	// amount to move inside limits
			   
	if (result==0)
	{
		printf("Home Y succeded\n");
	}
	else
	{
		printf("Home Y failed\n");
		return;
	}
	*/
	
	return;
}

