Example #1
0
        public static async Task Execute(IDasClient client)
        {
            Console.WriteLine();
            Console.WriteLine("This will transpose the top left 24x6 pixels of the image to the keyboard");
            Console.WriteLine("Pick an image: ");

            var imageFiles = Directory.GetFiles("images");

            for (int i = 0; i < imageFiles.Length; i++)
            {
                Console.WriteLine($"{i}. {Path.GetFileName(imageFiles[i])}");
            }

            int index;

            while (!int.TryParse(Console.ReadLine(), out index))
            {
                Console.WriteLine("Invalid selection - please choose an index");
            }

            if (index < 0 || index > imageFiles.Length - 1)
            {
                Console.WriteLine($"Invalid selection - please choose a number between 0 and {imageFiles.Length - 1}");
            }

            await LoadImage(client, Image.Load(imageFiles[index]));
        }
Example #2
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 #3
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 #4
0
        static async Task Main(string[] args)
        {
            //All the demos will use the local API
            _client = new LocalDasClient();

            Console.WriteLine("Local Das Client started, endpoint: " + _client.BaseUrl);

            while (!quit)
            {
                await PresentOptions();
            }
        }
Example #5
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);
        }
Example #6
0
        private static async Task LoadImage(IDasClient client, Image <Rgba32> image)
        {
            int xMax = image.Width > 24 ? 24 : image.Width;
            int yMax = image.Height > 6 ? 6 : image.Height;

            for (int x = 0; x < xMax; x++)
            {
                for (int y = 0; y < yMax; y++)
                {
                    var color = image[x, y];
                    if (color.A <= 200)
                    {
                        continue;
                    }

                    await client.SendSignal(new Signal("Image", (x, y), new Color(color.R, color.G, color.B)));
                }
            }
        }
Example #7
0
        public static async Task Execute(IDasClient client)
        {
            //A bunch of basic loops to iterate through the
            //keys on the border of the keyboard

            //Tilde to Backspace
            for (int i = 1; i <= 15; i++)
            {
                await SetLed(client, i, 1);
            }

            //Backspace to R-ctrl
            for (int i = 2; i <= 5; i++)
            {
                await SetLed(client, 15, i);
            }

            //R-ctrl to L-ctrl
            for (int i = 14; i >= 1; i--)
            {
                if (i == 10)
                {
                    i -= 5;
                }

                await SetLed(client, i, 5);
            }

            //L-ctrl to Tilde
            for (int i = 4; i >= 1; i--)
            {
                await SetLed(client, 1, i);
            }

            //Clean up after ourselves
            await client.DeleteSignals(_lastSignals);
        }