public void BallHandler() { bool deliver = !m_gamepad.GetButton(Y_BUTTON); bool runintake = m_gamepad.GetButton(LEFT_BUMPER); //whether the Intake button is pressed. bool is true or false bool runexpel = m_gamepad.GetButton(RIGHT_BUMPER); // Whether if the Expel button is pressed is true or false if (runintake) // If/else if/else statement { m_intake.setState(Intake.INTAKESTATE.Sweep); // If the Sweep button is pressed then it will sweep m_transfer.SetState(Transfer.TRANSFER_STATE.TRANSFER_ON); } else if (runexpel) { m_intake.setState(Intake.INTAKESTATE.Expel); // Else if the Expel button is pressed then it will expel m_transfer.SetState(Transfer.TRANSFER_STATE.TRANSFER_EXPEL); } else { m_intake.setState(Intake.INTAKESTATE.Off); // else no button is pressed then the sweep will be off. m_transfer.SetState(Transfer.TRANSFER_STATE.TRANSFER_OFF); } if (deliver) { m_deliver.setState(Deliver.DELIVERSTATE.Deliver); } else { m_deliver.setState(Deliver.DELIVERSTATE.HoldBalls); } m_intake.Run(); m_transfer.Run(); if (prevDeliver != deliver) { m_deliver.Run(); } prevDeliver = deliver; }
public static void Main() { TeleopControl Telecontrol = new TeleopControl(); AutonControl Autocontrol = new AutonControl(); int AutonLoops = LoopSec * AutonTime; GameController controller = Telecontrol.GetController(); bool okToRun = false; // Can we run code or not while (true) // loop forever { // If the USB controller isn't plugged in or if the stop button is pressed // it isn't ok to run the motors. // If the USB is plugged in, use the start button to activate (it will stay // that way unless the stop button is pressed or the USB becomes dislodged. if (controller.GetConnectionStatus() == UsbDeviceConnection.Connected) { if (controller.GetButton(Telecontrol.GetStartButton())) { okToRun = true; } else if (controller.GetButton(Telecontrol.GetStopButton())) { okToRun = false; } } else { okToRun = false; } if (okToRun) { Watchdog.Feed(); bool runauton = controller.GetButton(Telecontrol.GetAutonButton()); if ((runauton || runningAuton) && AutonLoopCount < AutonLoops) { runningAuton = !Autocontrol.Run(); ranAuto = true; AutonLoopCount++; } else if (ranAuto && AutonLoopCount < AutonLoops) { Deliver del = Deliver.GetInstance(); del.Run(); AutonLoopCount++; } else { Telecontrol.Run(); } Thread.Sleep(20); } else { Telecontrol.CheckSensors(); } } }