pattern.c
void vLaser( const uint32_t ulPatternCount )
{
    static int16_t sLaserStartLed = 0;
    static uint8_t ucColorIndex = 0;
    static uint8_t usIncrement = 1;

    /* Set colors for the wave pattern. */
    static uint8_t ucColors[ configLASER_NUM_COLORS ][ COLOR_CHANNELS ] = {
        configLASER_COLORS
    };


    if ( ulPatternCount == 0 )
    {
        sLaserStartLed = -configLASER_LENGTH;
        ucColorIndex = ulGetRandVal() % configLASER_NUM_COLORS;
        usIncrement = 0;
    }

    vFillStrip( 0, 0, 0 );

    for ( uint16_t i = 0; i < configLASER_LENGTH; i++ )
    {
        uint8_t sIntensity = ( ( i + 1 ) * 255 ) / configLASER_LENGTH;

        uint8_t R = ucColors[ucColorIndex][0] * sIntensity / 255;
        uint8_t G = ucColors[ucColorIndex][1] * sIntensity / 255;
        uint8_t B = ucColors[ucColorIndex][2] * sIntensity / 255;

        vSetLed( sLaserStartLed + i, R, G, B );
    }

    sLaserStartLed += usIncrement;

    if ( sLaserStartLed % configLASER_INCREMENT_DELAY == 0 )
    {
        usIncrement++;
    }

    /* If the laser goes off the end of the strip. */
    if ( sLaserStartLed > NUMBER_OF_LEDS + configLASER_LENGTH )
    {
        sLaserStartLed = -configLASER_LENGTH;
        usIncrement = 0;
        ucColorIndex = ulGetRandVal() % configLASER_NUM_COLORS;
    }
}
/**
  * @brief  Create wave pattern across LED strip.
  * @retval None
  */
@brief  Create wave pattern across LED strip.
@retval None
@brief Create wave pattern across LED strip . @retval None
void vLaser( const uint32_t ulPatternCount )
{
    static int16_t sLaserStartLed = 0;
    static uint8_t ucColorIndex = 0;
    static uint8_t usIncrement = 1;
    static uint8_t ucColors[ configLASER_NUM_COLORS ][ COLOR_CHANNELS ] = {
        configLASER_COLORS
    };
    if ( ulPatternCount == 0 )
    {
        sLaserStartLed = -configLASER_LENGTH;
        ucColorIndex = ulGetRandVal() % configLASER_NUM_COLORS;
        usIncrement = 0;
    }
    vFillStrip( 0, 0, 0 );
    for ( uint16_t i = 0; i < configLASER_LENGTH; i++ )
    {
        uint8_t sIntensity = ( ( i + 1 ) * 255 ) / configLASER_LENGTH;
        uint8_t R = ucColors[ucColorIndex][0] * sIntensity / 255;
        uint8_t G = ucColors[ucColorIndex][1] * sIntensity / 255;
        uint8_t B = ucColors[ucColorIndex][2] * sIntensity / 255;
        vSetLed( sLaserStartLed + i, R, G, B );
    }
    sLaserStartLed += usIncrement;
    if ( sLaserStartLed % configLASER_INCREMENT_DELAY == 0 )
    {
        usIncrement++;
    }
    if ( sLaserStartLed > NUMBER_OF_LEDS + configLASER_LENGTH )
    {
        sLaserStartLed = -configLASER_LENGTH;
        usIncrement = 0;
        ucColorIndex = ulGetRandVal() % configLASER_NUM_COLORS;
    }
}
void vLaser ( const uint32_t ulPatternCount ) { static int16_t sLaserStartLed = 0 ; static uint8_t ucColorIndex = 0 ; static uint8_t usIncrement = 1 ; static uint8_t ucColors [ configLASER_NUM_COLORS ] [ COLOR_CHANNELS ] = { configLASER_COLORS } ; if ( ulPatternCount == 0 ) { sLaserStartLed = - configLASER_LENGTH ; ucColorIndex = ulGetRandVal ( ) % configLASER_NUM_COLORS ; usIncrement = 0 ; } vFillStrip ( 0 , 0 , 0 ) ; for ( uint16_t i = 0 ; i < configLASER_LENGTH ; i ++ ) { uint8_t sIntensity = ( ( i + 1 ) * 255 ) / configLASER_LENGTH ; uint8_t R = ucColors [ ucColorIndex ] [ 0 ] * sIntensity / 255 ; uint8_t G = ucColors [ ucColorIndex ] [ 1 ] * sIntensity / 255 ; uint8_t B = ucColors [ ucColorIndex ] [ 2 ] * sIntensity / 255 ; vSetLed ( sLaserStartLed + i , R , G , B ) ; } sLaserStartLed += usIncrement ; if ( sLaserStartLed % configLASER_INCREMENT_DELAY == 0 ) { usIncrement ++ ; } if ( sLaserStartLed > NUMBER_OF_LEDS + configLASER_LENGTH ) { sLaserStartLed = - configLASER_LENGTH ; usIncrement = 0 ; ucColorIndex = ulGetRandVal ( ) % configLASER_NUM_COLORS ; } }
@brief  Create wave pattern across LED strip.
@brief Create wave pattern across LED strip .
/* Set colors for the wave pattern. */ /* If the laser goes off the end of the strip. */