Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 2 | /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include "frc/IterativeRobot.h" |
| 9 | |
| 10 | #include <hal/HAL.h> |
| 11 | |
| 12 | #include "frc/DriverStation.h" |
| 13 | |
| 14 | using namespace frc; |
| 15 | |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 16 | static constexpr auto kPacketPeriod = 0.02_s; |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 17 | |
| 18 | IterativeRobot::IterativeRobot() : IterativeRobotBase(kPacketPeriod) { |
| 19 | HAL_Report(HALUsageReporting::kResourceType_Framework, |
| 20 | HALUsageReporting::kFramework_Iterative); |
| 21 | } |
| 22 | |
| 23 | void IterativeRobot::StartCompetition() { |
| 24 | RobotInit(); |
| 25 | |
| 26 | // Tell the DS that the robot is ready to be enabled |
| 27 | HAL_ObserveUserProgramStarting(); |
| 28 | |
| 29 | // Loop forever, calling the appropriate mode-dependent function |
| 30 | while (true) { |
| 31 | // Wait for driver station data so the loop doesn't hog the CPU |
| 32 | DriverStation::GetInstance().WaitForData(); |
| 33 | |
| 34 | LoopFunc(); |
| 35 | } |
| 36 | } |