pattern.c
void vAuroraBorealis( const uint32_t ulPatternCount )
{
    /* Number of aurora's simultaneously show. */
    static int16_t sAuroraArray[configAURORA_BOREALIS_LENGTH];

    /* Aurora color.*/
    static uint16_t usAuroraColors[configAURORA_BOREALIS_LENGTH];

    uint16_t usWidth = 20;
    uint16_t usColorOffset = 20;
    uint16_t usColorRange = 300;

    /* Initial run. */
    if ( ulPatternCount == 0 )
    {
        for ( uint16_t i = 0; i < configAURORA_BOREALIS_LENGTH; i++ )
        {
            /* Pick aurora LEDs. Biased to the end of the strip because this is
            the last LED in the aurora. */
            sAuroraArray[i] = ( ulGetRandVal() % (2 * NUMBER_OF_LEDS) ) - (NUMBER_OF_LEDS / 4);

            /* Get some random colors. */
            usAuroraColors[i] = ulGetRandVal() % usColorRange;
        }
    }

    if ( ulPatternCount % configAURORA_BOREALIS_DELAY_MS == 0 )
    {
        vFillStrip( 0, 0, 63 );

        for ( uint16_t i = 0; i < configAURORA_BOREALIS_LENGTH; i++ )
        {
            /* Blend LED colors (Green/Blue) via cosine function. */
            /* LEDs in the center are brighter than the edges. */

            /* These LEDs get brighter towards the end of the strip. */
            vCrossfade(sAuroraArray[i] - 2 * usWidth, usWidth, 1,
                       0,                                                           // R
                       ucGetCos( usAuroraColors[i] + usColorOffset ),               // G
                       ucGetCos( usAuroraColors[i] + 120 + usColorOffset ) / 2 );   // B

            /* These LEDs get dimmer towards the end of the strip. */
            vCrossfade(sAuroraArray[i] - usWidth, usWidth, 0,
                       0,                                                           // R
                       ucGetCos( usAuroraColors[i] + usColorOffset ),               // G
                       ucGetCos( usAuroraColors[i] + 120 + usColorOffset ) / 2 );   // B

            if ( i < ( configAURORA_BOREALIS_LENGTH / 2 ) )
            {
                /* Move the aurora LED towards the end of the LED strip. */
                sAuroraArray[i]++;

                /* If we increment off end of the LED strip. */
                if ( sAuroraArray[i] > ( NUMBER_OF_LEDS + 2 * usWidth ) )
                {
                    /* We know this aurora will work it's way towards the end of
                    the strip so bias the selection towards the start of the LED
                    strip. Pick a new aurora start LED in the first 33%.*/
                    sAuroraArray[i] = ulGetRandVal() % ( NUMBER_OF_LEDS / 3 ) - usWidth;
                    usAuroraColors[i] = ulGetRandVal() % usColorRange;
                }
            }
            else
            {
                /* Move the aurora LED towards the start of the LED strip. */
                sAuroraArray[i]--;

                /* If we decrement off the beginning of the LED strip. */
                if ( sAuroraArray[i] < 0 )
                {
                    /* We know this aurora will work it's way towards the start
                    of the strip so bias the selection towards the end of the LED
                    strip. Pick a new aurora start LED in the last 33%.*/
                    sAuroraArray[i] = ulGetRandVal() % ( NUMBER_OF_LEDS / 3 ) +
                                        ( 2 * NUMBER_OF_LEDS / 3 ) + usWidth;
                    usAuroraColors[i] = ulGetRandVal() % usColorRange;
                }
            }
        }
    }
}
/**
  * @brief  Simulate the Aurora Borealis.
  * @retval None
  */
