Files
allwpilib/wpilibc/src/main/native/cpp/IterativeRobot.cpp

41 lines
1.3 KiB
C++
Raw Normal View History

/*----------------------------------------------------------------------------*/
/* Copyright (c) 2008-2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "IterativeRobot.h"
#include <HAL/HAL.h>
#include "DriverStation.h"
using namespace frc;
2017-07-08 10:50:56 -04:00
IterativeRobot::IterativeRobot() {
HAL_Report(HALUsageReporting::kResourceType_Framework,
HALUsageReporting::kFramework_Iterative);
}
/**
* Provide an alternate "main loop" via StartCompetition().
*
* This specific StartCompetition() implements "main loop" behaviour synced with
* the DS packets.
*/
void IterativeRobot::StartCompetition() {
RobotInit();
// Tell the DS that the robot is ready to be enabled
HAL_ObserveUserProgramStarting();
2017-07-08 10:50:56 -04:00
// Loop forever, calling the appropriate mode-dependent function
while (true) {
// wait for driver station data so the loop doesn't hog the CPU
2017-07-08 10:50:56 -04:00
DriverStation::GetInstance().WaitForData();
2017-07-08 10:50:56 -04:00
LoopFunc();
}
}