Example #1
0
        public void Start()
        {
            _trackIrClient.TrackIR_Enhanced_Init();

            Task.Run(() =>
            {
                while (true)
                {
                    Text = _trackIrClient.client_TestTrackIRData();
                }
            });
        }
Example #2
0
        public MainWindowViewModel()
        {
            _client = new TrackIrClient();

            _client.TrackIR_Enhanced_Init();
        }
Example #3
0
        static void Main(string[] args)
        {
            List <Point> keyboardPoints = new List <Point>();

            TrackIrClient client = new TrackIrClient();

            client.TrackIR_Enhanced_Init();

            bool looking = false;

            Console.WriteLine($"Init is: {LogitechGSDK.LogiLedInit()}");
            LogitechGSDK.LogiLedSaveCurrentLighting();

            while (true)
            {
                var output = client.client_HandleTrackIRData();

                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey().Key;

                    switch (key)
                    {
                    case ConsoleKey.N:
                        if (keyboardPoints.Count > 1)
                        {
                            Console.WriteLine("2 points added");
                            break;
                        }

                        Console.WriteLine($"Point added: [{output.fNPPitch}, {output.fNPYaw}]");
                        keyboardPoints.Add(new Point
                        {
                            Pitch = output.fNPPitch,
                            Yaw   = output.fNPYaw
                        });
                        break;

                    case ConsoleKey.Q:
                        client.TrackIR_Shutdown();
                        LogitechGSDK.LogiLedShutdown();
                        return;
                    }
                }

                if (keyboardPoints.Count > 1)
                {
                    var topLeft     = keyboardPoints[0];
                    var bottomRight = keyboardPoints[1];

                    var pitch = output.fNPPitch;
                    var yaw   = output.fNPYaw;

                    if (pitch > topLeft.Pitch && pitch < bottomRight.Pitch &&
                        yaw > bottomRight.Yaw && yaw < topLeft.Yaw)
                    {
                        Console.WriteLine("Looking at keyboard");

                        if (!looking)
                        {
                            Console.WriteLine($"Turning kb on: {LogitechGSDK.LogiLedSetLighting(1, 1, 1)}");
                            //Console.WriteLine($"Restoring: {LogitechController.LogiLedRestoreLighting()}");

                            looking = true;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not looking at keyboard");

                        if (looking)
                        {
                            Console.WriteLine($"Turning kb off: {LogitechGSDK.LogiLedSetLighting(0, 0, 0)}");
                            //Console.WriteLine($"Saving color: {LogitechController.LogiLedSaveCurrentLighting()} | Turning kb off: {LogitechController.LogiLedSetLighting(0, 0, 0)}");

                            looking = false;
                        }
                    }
                }

                Thread.Sleep(100);
            }
        }