@brief  Simulate the Aurora Borealis.
@retval None
@brief Simulate the Aurora Borealis . @retval None
void vAuroraBorealis( const uint32_t ulPatternCount )
{
    static int16_t sAuroraArray[configAURORA_BOREALIS_LENGTH];
    static uint16_t usAuroraColors[configAURORA_BOREALIS_LENGTH];
    uint16_t usWidth = 20;
    uint16_t usColorOffset = 20;
    uint16_t usColorRange = 300;
    if ( ulPatternCount == 0 )
    {
        for ( uint16_t i = 0; i < configAURORA_BOREALIS_LENGTH; i++ )
        {
            sAuroraArray[i] = ( ulGetRandVal() % (2 * NUMBER_OF_LEDS) ) - (NUMBER_OF_LEDS / 4);
            usAuroraColors[i] = ulGetRandVal() % usColorRange;
        }
    }
    if ( ulPatternCount % configAURORA_BOREALIS_DELAY_MS == 0 )
    {
        vFillStrip( 0, 0, 63 );
        for ( uint16_t i = 0; i < configAURORA_BOREALIS_LENGTH; i++ )
        {
            vCrossfade(sAuroraArray[i] - 2 * usWidth, usWidth, 1,
                       0,                                                           
                       ucGetCos( usAuroraColors[i] + usColorOffset ),               
                       ucGetCos( usAuroraColors[i] + 120 + usColorOffset ) / 2 );   
            vCrossfade(sAuroraArray[i] - usWidth, usWidth, 0,
                       0,                                                           
                       ucGetCos( usAuroraColors[i] + usColorOffset ),               
                       ucGetCos( usAuroraColors[i] + 120 + usColorOffset ) / 2 );   
            if ( i < ( configAURORA_BOREALIS_LENGTH / 2 ) )
            {
                sAuroraArray[i]++;
                if ( sAuroraArray[i] > ( NUMBER_OF_LEDS + 2 * usWidth ) )
                {
                    sAuroraArray[i] = ulGetRandVal() % ( NUMBER_OF_LEDS / 3 ) - usWidth;
                    usAuroraColors[i] = ulGetRandVal() % usColorRange;
                }
            }
            else
            {
                sAuroraArray[i]--;
                if ( sAuroraArray[i] < 0 )
                {
                    sAuroraArray[i] = ulGetRandVal() % ( NUMBER_OF_LEDS / 3 ) +
                                        ( 2 * NUMBER_OF_LEDS / 3 ) + usWidth;
                    usAuroraColors[i] = ulGetRandVal() % usColorRange;
                }
            }
        }
    }
}
void vAuroraBorealis ( const uint32_t ulPatternCount ) { static int16_t sAuroraArray [ configAURORA_BOREALIS_LENGTH ] ; static uint16_t usAuroraColors [ configAURORA_BOREALIS_LENGTH ] ; uint16_t usWidth = 20 ; uint16_t usColorOffset = 20 ; uint16_t usColorRange = 300 ; if ( ulPatternCount == 0 ) { for ( uint16_t i = 0 ; i < configAURORA_BOREALIS_LENGTH ; i ++ ) { sAuroraArray [ i ] = ( ulGetRandVal ( ) % ( 2 * NUMBER_OF_LEDS ) ) - ( NUMBER_OF_LEDS / 4 ) ; usAuroraColors [ i ] = ulGetRandVal ( ) % usColorRange ; } } if ( ulPatternCount % configAURORA_BOREALIS_DELAY_MS == 0 ) { vFillStrip ( 0 , 0 , 63 ) ; for ( uint16_t i = 0 ; i < configAURORA_BOREALIS_LENGTH ; i ++ ) { vCrossfade ( sAuroraArray [ i ] - 2 * usWidth , usWidth , 1 , 0 , ucGetCos ( usAuroraColors [ i ] + usColorOffset ) , ucGetCos ( usAuroraColors [ i ] + 120 + usColorOffset ) / 2 ) ; vCrossfade ( sAuroraArray [ i ] - usWidth , usWidth , 0 , 0 , ucGetCos ( usAuroraColors [ i ] + usColorOffset ) , ucGetCos ( usAuroraColors [ i ] + 120 + usColorOffset ) / 2 ) ; if ( i < ( configAURORA_BOREALIS_LENGTH / 2 ) ) { sAuroraArray [ i ] ++ ; if ( sAuroraArray [ i ] > ( NUMBER_OF_LEDS + 2 * usWidth ) ) { sAuroraArray [ i ] = ulGetRandVal ( ) % ( NUMBER_OF_LEDS / 3 ) - usWidth ; usAuroraColors [ i ] = ulGetRandVal ( ) % usColorRange ; } } else { sAuroraArray [ i ] -- ; if ( sAuroraArray [ i ] < 0 ) { sAuroraArray [ i ] = ulGetRandVal ( ) % ( NUMBER_OF_LEDS / 3 ) + ( 2 * NUMBER_OF_LEDS / 3 ) + usWidth ; usAuroraColors [ i ] = ulGetRandVal ( ) % usColorRange ; } } } } }
@brief  Simulate the Aurora Borealis.
@brief Simulate the Aurora Borealis .
/* Number of aurora's simultaneously show. */ /* Aurora color.*/ /* Initial run. */ /* Pick aurora LEDs. Biased to the end of the strip because this is
            the last LED in the aurora. */ /* Get some random colors. */ /* Blend LED colors (Green/Blue) via cosine function. */ /* LEDs in the center are brighter than the edges. */ /* These LEDs get brighter towards the end of the strip. */ // R // G // B /* These LEDs get dimmer towards the end of the strip. */ // R // G // B /* Move the aurora LED towards the end of the LED strip. */ /* If we increment off end of the LED strip. */ /* We know this aurora will work it's way towards the end of
                    the strip so bias the selection towards the start of the LED
                    strip. Pick a new aurora start LED in the first 33%.*/ /* Move the aurora LED towards the start of the LED strip. */ /* If we decrement off the beginning of the LED strip. */ /* We know this aurora will work it's way towards the start
                    of the strip so bias the selection towards the end of the LED
                    strip. Pick a new aurora start LED in the last 33%.*/