WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
XRPOnBoardIO.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <frc/DigitalInput.h>
8#include <frc/DigitalOutput.h>
9
10#include <memory>
11
12#include <units/time.h>
13
14namespace frc {
15
16/**
17 * @ingroup xrp_api
18 * @{
19 */
20
21/**
22 * This class represents the onboard IO of the XRP
23 * reference robot. This the USER push button and
24 * LED.
25 *
26 * <p>DIO 0 - USER Button (input only)
27 * DIO 1 - LED (output only)
28 */
30 public:
31 XRPOnBoardIO() {} // No need to do anything. No configurable IO
32
33 static constexpr auto kMessageInterval = 1_s;
34 units::second_t m_nextMessageTime = 0_s;
35
36 /**
37 * Gets if the USER button is pressed.
38 *
39 * @return True if the USER button is currently pressed.
40 */
42
43 /**
44 * Sets the yellow LED.
45 *
46 * @param value True to activate LED, false otherwise.
47 */
48 void SetLed(bool value);
49
50 /**
51 * Gets the state of the yellow LED.
52 *
53 * @return True if LED is active, false otherwise.
54 */
55 bool GetLed() const;
56
57 private:
58 frc::DigitalInput m_userButton{0};
59 frc::DigitalOutput m_led{1};
60};
61
62/** @} */
63
64} // namespace frc
Class to read a digital input.
Definition DigitalInput.h:28
Class to write to digital outputs.
Definition DigitalOutput.h:26
This class represents the onboard IO of the XRP reference robot.
Definition XRPOnBoardIO.h:29
XRPOnBoardIO()
Definition XRPOnBoardIO.h:31
units::second_t m_nextMessageTime
Definition XRPOnBoardIO.h:34
bool GetUserButtonPressed()
Gets if the USER button is pressed.
bool GetLed() const
Gets the state of the yellow LED.
static constexpr auto kMessageInterval
Definition XRPOnBoardIO.h:33
void SetLed(bool value)
Sets the yellow LED.
Definition CAN.h:11