task main()
{
  // Turn on the LCD backlight
  bLCDBacklight = true;
  
  // Clear the LCD
  LcdClear();

  // Display a startup message
  displayLCDCenteredString(0, "Starting up...");

  // Don't start the robot for two seconds, as the original code did
  wait1Msec(2000);

  // Call the pre_auton funtion
  pre_auton();

  // Main loop
  while (true)
  {
    if (bIfiRobotDisabled)
    {
      // Allow the auton to be set using the LCD when disabled
      StartTask(LcdSetAuton);

      // Stop all motors when disabled
      allMotorsOff();
    }

    // If the robot is disabled, do nothing until it is enabled
    while (bIfiRobotDisabled)
      wait1Msec(25);

    // Stop allowing the autonomous to be set from the LCD
    StopTask(LcdSetAuton);

    // Clear the LCD
    LcdClear();

    // Handle autonomous mode
    if (bIfiAutonomousMode)
    {
      // Clear the LCD
      LcdClear();

      // Start the autonomous task
      StartTask(autonomous);

      // Loop to be run while autonomous is running and the robot is enabled
      while (bIfiAutonomousMode && !bIfiRobotDisabled)
      {
        // If the VEXNET disconnects, power off all of the motors
        if (!bVEXNETActive)
          if (nVexRCReceiveState == vrNoXmiters)
            allMotorsOff();

        // Don't hog CPU
        wait1Msec(25);
      }

      // After autonomous has expired, power off all of the motors
      allMotorsOff();

      // Stop all tasks if the user has set tasks to end between modes
      if(bStopTasksBetweenModes)
        allTasksStop();
    }

    else
    {
      // Clear the LCD
      LcdClear();

      // Display Driver Control to reflect the current mode
      displayLCDCenteredString(0, "Driver Control");

      // Start the user control task
      StartTask(usercontrol);

      // Here we repeat loop waiting for user control to end and (optionally) start
      // of a new competition run
      while (!bIfiAutonomousMode && !bIfiRobotDisabled)
      {
        // If the VEXNET disconnects, turn off the motors
        if (nVexRCReceiveState == vrNoXmiters)
          allMotorsOff();

        // Don't hog CPU
        wait1Msec(25);
      }

      // If the mode is switched from user control, turn of all motors
      allMotorsOff();

      // Stop all tasks if the user has set tasks to end between modes
      if(bStopTasksBetweenModes)
        allTasksStop();
    }
  }
}
task main()
{
	// Master CPU will not let competition start until powered on for at least 2-seconds
	clearLCDLine(0);
	clearLCDLine(1);
	displayLCDPos(0, 0);
	displayNextLCDString("Startup");
	wait1Msec(2000);


	while (true)
	{
		clearLCDLine(0);
		clearLCDLine(1);
		displayLCDPos(0, 0);

		while (bIfiRobotDisabled)
		{
			if (JustDisabled == true){
				startTask(LCD);
				SensorValue(BaseLock) = 0;
				SensorType[ in2 ] = sensorNone;
				wait1Msec(1000);
				SensorType[ in2 ] = sensorGyro;
				wait1Msec(2000);
			}
			else {
				wait1Msec(25);
			}
			JustDisabled = false;
		}

		JustDisabled = true;

		nTimeXX = 0;
		clearLCDLine(0);
		clearLCDLine(1);
		displayLCDPos(0, 0);
		if (bIfiAutonomousMode)
		{
			displayNextLCDString("Autonomous");
			startTask(autonomous);

			// Waiting for autonomous phase to end
			while (bIfiAutonomousMode && !bIfiRobotDisabled)
			{
				if (!bVEXNETActive)
				{
					if (nVexRCReceiveState == vrNoXmiters) // the transmitters are powered off!!
						allMotorsOff();
				}
				wait1Msec(25);               // Waiting for autonomous phase to end
			}
			allMotorsOff();
			if(bStopTasksBetweenModes)
			{
				allTasksStop();
			}
		}

		else
		{
			displayNextLCDString("User Control");
			startTask(usercontrol);

			// Here we repeat loop waiting for user control to end and (optionally) start
			// of a new competition run
			while (!bIfiAutonomousMode && !bIfiRobotDisabled)
			{
				if (nVexRCReceiveState == vrNoXmiters) // the transmitters are powered off!!
					allMotorsOff();
				wait1Msec(25);
			}
			allMotorsOff();
			if(bStopTasksBetweenModes)
			{
				allTasksStop();
			}
		}
	}
}
Beispiel #3
0
task main()
{
	// Master CPU will not let competition start until powered on for at least 2-seconds
	wait1Msec(2000);


	pre_auton();

	//wait1Msec(500);


	while (true)
	{

		while (bIfiRobotDisabled)
		{
		  nTimeXX = 0;
			while (true)
			{
				if (!bIfiRobotDisabled)
				  break;
				wait1Msec(25);

				if (!bIfiRobotDisabled)
				  break;
				wait1Msec(25);

				if (!bIfiRobotDisabled)
				  break;
				wait1Msec(25);

				if (!bIfiRobotDisabled)
				  break;
				wait1Msec(25);
				++nTimeXX;
			}
	  }

		nTimeXX = 0;
		if (bIfiAutonomousMode)
		{
		  startTask(autonomous);

			// Waiting for autonomous phase to end
			while (bIfiAutonomousMode && !bIfiRobotDisabled)
			{
				if (!bVEXNETActive)
				{
				  if (nVexRCReceiveState == vrNoXmiters) // the transmitters are powered off!!
					  allMotorsOff();
				}
				wait1Msec(25);               // Waiting for autonomous phase to end
			}
		  allMotorsOff();
		  if(bStopTasksBetweenModes)
		  {
			  allTasksStop();
			}
		}

		else
		{
			startTask(usercontrol);

			// Here we repeat loop waiting for user control to end and (optionally) start
			// of a new competition run
			while (!bIfiAutonomousMode && !bIfiRobotDisabled)
			{
				if (nVexRCReceiveState == vrNoXmiters) // the transmitters are powered off!!
					allMotorsOff();
				wait1Msec(25);
		  }
			allMotorsOff();
		  if(bStopTasksBetweenModes)
		  {
			  allTasksStop();
			}
		}
	}
}
task main()
{
    // Master CPU will not let competition start until powered on for at least 2-seconds
    clearLCDLine(0);
    clearLCDLine(1);
    displayLCDPos(0, 0);
    displayNextLCDString("Startup");
    wait1Msec(2000);


    pre_auton();

    //wait1Msec(500);


    while (true)
    {

        clearLCDLine(0);
        clearLCDLine(1);
        displayLCDPos(0, 0);

        while (bSimulatedRobotDisabled)
        {
            displayLCDPos(0, 0);
            displayNextLCDString("Disabled");
            nTimeXX = 0;
            while (true)
            {
                displayStatusAndTime();
                if (!bSimulatedRobotDisabled)
                    break;
                wait1Msec(25);

                displayStatusAndTime();
                if (!bSimulatedRobotDisabled)
                    break;
                wait1Msec(25);

                displayStatusAndTime();
                if (!bSimulatedRobotDisabled)
                    break;
                wait1Msec(25);

                displayStatusAndTime();
                if (!bSimulatedRobotDisabled)
                    break;
                wait1Msec(25);
                ++nTimeXX;
            }
        }

        nTimeXX = 0;
        clearLCDLine(0);
        clearLCDLine(1);
        displayLCDPos(0, 0);
        if (bSimulatedAutonomousMode)
        {
            displayNextLCDString("Autonomous");
            StartTask(autonomous);

            // Waiting for autonomous phase to end
            while (bSimulatedAutonomousMode && !bSimulatedRobotDisabled)
            {
                if (!bVEXNETActive)
                {
                    if (nSimulatedRecieveState == vrNoXmiters) // the transmitters are powered off!!
                        allMotorsOff();
                }
                wait1Msec(25);               // Waiting for autonomous phase to end
            }
            allMotorsOff();
            allTasksStop();
        }

        else
        {
            displayNextLCDString("User Control");
            StartTask(usercontrol);

            // Here we repeat loop waiting for user control to end and (optionally) start
            // of a new competition run
            while (!bSimulatedAutonomousMode && !bSimulatedRobotDisabled)
            {
                if (nSimulatedRecieveState == vrNoXmiters) // the transmitters are powered off!!
                    allMotorsOff();
                wait1Msec(25);
            }
            allMotorsOff();
            allTasksStop();
        }
    }
}