Esempio n. 1
0
void nightRider(uint8 i)
{
    turnLedsOff();
    switch(i) {
    case 0:
        LED4_Write(0u);
        break;
    case 1:
    case 13:
        LED4_Write(0u);
        LED2_Write(0u);
        break;
    case 2:
    case 12:
        LED2_Write(0u);
        LED0_Write(0u);
        break;
    case 3:
    case 11:
        LED0_Write(0u);
        LED1_Write(0u);
        break;
    case 4:
    case 10:
        LED1_Write(0u);
        LED3_Write(0u);
        break;
    case 5:
    case 9:
        LED3_Write(0u);
        LED5_Write(0u);
        break;
    case 6:
    case 8:
        LED5_Write(0u);
        LED6_Write(0u);
        break;
    case 7:
        LED6_Write(0u);
        break;
    default:
        break;
    }
}
Esempio n. 2
0
void turnLedsOn()
{
    LED0_Write(0u);
    LED1_Write(0u);
    LED2_Write(0u);
    LED3_Write(0u);
    LED4_Write(0u);
    LED5_Write(0u);
    LED6_Write(0u);
    GPIO_0_Write(0u);
    GPIO_1_Write(0u);
}
Esempio n. 3
0
void DriveLEDs(ZONE_NAMES currentZone)
{
    #if(DRIVE_LEDS)
	/*Turn off all the LEDs and based on conditions turn ON required before driving LEDs*/
	LED_STATES LED1 = LED_OFF_GESTURES;
	LED_STATES LED2 = LED_OFF_GESTURES;
	LED_STATES LED3 = LED_OFF_GESTURES;
	LED_STATES LED4 = LED_OFF_GESTURES;
	LED_STATES LED5 = LED_OFF_GESTURES;
    #endif 

	#if(LED_DRIVE_SEQUENCE)
	{
        #if(DRIVE_LEDS)
		/*Three LEDs are used as visual feedback in X direction and three in Y direction
		LEDs are driven in the same direction as gesture
		LED1, LED2 and LED3 are placed from left to right
		LED5, LED2 and LED4 are placed from bottom to top
		Each LED is driven for 'N' loop times as configured in the macro*/
		
		switch(LEDDriveSequence)
		{
			case LEFT_TO_RIGHT:
			{
				/*Left to Right gesture is detected turn ON LEDs one after the other in the same order */
				if ((LEDCounter / LED_ON_TIME_LOOPS) == FIRST_LED)
				{
					LED1 = LED_ON_GESTURES;
				}
				else if ((LEDCounter / LED_ON_TIME_LOOPS) == SECOND_LED)
				{
					LED2 = LED_ON_GESTURES;
				}
				else if ((LEDCounter / LED_ON_TIME_LOOPS) == THIRD_LED)
				{
					LED3 = LED_ON_GESTURES;
				}
				break;
			}
			case RIGHT_TO_LEFT:
			{
				/*Right to Left gesture is detected turn ON LEDs one after the other in the same order */
				if ((LEDCounter / LED_ON_TIME_LOOPS) == FIRST_LED)
				{
					LED3 = LED_ON_GESTURES;
				}
				else if ((LEDCounter / LED_ON_TIME_LOOPS) == SECOND_LED)
				{
					LED2 = LED_ON_GESTURES;
				}
				else if ((LEDCounter / LED_ON_TIME_LOOPS) == THIRD_LED)
				{
					LED1 = LED_ON_GESTURES;
				}
				break;
			}
			case BOTTOM_TO_TOP:
			{
				/*Bottom to Top gesture is detected turn ON LEDs one after the other in the same order */
				if ((LEDCounter / LED_ON_TIME_LOOPS) == FIRST_LED)
				{
					LED5 = LED_ON_GESTURES;
				}
				else if ((LEDCounter / LED_ON_TIME_LOOPS) == SECOND_LED)
				{
					LED2 = LED_ON_GESTURES;
				}
				else if ((LEDCounter / LED_ON_TIME_LOOPS) == THIRD_LED)
				{
					LED4 = LED_ON_GESTURES;
				}
				break;
			}
			case TOP_TO_BOTTOM:
			{
				/*Top to Bottom gesture is detected turn ON LEDs one after the other in the same order */
				if ((LEDCounter / LED_ON_TIME_LOOPS) == FIRST_LED)
				{
					LED4 = LED_ON_GESTURES;
				}
				if ((LEDCounter / LED_ON_TIME_LOOPS) == SECOND_LED)
				{
					LED2 = LED_ON_GESTURES;
				}
				if ((LEDCounter / LED_ON_TIME_LOOPS) == THIRD_LED)
				{
					LED5 = LED_ON_GESTURES;
				}
				break;
			}
			default:
			{
				LED1 = LED_OFF_GESTURES;
		 		LED2 = LED_OFF_GESTURES;
				LED3 = LED_OFF_GESTURES;
				LED4 = LED_OFF_GESTURES;
				LED5 = LED_OFF_GESTURES;
			}
		}
    #endif 
		/*LED counter to track loop timings for LED drive*/
		if (LEDDriveSequence != TURN_ALL_LEDS_OFF)
		{
			LEDCounter++;
			if(LEDCounter >= LED_ON_TIME_LOOPS * LED_COUNT)
			{
				/*LED drive based on gesture is completed , change the LED sequence
				to turn OFF all the LEDs*/
				LEDDriveSequence = TURN_ALL_LEDS_OFF;
			}
		}
	}
	#else
    #if(DRIVE_LEDS)
	{
		/*Three positions are detected using two proximity sensors
		*	LED1, LED2 and LED3 are the LEDs on the X-axis from left to right
		*	LED5, LED2 and LED4 are the LEDs on the Y-axis from bottom to top
		*	When X-axis gestures are being detected LEDs drive conditions are given below
		*	Position1 - left sensor ON and right sensor OFF - LED1 turned ON
		*	Position2 - left sensor ON and right sensor ON - LED2 turned ON
		*	Position3 - left sensor OFF and right sensor ON - LED3 turned ON
		*	When Y-axis gestures are being detected LEDs drive conditions are given below
		*	Position1 - bottom sensor ON and top sensor OFF - LED5 turned ON
		*	Position2 - bottom sensor ON and top sensor ON - LED2 turned ON
		*	Position3 - bottom sensor OFF and top sensor ON - LED4 turned ON*/
		switch(currentZone)
		{
			case ZONE_ONE:
			{
				#if(GESTURE_AXIS)
				{
					LED1 = LED_ON;
				}
				#else
				{
					LED5 = LED_ON;
				}
				#endif
				break;
			}
			case ZONE_TWO:
			{
				LED2 = LED_ON;
				break;
			}
			case ZONE_THREE:
			{
				#if(GESTURE_AXIS)
				{
					LED3 = LED_ON;
				}
				
				#else
				{
					LED4 = LED_ON;
				}
				#endif
				break;
			}
			default:
			{
				LED1 = LED_OFF;
		 		LED2 = LED_OFF;
				LED3 = LED_OFF;
				LED4 = LED_OFF;
				LED5 = LED_OFF;
			}
		}
	}
    #endif 
	#endif
    
    #if(DRIVE_LEDS)
	/*Drive all the LEDs*/
	LED1_Write(LED1);
	LED2_Write(LED2);
	LED3_Write(LED3);
	LED4_Write(LED4);
	LED5_Write(LED5);
    #endif 
}