Example #1
0
// snake tail chaser
void Snake( uint16_t count )
{
	int i,x;        
    uint32 startColor;
     
	count = count ;
	
    startColor = StripLights_RED;

    for(x = StripLights_MIN_X+1; x <= StripLights_MAX_X; x++)
    {            
        
        if( x & 6)
	        for(i = StripLights_MIN_X; i <= StripLights_MAX_X; i++)
	        {            
	            uint32_t colour = StripLights_GetPixel(i, 0);
	            StripLights_Pixel(i, 0, colour/2);
	        }        
        
        StripLights_Pixel(x, 0, startColor);
        
        while( StripLights_Ready() == 0);
    	StripLights_Trigger(1);
        CyDelay( 15 );        

        if( x % 10 == 5 ) startColor+=0x010101;
        
        BOOT_CHECK();
    }
}
Example #2
0
void CandyCaneSmooth ( uint16_t count , led_color c1, led_color c2 )
{
    int i,x,percentage;
    uint8_t flip =0;
	uint32 t1,t2;
	
    // Candy cane
	if (0 ) {
		char buffer[256];
		sprintf(buffer,"c1 = %02x %02x %02x\n",c1.c.r,c1.c.g,c1.c.b);
		UART_UartPutString( buffer );
		sprintf(buffer,"c2 = %02x %02x %02x\n",c2.c.r,c2.c.g,c2.c.b);
		UART_UartPutString( buffer );
	}
	
			
	// loop effect for this many times
    for( i=0; i < count ; i++ )
    {   
		
		for( percentage = 0 ; percentage <= 100 ; percentage+=5 ) { 
			
			//  calculate target colours
			t1 = TweenC1toC2( c1, c2, percentage ) ;
			t2 = TweenC1toC2( c2, c1, percentage ) ;
						
	        // all strip, for every other led
	        for(x = StripLights_MIN_X; x <= StripLights_MAX_X; x+=2)
	        {
				// if flipped. draw c1,c2 otherwise c2,c1
	            if( flip ) {
	                StripLights_Pixel(x, 0, t1);
	                StripLights_Pixel(x+1, 0, t2);
	            } else {
	                StripLights_Pixel(x, 0, t2);
	                StripLights_Pixel(x+1, 0, t1);
	            }
	        }

			// toggle flip
	        flip = 1 - flip;
	        
			// wait and trigger
	        while( StripLights_Ready() == 0);
			StripLights_Trigger(1);
			
			
			// delay between transitions 
	       	CyDelay( 120 );        
			
	        BOOT_CHECK();
		}
    }   
}
Example #3
0
// quick helper function for testing hsv/rgb.
void StripLights_PixelHSV(int32 x,int32 y,hsv_color hsv )
{
	led_color rgb;
	
	rgb = hsv_to_rgb( hsv ) ;
	
	StripLights_Pixel( x,y,rgb.rgb);
}
Example #4
0
void SingleLEDPingPong( uint16_t count , uint8 fade_amount, uint32 color) 
{
	int i,x;
	
    for( i=0; i < count ; i++ )
    {   
    	for(x = StripLights_MIN_X; x <= StripLights_MAX_X; x++)
        {
			if(fade_amount ) {
				// Fade  strip	
				FadeStrip( StripLights_MIN_X, StripLights_MAX_X , fade_amount );
			} else { 
				StripLights_MemClear(0);
			}
		
            
            StripLights_Pixel(x, 0, color);
            
            while( StripLights_Ready() == 0);
	    	StripLights_Trigger(1);
            CyDelay( 5 );        
            BOOT_CHECK();
        }
        
        for(x = StripLights_MIN_X; x <= StripLights_MAX_X; x++)
        {
			if(fade_amount ) {
				// Fade  strip	
				FadeStrip( StripLights_MIN_X, StripLights_MAX_X , fade_amount );
			} else { 
				StripLights_MemClear(0);
			}
			
            StripLights_Pixel(StripLights_MAX_X-x, 0, color);
            
            while( StripLights_Ready() == 0);
	    	StripLights_Trigger(1);
			
            CyDelay( 5 );        
			
            BOOT_CHECK();
        }
    }
}
Example #5
0
void Sparkler ( uint16 runtime, int fade_amount , int num_sparkles ,char white ) 
{
    int x,j;
	led_color temp;

	// length of time to run
	for(x = 0; x <= runtime ; 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 < num_sparkles ;j++ ){
						
			temp.c.r = calculate_sparkle( j );
			
			if (white ) { 
				temp.c.g = temp.c.b = temp.c.r;
			} else {
				temp.c.g = calculate_sparkle( j );
				temp.c.b = calculate_sparkle( j );
			}
				
			// draw a pixel 
			StripLights_Pixel(rand()%StripLights_MAX_X, 0, temp.rgb );
		}
		
	    // strip ready?
		while( StripLights_Ready() == 0);
		
		//push current data to led strip
	    StripLights_Trigger(1);
	    CyDelay( 3 );     
	}
	
	if( fade_amount ) {
		// fade at end
		for(x = 0; x <= 200 ; x++)
		{
			// Fade  strip	
			FadeStrip( StripLights_MIN_X, StripLights_MAX_X , fade_amount );

			// strip ready?
			while( StripLights_Ready() == 0);

			//push current data to led strip
			StripLights_Trigger(1);
			CyDelay( 3 );     
		}
	}		
}
Example #6
0
/*
 * FadeLED - Tween one LED to a specified colour
 *
 */
