/***********************************************************************************************
 * Title:			get_char_test.c
 *
 * Programmer:		Todd Martin
 *
 * Date:				April, 1999
 *
 * Version:			5
 *
 * Description:	Tests using get_char() to control motors.  Written in IC.
 *
 **********************************************************************************************/

/*************************************** Constants ********************************************/
int MOTOR_JMPR = 0;			/* set to 1 for J4 and set to 0 for J5 */
/************************************ End of Constants ****************************************/

/***************************************** Globals ********************************************/
/************************************** End of Globals ****************************************/

/****************************************** Main **********************************************/
void main()
{
	initialize();
	receive();
}
/*************************************** End of Main ******************************************/

/************************************ Program Functions ***************************************/
void initialize()
{
	init_motors();
	init_serial();						/* initialize the serial port */
	motor(MOTOR_JMPR, 0.0);			/* stop motor */
}

void receive()		/* receives characters from the serial port */
{
	char data;

	while (1)
	{
		data = get_char();
		if ((data == 'B') || (data == 'b'))		/* apply the brakes */
		{
			motor(MOTOR_JMPR, 0.0); 
		}
		else if ((data == 'I') || (data == 'i'))
		{
				motor(MOTOR_JMPR, 100.0); 
		}
		else if ((data == 'K') || (data == 'k'))
		{
				motor(MOTOR_JMPR, -100.0); 
		}
		else
		{
			/* continue as previously instructed */
		}
	}
}

void wait(int milli_seconds)
{
	long timer_a;

	timer_a = mseconds() + (long) milli_seconds;
	while (timer_a > mseconds()) 
	{
		defer();
	}
}
/******************************** End of Program Functions *************************************/


