Exemplo n.º 1
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();
        }
    }
}
Exemplo n.º 2
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 );     
		}
	}		
}
Exemplo n.º 3
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();
	}
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
int main()
{
    uint16 Diff, FPS;
   
    CyGlobalIntEnable; /* Enable global interrupts. */

    PixelMask = 0;
    PixelCounter = 0;
    NoSpeed = 0;
    
    Timer_Start();
    Timer_ISR_StartEx(Timer_ISR);
    
    StripLights_Start();

    StripLights_Dim(0);
    StripLights_MemClear(0x00000000);
    StripLights_Trigger(1);

//    EZI2C_EzI2CSetBuffer1(sizeof(I2C_Struct.I2C_Buffer), sizeof(I2C_Struct.I2C_Buffer), I2C_Struct.I2C_Buffer);
//    EZI2C_Start();
    
    Diff = 60;
    
    for(;;)
    {
        //any Hall captures yet?
        if(Timer_Capture_Flag)
        {
            if(Timer_Capture > Timer_Capture_Last)
                Diff = Timer_Capture - Timer_Capture_Last;
            else
                Diff = (65535 - Timer_Capture_Last) + Timer_Capture;
            
            Timer_Capture_Flag = 0;
            StepColors();
            NoSpeed = 0;
        }
        //nope, maybe I stopped
        else
        {
            Timeout++;
        }
        //kill the lights if I'm standing still
        if(Timeout > 20000)
        {
            NoSpeed = 1;
            Timeout = 0;
        }
        
        FPS = FPS_SCALE/Diff;   //not using this but it could be fun later
        
//        I2C_Struct.I2C_Buffer[0] = (uint8)(Diff >>8);
//        I2C_Struct.I2C_Buffer[1] = (uint8)Diff;
//        I2C_Struct.I2C_Buffer[2] = (uint8)(FPS >>8);
//        I2C_Struct.I2C_Buffer[3] = (uint8)FPS;
//        if (!(EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY))
//        {
//            I2C_Struct.Capture = Diff;
//        }

        //OK, time to write out to the LEDs
        if(1 == NoSpeed)
            StripLights_MemClear(0x00000000);
        StripLights_Trigger(1);
        while(!StripLights_Ready());
    }
}