void setDelay()
{
	unsigned int num;
	while (1)
	{
		num = ADC_read(0, 10, true);
		delay = num >> 5;
		x_yield();
	}
	
}
Beispiel #2
0
/*
* Serial_read_string
*
* Reads a string form a specified serial port.
*
* @param int port - the port ID
* @param char * data - the array to be read into
* @param int data_length - the length of the char array
* @return int - 1 if sucessful, 0 if not
*/
int Serial_read_string(int port, char * data, int data_length) {
	char latest;
	int i = 0;

	//loop until end of data
	while (i < data_length) {
		//get latest character
		latest = Serial_read(port);
		if (latest != 0xFF) {
			if (latest == 0x0D) {
				//the input has terminated
				data[i] = 0x00;//null terminate string
				return 1;
			}
			//write the next character into the buffer
			data[i++]=latest;
		}
		//if we got back a -1 from Serial_read, just loop again
		x_yield();
	}
	//we've used more than the whole array, error
	return 0;
}