CTRE Phoenix Pro C++ 23.0.12
AutoFeedEnable.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
9#include "frc/DriverStation.h"
11#include "hal/simulation/MockHooks.h"
12
13namespace ctre {
14namespace phoenixpro {
15namespace wpiutils {
16
18public:
20 {
21 static AutoFeedEnable *autoFeedEnable = new AutoFeedEnable{};
22 return *autoFeedEnable;
23 }
24
25private:
26 int32_t m_simPeriodicUid{-1};
27
28 AutoFeedEnable()
29 {
30 m_simPeriodicUid = HALSIM_RegisterSimPeriodicBeforeCallback(OnPeriodic, this);
31 }
32 ~AutoFeedEnable()
33 {
34 if (m_simPeriodicUid >= 0)
35 {
36 HALSIM_CancelSimPeriodicBeforeCallback(m_simPeriodicUid);
37 m_simPeriodicUid = -1;
38 }
39 }
40
41 static void OnPeriodic(void *param)
42 {
43 (void)param;
44 if (frc::DriverStation::IsEnabled())
45 {
47 }
48 }
49};
50
51}
52}
53}
Definition: AutoFeedEnable.hpp:17
static AutoFeedEnable & GetInstance()
Definition: AutoFeedEnable.hpp:19
CTREXPORT void FeedEnable(int timeoutMs)
Feed the robot enable.
Definition: string_util.hpp:14