示例#1
0
        void JoystickUpdated(object sender, IChangeResult <JoystickPosition> e)
        {
            if (e.New.Horizontal < 0.2f)
            {
                Left.SetBrightness(0f);
                Right.SetBrightness(0f);
            }
            if (e.New.Vertical < 0.2f)
            {
                Up.SetBrightness(0f);
                Down.SetBrightness(0f);
            }

            if (e.New.Horizontal > 0)
            {
                Left.SetBrightness(e.New.Horizontal.Value);
            }
            else
            {
                Right.SetBrightness(Math.Abs(e.New.Horizontal.Value));
            }

            if (e.New.Vertical > 0)
            {
                Down.SetBrightness(Math.Abs(e.New.Vertical.Value));
            }
            else
            {
                Up.SetBrightness(Math.Abs(e.New.Vertical.Value));
            }

            Console.WriteLine($"({e.New.Horizontal.Value}, {e.New.Vertical.Value})");
        }
示例#2
0
        private void OnTouched()
        {
            count++;
            PlayBuzzer();

            new Thread(() =>
            {
                for (int i = 0; i < 4; i++)
                {
                    redLed.SetBrightness(0.8f);
                    Thread.Sleep(25);
                    redLed.SetBrightness(0);
                    Thread.Sleep(25);
                }
            }).Start();

            UpdateDisplay();
        }
示例#3
0
 public void BrightnessTest(int loopCount)
 {
     for (int i = 0; i < loopCount; i++)
     {
         Console.WriteLine("Blue On @ 1.0");
         _bluePwmLed.SetBrightness(1);
         Thread.Sleep(1000);
         Console.WriteLine("Blue at 98.5%");
         _bluePwmLed.SetBrightness(0.985f);
         Thread.Sleep(1000);
         Console.WriteLine("Blue Off");
         _bluePwmLed.SetBrightness(0);
         Thread.Sleep(1000);
         Console.WriteLine("Blue 50%");
         _bluePwmLed.SetBrightness(0.5f);
         Thread.Sleep(1000);
         _bluePwmLed.Stop();
     }
 }
示例#4
0
        void TestPwmLed()
        {
            Console.WriteLine("TestPwmLed...");

            while (true)
            {
                Console.WriteLine("Turning on and off each led for one second");
                pwmLed.IsOn = true;
                Thread.Sleep(500);
                pwmLed.IsOn = false;

                Console.WriteLine("Blinking the LED for three seconds...");
                pwmLed.StartBlink();
                Thread.Sleep(3000);
                pwmLed.Stop();

                Console.WriteLine("Pulsing the LED for three seconds...");
                pwmLed.StartPulse();
                Thread.Sleep(3000);
                pwmLed.Stop();

                Console.WriteLine("Increasing and decreasing brightness...");
                for (int j = 0; j <= 3; j++)
                {
                    for (int i = 0; i <= 10; i++)
                    {
                        pwmLed.SetBrightness(i * 0.10f);
                        Thread.Sleep(100);
                    }

                    for (int i = 10; i >= 0; i--)
                    {
                        pwmLed.SetBrightness(i * 0.10f);
                        Thread.Sleep(100);
                    }
                }
            }
        }
        void TestCar()
        {
            while (true)
            {
                up.SetBrightness(0.1f);
                carController.MoveForward();
                Thread.Sleep(1000);
                up.SetBrightness(0.0f);

                carController.Stop();
                Thread.Sleep(500);

                down.SetBrightness(0.1f);
                carController.MoveBackward();
                Thread.Sleep(1000);
                down.SetBrightness(0.0f);

                carController.Stop();
                Thread.Sleep(500);

                left.SetBrightness(0.1f);
                carController.TurnLeft();
                Thread.Sleep(1000);
                left.SetBrightness(0.0f);

                carController.Stop();
                Thread.Sleep(500);

                right.SetBrightness(0.1f);
                carController.TurnRight();
                Thread.Sleep(1000);
                right.SetBrightness(0.0f);

                carController.Stop();
                Thread.Sleep(500);
            }
        }