mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[hal,wpilib] Add function to control "Radio" LED (#6073)
This commit is contained in:
21
hal/src/main/native/sim/LEDs.cpp
Normal file
21
hal/src/main/native/sim/LEDs.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "hal/LEDs.h"
|
||||
|
||||
#include "hal/simulation/RoboRioData.h"
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeLEDs() {}
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) {
|
||||
HALSIM_SetRoboRioRadioLEDState(state);
|
||||
}
|
||||
HAL_RadioLEDState HAL_GetRadioLEDState(int32_t* status) {
|
||||
return HALSIM_GetRoboRioRadioLEDState();
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -136,6 +136,7 @@ DEFINE_CAPI(int32_t, UserFaults3V3, userFaults3V3)
|
||||
DEFINE_CAPI(double, BrownoutVoltage, brownoutVoltage)
|
||||
DEFINE_CAPI(double, CPUTemp, cpuTemp)
|
||||
DEFINE_CAPI(int32_t, TeamNumber, teamNumber)
|
||||
DEFINE_CAPI(HAL_RadioLEDState, RadioLEDState, radioLedState)
|
||||
|
||||
int32_t HALSIM_RegisterRoboRioSerialNumberCallback(
|
||||
HAL_RoboRioStringCallback callback, void* param, HAL_Bool initialNotify) {
|
||||
@@ -192,5 +193,6 @@ void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback,
|
||||
REGISTER(userFaults3V3);
|
||||
REGISTER(brownoutVoltage);
|
||||
REGISTER(cpuTemp);
|
||||
REGISTER(radioLedState);
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
@@ -32,10 +32,15 @@ class RoboRioData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(BrownoutVoltage)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(CPUTemp)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(TeamNumber)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(RadioLEDState)
|
||||
|
||||
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(SerialNumber)
|
||||
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(Comments);
|
||||
|
||||
static inline HAL_Value MakeRadioLEDStateValue(HAL_RadioLEDState value) {
|
||||
return HAL_MakeEnum(value);
|
||||
}
|
||||
|
||||
public:
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetFPGAButtonName> fpgaButton{false};
|
||||
SimDataValue<double, HAL_MakeDouble, GetVInVoltageName> vInVoltage{12.0};
|
||||
@@ -61,6 +66,8 @@ class RoboRioData {
|
||||
6.75};
|
||||
SimDataValue<double, HAL_MakeDouble, GetCPUTempName> cpuTemp{45.0};
|
||||
SimDataValue<int32_t, HAL_MakeInt, GetTeamNumberName> teamNumber{0};
|
||||
SimDataValue<HAL_RadioLEDState, MakeRadioLEDStateValue, GetRadioLEDStateName>
|
||||
radioLedState{HAL_RadioLED_kOff};
|
||||
|
||||
int32_t RegisterSerialNumberCallback(HAL_RoboRioStringCallback callback,
|
||||
void* param, HAL_Bool initialNotify);
|
||||
|
||||
Reference in New Issue
Block a user