WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
OnBoardIO.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 <memory>
8
9#include <frc/DigitalInput.h>
10#include <frc/DigitalOutput.h>
11#include <units/time.h>
12
13namespace frc {
14
15/**
16 * @ingroup romi_api
17 * @{
18 */
19
20/**
21 * This class represents the onboard IO of the Romi
22 * reference robot. This includes the pushbuttons and
23 * LEDs.
24 *
25 * <p>DIO 0 - Button A (input only)
26 * DIO 1 - Button B (input) or Green LED (output)
27 * DIO 2 - Button C (input) or Red LED (output)
28 * DIO 3 - Yellow LED (output only)
29 */
30class OnBoardIO {
31 public:
32 /** Mode for Romi onboard IO */
33 enum ChannelMode { /** Input */ INPUT, /** Output */ OUTPUT };
35
36 static constexpr auto kMessageInterval = 1_s;
37 units::second_t m_nextMessageTime = 0_s;
38
39 /**
40 * Gets if the A button is pressed.
41 */
43
44 /**
45 * Gets if the B button is pressed.
46 */
48
49 /**
50 * Gets if the C button is pressed.
51 */
53
54 /**
55 * Sets the green LED.
56 */
57 void SetGreenLed(bool value);
58
59 /**
60 * Sets the red LED.
61 */
62 void SetRedLed(bool value);
63
64 /**
65 * Sets the yellow LED.
66 */
67 void SetYellowLed(bool value);
68
69 private:
70 frc::DigitalInput m_buttonA{0};
71 frc::DigitalOutput m_yellowLed{3};
72
73 // DIO 1
74 std::unique_ptr<frc::DigitalInput> m_buttonB;
75 std::unique_ptr<frc::DigitalOutput> m_greenLed;
76
77 // DIO 2
78 std::unique_ptr<frc::DigitalInput> m_buttonC;
79 std::unique_ptr<frc::DigitalOutput> m_redLed;
80};
81
82/** @} */
83
84} // 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 Romi reference robot.
Definition OnBoardIO.h:30
bool GetButtonBPressed()
Gets if the B button is pressed.
ChannelMode
Mode for Romi onboard IO.
Definition OnBoardIO.h:33
@ OUTPUT
Output.
Definition OnBoardIO.h:33
@ INPUT
Input.
Definition OnBoardIO.h:33
void SetRedLed(bool value)
Sets the red LED.
bool GetButtonAPressed()
Gets if the A button is pressed.
void SetGreenLed(bool value)
Sets the green LED.
units::second_t m_nextMessageTime
Definition OnBoardIO.h:37
static constexpr auto kMessageInterval
Definition OnBoardIO.h:36
void SetYellowLed(bool value)
Sets the yellow LED.
bool GetButtonCPressed()
Gets if the C button is pressed.
OnBoardIO(OnBoardIO::ChannelMode dio1, OnBoardIO::ChannelMode dio2)
Definition CAN.h:11