mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[hal,wpilib] Add function to control "Radio" LED (#6073)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <hal/CAN.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/LEDs.h>
|
||||
#include <hal/Power.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
@@ -230,6 +231,30 @@ units::celsius_t RobotController::GetCPUTemp() {
|
||||
return units::celsius_t{retVal};
|
||||
}
|
||||
|
||||
static_assert(RadioLEDState::kOff ==
|
||||
static_cast<RadioLEDState>(HAL_RadioLEDState::HAL_RadioLED_kOff));
|
||||
static_assert(
|
||||
RadioLEDState::kGreen ==
|
||||
static_cast<RadioLEDState>(HAL_RadioLEDState::HAL_RadioLED_kGreen));
|
||||
static_assert(RadioLEDState::kRed ==
|
||||
static_cast<RadioLEDState>(HAL_RadioLEDState::HAL_RadioLED_kRed));
|
||||
static_assert(
|
||||
RadioLEDState::kOrange ==
|
||||
static_cast<RadioLEDState>(HAL_RadioLEDState::HAL_RadioLED_kOrange));
|
||||
|
||||
void RobotController::SetRadioLEDState(RadioLEDState state) {
|
||||
int32_t status = 0;
|
||||
HAL_SetRadioLEDState(static_cast<HAL_RadioLEDState>(state), &status);
|
||||
FRC_CheckErrorStatus(status, "SetRadioLEDState");
|
||||
}
|
||||
|
||||
RadioLEDState RobotController::GetRadioLEDState() {
|
||||
int32_t status = 0;
|
||||
auto retVal = static_cast<RadioLEDState>(HAL_GetRadioLEDState(&status));
|
||||
FRC_CheckErrorStatus(status, "GetRadioLEDState");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
CANStatus RobotController::GetCANStatus() {
|
||||
int32_t status = 0;
|
||||
float percentBusUtilization = 0;
|
||||
|
||||
@@ -338,6 +338,23 @@ void RoboRioSim::SetComments(std::string_view comments) {
|
||||
HALSIM_SetRoboRioComments(comments.data(), comments.size());
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RoboRioSim::RegisterRadioLEDStateCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelRoboRioRadioLEDStateCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioRadioLEDStateCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
RadioLEDState RoboRioSim::GetRadioLEDState() {
|
||||
return static_cast<RadioLEDState>(HALSIM_GetRoboRioRadioLEDState());
|
||||
}
|
||||
|
||||
void RoboRioSim::SetRadioLEDState(RadioLEDState state) {
|
||||
HALSIM_SetRoboRioRadioLEDState(static_cast<HAL_RadioLEDState>(state));
|
||||
}
|
||||
|
||||
void RoboRioSim::ResetData() {
|
||||
HALSIM_ResetRoboRioData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user