void normalizeSensorArray(int sensorArray[TOTALSENSORS])
{

	// Stores Previous Line Signal. If New Line Signal is Empty, then restore previous Line Signal as current one.
	static int previousSensorArray[TOTALSENSORS] = {0, 0, 0, 1, 0, 0, 0};
	int i;
	
	if(isArrayEmpty(sensorArray))										// Check if Robot DOES NOT detect Line. If TRUE, restore previous known Line Position.
	{
		for(i = 0 ; i < TOTALSENSORS ; i++)
		{
			sensorArray[i] = previousSensorArray[i];
		}
	}
	else if(isArrayFull(sensorArray))									// Check if Robot detects a line throughout. If TRUE, restore previous known Line Position.
	{
		
		for(i = 0 ; i < TOTALSENSORS ; i++)
		{
			sensorArray[i] = previousSensorArray[i];
		}
	}
	else																// If Line is distinguished properly, Remember it.
	{
		for(i = 0 ; i < TOTALSENSORS ; i++)
		{
			previousSensorArray[i] = sensorArray[i];
		}
	}
	
}
Example #2
0
int main()
{
    ArrayType   arr;
    initArray(&arr,2);
    arr.array[0] = 1;
    arr.array[1] = 2;
    printArray(&arr);
    if(isArrayFull(&arr,3))
    {
        extendArray(&arr,4);
        arr.array[2] = 3;
        arr.array[3] = 4;
    }
    printArray(&arr);
    freeArray(arr);
    return 0;
}