Example #1
0
int main()
{
    
	uint8 counter = 0;	
	
	/* Enable global interrupts*/
	CyGlobalIntEnable;
	
	/* Check if the switch is pressed during power up */ 
	if(Boot_P0_7_Read() == 0)
	{
		
		for(counter = 0; counter <= SWITCH_PRESS_TIMEOUT; counter++)
		{
			/* Delay for 1ms */
			//CyDelay(1);
			CyDelay(2);
				
			/* If the switch is released before specified time, do not enter the 
			 * bootloader */
			if(Boot_P0_7_Read() != 0)
				break;
		}
						 
		if(counter > SWITCH_PRESS_TIMEOUT)
		{
			/* If the switch was pressed for more than 100 millisecond counter 
			 * value will be 100. If so, set the flash run type as bootloader to 
			 * wait for a bootload operation */
			Bootloader_SET_RUN_TYPE (Bootloader_START_BTLDR);
		}
	}
		
	/*Indicate that you have entered the bootloader mode.*/
	PWM_Start();
	
	/* Start the Bootloader */
	Bootloader_Start();
	/* The “Bootloader_Start()” API will either wait for a bootload operation or 
	 * will launch the application depending on whether or not the API
	 * "Bootloader_SET_RUN_TYPE(Bootloader_START_BTLDR)" was called because of the 
	 * switch being pressed during power up */
			
    for(;;)
    {
        
    }
}
Example #2
0
void Icicle (uint8 redraw, uint8 length, int fade_amount )           
 {
    int x,j,i;
	led_color temp;

	// for entire length of strip, plus engough to move it off the display)
	for(x = StripLights_MIN_X; x <= StripLights_MAX_X + ( length * 2 ); x++)
	{
		
		if(fade_amount ) {
			// Fade  strip	
			FadeStrip( StripLights_MIN_X, StripLights_MAX_X , fade_amount );
		} else { 
			StripLights_MemClear(0);
		}
		
		
		// draw in same place 8 times
		for ( j = 0 ; j < redraw ;j++ ){
			
			// length of icicle
			for(i=0; i < length; i++)
			{
				// caculate a randow twink based on current position in length
				temp.c.r =
				temp.c.g =
				temp.c.b = calculate_sparkle( i  );

				// draw a pixel at x+i
			    StripLights_Pixel(x+i, 0, temp.rgb );
				
				CyDelay( 1 );  
		 	}    
			    
		    // strip ready?
			while( StripLights_Ready() == 0);
			
			//push current data to led strip
		    StripLights_Trigger(1);
		    CyDelay( 3 );        
		}
		
		// check if firmware load requested
	    if( Boot_P0_7_Read ( ) == 0 )   CySoftwareReset();
	}
}