Exemple #1
0
        protected override void Main()
        {
            while (true)
            {
                DriveTrain.TankDrive(-DriveStick_Left.GetRawAxis(1), -DriveStick_Right.GetRawAxis(1));

                if ((DriveStick_Left.GetRawAxis(1) < -0.1 || DriveStick_Right.GetRawAxis(1) < -0.1) && !Custom_Board.GetRawButton(4))
                {
                    Intake1.Set(-1);
                    Intake2.Set(-1);
                }

                else
                {
                    Intake1.Set(0);
                    Intake2.Set(0);
                }

                if (Custom_Board.GetRawButton(4))
                {
                    Shooter.Set(.9);
                    Agitator.Set(1);
                }

                else
                {
                    Shooter.Set(0);
                    Agitator.Set(0);
                }

                if (DriveStick_Left.GetRawButton(1) || DriveStick_Right.GetRawButton(1))
                {
                    if (flag)
                    {
                        Shifters.Set(!Shifters.Get());

                        flag = false;
                    }
                }

                else
                {
                    flag = true;
                }
                if (DriveStick_Left.GetRawAxis(2) > 0.1)
                {
                    PTO.Set(true);
                }

                else
                {
                    PTO.Set(false);
                }

                Shooter_Pivot.Set(.5 * Custom_Board.GetRawAxis(4));

                Snooze(10);
            }
        }
        protected override void Main()
        {
            while (true)
            {
                if (Custom_Board.GetRawAxis(2) > 0.1)
                {
                    Intake1.Set(-1);
                    Intake2.Set(1);
                }

                else if (DriveStick_Right.GetRawButton(3) || Custom_Board.GetRawAxis(3) > 0.1)
                {
                    Intake1.Set(1);
                    Intake2.Set(-1);
                }

                else
                {
                    Intake1.Set(0);
                    Intake2.Set(0);
                }

                if (Custom_Board.GetRawButton(3))
                {
                    if (started)
                    {
                        if ((Environment.TickCount - time) > 1000)
                        {
                            Agitator.Set(1);
                            IntakeSecondStage.Set(-1);
                        }
                    }

                    else
                    {
                        time    = Environment.TickCount;
                        started = true;
                        Shooter.Set(.95);
                    }
                }

                else if (Custom_Board.GetRawButton(2))
                {
                    if (started)
                    {
                        if ((Environment.TickCount - time) > 1000)
                        {
                            Agitator.Set(-1);
                            IntakeSecondStage.Set(-1);
                        }
                    }

                    else
                    {
                        time    = Environment.TickCount;
                        started = true;
                        Shooter.Set(.95);
                    }
                }

                else
                {
                    Shooter.Set(0);
                    Agitator.Set(0);
                    IntakeSecondStage.Set(0);
                    started = false;
                }

                if (DriveStick_Left.GetRawButton(1) || DriveStick_Right.GetRawButton(1))
                {
                    if (toggleshift)
                    {
                        Shifters.Set(!Shifters.Get());

                        toggleshift = false;
                    }
                }

                else
                {
                    toggleshift = true;
                }

                if (DriveStick_Left.GetRawButton(6) && DriveStick_Right.GetRawButton(11))
                {
                    if (togglepto)
                    {
                        PTO.Set(!PTO.Get());

                        togglepto = false;
                    }
                }

                else
                {
                    togglepto = true;
                }

                if (PTO.Get())
                {
                    if (DriveStick_Right.GetRawAxis(1) >= 0)
                    {
                        DriveTrain.StopMotor();
                    }
                    else
                    {
                        DriveTrain.Move(DriveStick_Right.GetRawAxis(1), DriveStick_Right.GetRawAxis(1));
                    }
                }
                else
                {
                    DriveTrain.Move(-DriveStick_Left.GetRawAxis(1), -DriveStick_Right.GetRawAxis(1));
                }

                if (Custom_Board.GetRawButton(4))
                {
                    GearSlot.Set(true);
                }
                else
                {
                    GearSlot.Set(false);
                }

                //if (DriveStick_Left.GetRawAxis(2) > 0.1) PTO.Set(true);
                //else PTO.Set(false);

                // Set the shooter pivot to a specific point based on the joysticks.
                //TurntableController.Controller.Setpoint = ((encoderTicks + Custom_Board.GetRawAxis(4)) / 2);
                Shooter_Pivot.Set(.5 * Custom_Board.GetRawAxis(4));

                Snooze(10);
            }
        }