示例#1
0
	void OperatorControl()
	{
		// Loop counter to ensure that the program is running (debug helper
		// that can be removed when things get more stable)
		int sanity, bigSanity = 0;
		
		gamepad.Update();

		while (IsOperatorControl() && IsEnabled())
		{
			controls = Controls::GetInstance();
			
			controls->SetSpeed(LEFT_DRIVE_PWM, -1.0 * gamepad.GetRightY());
			controls->SetSpeed(RIGHT_DRIVE_PWM, -1.0 * gamepad.GetRightY());
			
			gamepad.Update();
			
			dsLCD->Clear();
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line1, "2013 Test Fix");
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line2, "Teleop Mode");
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line6, "bigSanity: %d", sanity);
			dsLCD->UpdateLCD();
			sanity++;
			if (0 == sanity % 20)
			{
				bigSanity++;
			}

			Wait(0.05);				// wait for a motor update time
		}
	}
示例#2
0
	void Test()
	{
		menuType currentMenu = TOP;
		menuType newMenu = TOP;

		BaseMenu * menus[NUM_MENU_TYPE];

		menus[TOP] = new TopMenu;
		menus[ANALOG] = new AnalogMenu;
		menus[DIGITAL_TOP] = new DigitalMenu;
		menus[SOLENOID] = new SolenoidMenu;
		menus[DIGITAL_PWM] = new PWMMenu;
		menus[DIGITAL_IO] = new DigitalIOMenu;
		menus[DIGITAL_RELAY] = new RelayMenu;
		menus[DIGITAL_IO_STATE] = new DigitalIOStateMenu;
		menus[DIGITAL_IO_CLOCK] = new DigitalIOClockMenu;
		menus[DIGITAL_IO_ENCODER] = new DigitalIOEncoderMenu;

		// Write out the TOP menu for the first time
		menus[currentMenu]->UpdateDisplay();

		// Initialize the button states on the gamepad
		gamepad.Update();

		// Loop counter to ensure that the program us running (debug helper
		// that can be removed when things get more stable)
		int sanity = 0;

		while (IsTest())
		{
			// The dpad "up" button is used to move the menu pointer up one line
			// on the LCD display
			if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kUp))
			{
				menus[currentMenu]->HandleIndexUp();
			}

			// The dpad "down" button is used to move the menu pointer down one line
			// on the LCD display
			if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kDown))
			{
				menus[currentMenu]->HandleIndexDown();
			}

			// The dpad left button is used to exit a submenu when the menu pointer
			// points to the "back" menu item and to decrease a value (where 
			// appropriate) on any other menu item.
			if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kLeft))
			{
				newMenu = menus[currentMenu]->HandleSelectLeft();
			}

			// Theoretically, both the select buttons could be pressed in the 
			// same 10 msec window. However, if using the dpad on the game 
			// game controller this is physically impossible so we don't
			// need to worry about a previous value of newMenu being 
			// overwritten in the next bit of code.

			// The dpad right button is used to enter a submenu when the menu pointer
			// points to a submenu item and to increase a value (where  appropriate) 
			// on any other menu item.
			if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kRight))
			{
				newMenu = menus[currentMenu]->HandleSelectRight();

				// Handle change from one menu to a sub menu
				if (newMenu != currentMenu)
				{
					// When we enter a menu we need to set the record the
					// menu to return to. We do *not* want to do this when
					// returning from a menu to its calling menu.
					menus[newMenu]->SetCallingMenu(currentMenu);
				}
			}

			// Handle change from one menu to another
			if (newMenu != currentMenu)
			{
				menus[newMenu]->UpdateDisplay();
				currentMenu = newMenu;
			}

			// Set the motor speed(s) (if any have been enabled via the Digital PWM menu)
			menus[DIGITAL_PWM]->SetSpeed(-1.0 * gamepad.GetRightY());

			// Update gamepad button states
			gamepad.Update();

			// Update the display (we do this on every loop pass because some menus
			// (analog, for example) need to have values updated even when there are
			// no dpad events to handle)
			menus[currentMenu]->UpdateDisplay();

			// Dump the sanity time value to the LCD
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line6, "Sanity: %d", sanity);
			dsLCD->UpdateLCD();

			sanity++;

			// Run the loop every 50 msec (20 times per second)
			Wait(0.050);
		}
	}