Example #1
0
        public static async Task Execute(IDasClient client)
        {
            Console.WriteLine("Rainbow time!");

            List <int> sentSignalIds = new List <int>();

            //From the F1 key to the F12 key
            for (int i = 3; i <= 15; i++)
            {
                //Double up the index since we only have enough colors
                //for half the keys
                int colorIndex = (i - 3) / 2;

                var signal = new Signal("Rainbow!", (i, 0), _colors[colorIndex]);
                var sent   = await client.SendSignal(signal);

                sentSignalIds.Add(sent.Id);
            }

            Console.WriteLine("Rainbow sent! Push enter to clear");
            Console.ReadLine();

            foreach (var id in sentSignalIds)
            {
                await client.DeleteSignal(id);
            }
        }
Example #2
0
        public static async Task Execute(IDasClient client)
        {
            ConsoleKey key = ConsoleKey.A;

            Console.WriteLine("Type keys in the console window and watch them glow!");
            Console.WriteLine("Hit escape to quit");

            while (key != ConsoleKey.Escape)
            {
                var input = Console.ReadKey();
                key = input.Key;

                if (key == ConsoleKey.Escape)
                {
                    continue;
                }

                char inputChar = Char.ToUpper(input.KeyChar);
                var  signal    = new Signal("Hotspot", "KEY_" + inputChar, new Color(255, 0, 0));

                var result = await client.SendSignal(signal);

                await Task.Delay(1000);

                await client.DeleteSignal(result.Id);
            }
        }
Example #3
0
        private static async Task SetLed(IDasClient client, int x, int y)
        {
            //Keep a "trail" of 2 keys
            if (_lastSignals.Count > 2)
            {
                await client.DeleteSignal(_lastSignals.Dequeue());
            }

            var signal = new Signal("Snake", (x, y), new Color("#F00"));

            _lastSignals.Enqueue((await client.SendSignal(signal)).Id);

            //We need a slight delay, because the built-in transition
            //animations on signals is too slow
            await Task.Delay(600);
        }