Пример #1
0
        public static void Main()
        {
            CTRE.Gamepad _gamepad = new CTRE.Gamepad(new CTRE.UsbHostDevice());
            //0 - left x
            //1 - left y
            //2 - right x
            //
            //5 - LB
            //6 - RB

            ledSpike.SetControlMode(CTRE.TalonSrx.ControlMode.kVoltage);
            ledSpike.SetCurrentLimit(1);

            while (true)
            {
                float y    = -_gamepad.GetAxis(1);
                float turn = _gamepad.GetAxis(2);

                Deadband(ref y);
                Deadband(ref turn);

                if (_gamepad.GetConnectionStatus() == CTRE.UsbDeviceConnection.Connected)
                {
                    if (_gamepad.GetButton(5))
                    {
                        ArcadeDrive(y, turn);
                        /* feed watchdog to keep Talon's enabled */
                        CTRE.Watchdog.Feed();
                    }
                    if (_gamepad.GetButton(6))
                    {
                        ledSpike.Set(3.5f);
                        CTRE.Watchdog.Feed();
                    }
                    else
                    {
                        ledSpike.Set(0);
                    }
                }

                /* run this task every 10ms */
                Thread.Sleep(10);
            }
        }
Пример #2
0
        static void Run()
        {
            float x = _gamepad.GetAxis(1);

            Deadband(ref x);

            //Set the Maximum Current Limit for the Talon (in Amps)
            talon.SetCurrentLimit(10);
            //Enable the Current Limiting Feature.
            talon.EnableCurrentLimit(true);

            talon.Set(x);

            float current = talon.GetOutputCurrent();

            stringBuilder.Append("\t");
            stringBuilder.Append(current);
            stringBuilder.Append("\t");
        }