2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-01-01 01:05:57 -07:00
|
|
|
/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "IterativeRobot.h"
|
|
|
|
|
|
|
|
|
|
#include "DriverStation.h"
|
2016-05-22 21:41:22 -07:00
|
|
|
#include "HAL/HAL.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2017-07-08 10:50:56 -04:00
|
|
|
IterativeRobot::IterativeRobot() {
|
|
|
|
|
HAL_Report(HALUsageReporting::kResourceType_Framework,
|
|
|
|
|
HALUsageReporting::kFramework_Iterative);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Provide an alternate "main loop" via StartCompetition().
|
2015-06-25 15:07:55 -04:00
|
|
|
*
|
|
|
|
|
* This specific StartCompetition() implements "main loop" behaviour synced with
|
2016-09-21 23:48:54 -07:00
|
|
|
* the DS packets.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void IterativeRobot::StartCompetition() {
|
2017-07-08 10:50:56 -04:00
|
|
|
// Loop forever, calling the appropriate mode-dependent function
|
2015-06-25 15:07:55 -04:00
|
|
|
while (true) {
|
2016-10-02 09:05:32 -07:00
|
|
|
// wait for driver station data so the loop doesn't hog the CPU
|
2017-07-08 10:50:56 -04:00
|
|
|
DriverStation::GetInstance().WaitForData();
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2017-07-08 10:50:56 -04:00
|
|
|
LoopFunc();
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|