예제 #1
0
        private async void Stars(int delay, int starCount, int brightness)
        {
            Fadecandy.LoadVideoRandomWhite((byte)(brightness - 20), (byte)(brightness + 20));
            await SendVideoArray();

            int currentLED = 0;

            Random rndLocation = new Random(DateTime.Now.Millisecond);

            for (int c = 0; c < 200; c++)
            {
                // How many pixels to change at once
                for (int l = 0; l < starCount; l++)
                {
                    int col = rndLocation.Next(0, 8);
                    int row = rndLocation.Next(0, 8);

                    currentLED = Fadecandy.LED8x8Map[0, col, row];
                    byte rndBrightness = (byte)rndLocation.Next(brightness - 20, brightness + 20);
                    Fadecandy.VideoArray[currentLED]     = rndBrightness;
                    Fadecandy.VideoArray[currentLED + 1] = rndBrightness;
                    Fadecandy.VideoArray[currentLED + 2] = rndBrightness;
                }

                await SendVideoArray();

                await Task.Delay(delay);
            }
        }
예제 #2
0
        private async void Flash(int delay, int frames, int flashCount, byte brightness)
        {
            Fadecandy.LoadVideoBlank();
            await SendVideoArray();

            int currentLED = 0;

            Random rndLocation = new Random(DateTime.Now.Millisecond);

            for (int f = 0; f < frames; f++)
            {
                for (int c = 0; c < flashCount; c++)
                {
                    int col = rndLocation.Next(0, 8);
                    int row = rndLocation.Next(0, 8);

                    currentLED = Fadecandy.LED8x8Map[0, col, row];
                    Fadecandy.VideoArray[currentLED]     = brightness;
                    Fadecandy.VideoArray[currentLED + 1] = brightness;
                    Fadecandy.VideoArray[currentLED + 2] = brightness;
                }
                await SendVideoArray();

                Fadecandy.LoadVideoBlank();
                await Task.Delay(delay);
            }
        }
예제 #3
0
        private async void AlienSignal(int delay, int density, byte brightness)
        {
            Fadecandy.LoadVideoBlank();
            await SendVideoArray();

            int    currentLED = 0;
            int    color      = 0;
            Random rnd        = new Random(DateTime.Now.Millisecond);

            for (int t = 0; t < 50; t++)
            {
                for (int c = 0; c < 8; c++)
                {
                    for (int r = 0; r < 8; r++)
                    {
                        currentLED = Fadecandy.LED8x8Map[0, c, r];
                        Fadecandy.VideoArray[currentLED]     = 0x00;
                        Fadecandy.VideoArray[currentLED + 1] = 0x00;
                        Fadecandy.VideoArray[currentLED + 2] = 0x00;

                        // Sets the color by populating just one of the RGBs
                        if ((byte)rnd.Next(0, 100) < density)
                        {
                            Fadecandy.VideoArray[currentLED + color] = brightness;
                        }
                    }
                }

                if (color > 1)
                {
                    color = 0;
                }
                else
                {
                    color++;
                }

                await SendVideoArray();

                await Task.Delay(delay);
            }
        }
예제 #4
0
        private async void ButtonRandomFlashTrailing_Click(object sender, RoutedEventArgs e)
        {
            AddMessage("Random Flash Trailing Pressed", null);

            Fadecandy.LoadVideoBlank();
            await SendVideoArray();

            int         currentLED = 0;
            Queue <int> leds       = new Queue <int>();

            int density = Convert.ToInt16(txtCountFlashTrail.Text);

            for (int c = 0; c < density; c++)
            {
                leds.Enqueue(0);
            }

            Random rndLocation = new Random(DateTime.Now.Millisecond);

            for (int c = 0; c < 200; c++)
            {
                int lastLED = leds.Dequeue();
                Fadecandy.VideoArray[lastLED]     = 0x00;
                Fadecandy.VideoArray[lastLED + 1] = 0x00;
                Fadecandy.VideoArray[lastLED + 2] = 0x00;

                int col = rndLocation.Next(0, 8);
                int row = rndLocation.Next(0, 8);

                currentLED = Fadecandy.LED8x8Map[0, col, row];
                Fadecandy.VideoArray[currentLED]     = 0x30;
                Fadecandy.VideoArray[currentLED + 1] = 0x30;
                Fadecandy.VideoArray[currentLED + 2] = 0x30;
                await SendVideoArray();

                await Task.Delay(Convert.ToInt16(txtDelayFlashTrail.Text));

                leds.Enqueue(currentLED);
            }
        }
예제 #5
0
        private async void FillDown(int delay, byte brightness)
        {
            Fadecandy.LoadVideoBlank();
            await SendVideoArray();

            int    currentLED  = 0;
            Random rndLocation = new Random(DateTime.Now.Millisecond);

            for (int c = 0; c < 8; c++)
            {
                for (int r = 0; r < 8; r++)
                {
                    currentLED = Fadecandy.LED8x8Map[0, c, r];
                    Fadecandy.VideoArray[currentLED]     = brightness;
                    Fadecandy.VideoArray[currentLED + 1] = brightness;
                    Fadecandy.VideoArray[currentLED + 2] = brightness;
                    await SendVideoArray();

                    await Task.Delay(delay);
                }
            }
        }
예제 #6
0
        private async void ButtonRandomSnake_Click(object sender, RoutedEventArgs e)
        {
            AddMessage("Random Flash Trailing Pressed", null);

            Fadecandy.LoadVideoBlank();
            await SendVideoArray();

            int         currentLED = 0;
            Queue <int> leds       = new Queue <int>();

            int length = Convert.ToInt16(txtCountSnake.Text);

            for (int c = 0; c < length; c++)
            {
                leds.Enqueue(0);
            }

            Random rndLocation = new Random(DateTime.Now.Millisecond);
            int    col         = rndLocation.Next(0, 8);
            int    row         = rndLocation.Next(0, 8);

            for (int c = 0; c < 100; c++)
            {
                if (rndLocation.Next(0, 50) > 25)
                {
                    if (rndLocation.Next(0, 50) > 25)
                    {
                        col++;
                        if (col > 7 || col < 0)
                        {
                            col--;
                        }
                    }
                    else
                    {
                        col--;
                        if (col > 7 || col < 0)
                        {
                            col++;
                        }
                    }
                }
                else
                {
                    if (rndLocation.Next(0, 50) > 25)
                    {
                        row++;
                        if (row > 7 || row < 0)
                        {
                            row--;
                        }
                    }
                    else
                    {
                        row--;
                        if (row > 7 || row < 0)
                        {
                            row++;
                        }
                    }
                }

                int lastLED = leds.Dequeue();
                Fadecandy.VideoArray[lastLED + 1] = 0x00;
                Fadecandy.VideoArray[lastLED + 2] = 0x00;

                currentLED = Fadecandy.LED8x8Map[0, col, row];
                leds.Enqueue(currentLED);

                List <int> turnAllOn = leds.ToList();
                foreach (int x in turnAllOn)
                {
                    Fadecandy.VideoArray[x + 1] = 0x00;
                    Fadecandy.VideoArray[x + 2] = 0x30;
                }

                Fadecandy.VideoArray[currentLED + 1] = 0x30;
                Fadecandy.VideoArray[currentLED + 2] = 0x00;

                await SendVideoArray();

                await Task.Delay(Convert.ToInt16(txtDelaySnake.Text));
            }
        }