void FadeLED( uint16 i, uint32 target, int percentage)
{
		led_color trgb;

		trgb.rgb = StripLights_GetPixel(i,0);
		
		trgb.rgb = TweenC1toC2( trgb, (led_color)target, percentage ) ;

		StripLights_Pixel( i, 0, trgb.rgb );
}
Example #7
0
/**
 * @brief Sets length LEDs to colour from
 *
 * @param from colour to use 
 * @param length number of LEDS to set
 *
 * @return none
 */
void StripLights_SetXToColour ( uint32 from, unsigned short length ) 
{
	int x;
	
	length = MIN(StripLights_MAX_X,length);
	
	 for(x = StripLights_MIN_X; x <= length ; x++) {
		StripLights_Pixel(x,0,from);
	}
	
	StripLights_Trigger(1);
	
}
Example #8
0
void Twinkle( uint16_t count ) 
{
        int i,x;
        led_color col;
        uint32 startColor;
        startColor = StripLights_WHITE;
            
        
        for(x = 0; x <= count; x++)
        {            

			col.c.r = rand();
			col.c.g = rand();
			col.c.b = rand();

			startColor = col.rgb;
                       
			StripLights_Pixel(rand()%StripLights_MAX_X, 0, startColor);
			
            for(i = StripLights_MIN_X; i <= StripLights_MAX_X; i++)
            {            
                col.rgb = StripLights_GetPixel(i, 0);
                
                if ( col.c.r > 0 ) col.c.r -= col.c.r/2; 
                if ( col.c.g > 0 ) col.c.g -= col.c.g/2; 
                if ( col.c.b > 0 ) col.c.b -= col.c.b/2; 
                
                StripLights_Pixel(i, 0, col.rgb );
            }        
      
            while( StripLights_Ready() == 0);
	    	StripLights_Trigger(1);
            CyDelay( 15 );        
            
            BOOT_CHECK();
        }
        
}
Example #9
0
void CandyCane ( uint16_t count , uint32 c1, uint32 c2 )
{
    int i,x;
    uint8_t flip =0;
	
    // Candy cane
	
	// loop effect for this many times
    for( i=0; i < count ; i++ )
    {   
		
        // all strip, for every other led
        for(x = StripLights_MIN_X; x <= StripLights_MAX_X; x+=2)
        {
			// if flipped. draw c1,c2 otherwise c2,c1
            if( flip ) {
                StripLights_Pixel(x, 0, c1);
                StripLights_Pixel(x+1, 0, c2);
            } else {
                StripLights_Pixel(x+1, 0, c1);
                StripLights_Pixel(x, 0, c2);
            }
        }

		// toggle flip
        flip = 1 - flip;
        
		// wait and trigger
        while( StripLights_Ready() == 0);
		StripLights_Trigger(1);
		
		// delay between transitions 
       	CyDelay( 100 );        
		
        BOOT_CHECK();
    }   
}
Example #10
0
void FadeStrip(  uint16 start, int16 length ,int percentage )
{
	led_color trgb;
	int i;
	
    for(i = start; i <= start+length; i++) {
    
		// get pixel
		trgb.rgb = StripLights_GetPixel(i,0);
		
		trgb.rgb = TweenC1toC2( trgb,(led_color) StripLights_BLACK, percentage ) ;

		StripLights_Pixel( i, 0, trgb.rgb );
	}
}
Example #11
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();
	}
}
Example #12
0
void ColorWheel( uint16_t count )
{
	static int i =0xAAA ,x;
	static uint32 color;
	static uint32 startColor ;   

    
	if (i >= count ) {
		i = 0;
	}
	
	if ( i == 0xaaa ) {
		i = 0;
		color = 0;
		startColor = 0;
	}
	
    for( ; i < count ; i++ )
    {   
        color = startColor;
        for(x = StripLights_MIN_X; x <= StripLights_MAX_X; x++)
        {
            StripLights_Pixel(x, 0, getColor( color ));

        	 color++;
            
			if(color >= StripLights_COLOR_WHEEL_SIZE) color = 0;
       	}
		
		startColor++;
    
		if(startColor >= StripLights_COLOR_WHEEL_SIZE) startColor = 0;
    
       while( StripLights_Ready() == 0);
    
		StripLights_Trigger(1);
	
       CyDelay( 50 );

        BOOT_CHECK();
    }
}
Example #13
0
//yay, new input!  Step the colors
void StepColors(void){
    //PixelCounter is used as the main index into the strip's pixel array
    //PixelMask is there because this particular installation is "reversed"
    //so we need to start the motion from the far end of the strip
    if(PixelCounter < 27)
        PixelCounter++;
    else PixelCounter = 0;
    PixelMask = 27-PixelCounter;

    StripLights_MemClear(0x00000000);
    
    StripLights_Pixel(PixelMask   ,0,PURPLE);
    StripLights_Pixel(PixelMask -1,0,VIOLET);
    StripLights_Pixel(PixelMask -2,0,BLUE);
    StripLights_Pixel(PixelMask -3,1,YELLOW);
    StripLights_Pixel(PixelMask -4,1,ORANGE);
    StripLights_Pixel(PixelMask -5,1,RED);
}