mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[hal] Add frequency support to DutyCycle (#8076)
This commit is contained in:
@@ -17,7 +17,6 @@ void InitializeDutyCycleData() {
|
||||
DutyCycleData* hal::SimDutyCycleData;
|
||||
|
||||
void DutyCycleData::ResetData() {
|
||||
digitalChannel = 0;
|
||||
initialized.Reset(false);
|
||||
simDevice = 0;
|
||||
frequency.Reset(0);
|
||||
@@ -25,22 +24,10 @@ void DutyCycleData::ResetData() {
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
int32_t HALSIM_FindDutyCycleForChannel(int32_t channel) {
|
||||
for (int i = 0; i < kNumDutyCycles; ++i) {
|
||||
if (SimDutyCycleData[i].initialized &&
|
||||
SimDutyCycleData[i].digitalChannel == channel) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void HALSIM_ResetDutyCycleData(int32_t index) {
|
||||
SimDutyCycleData[index].ResetData();
|
||||
}
|
||||
int32_t HALSIM_GetDutyCycleDigitalChannel(int32_t index) {
|
||||
return SimDutyCycleData[index].digitalChannel;
|
||||
}
|
||||
|
||||
HAL_SimDeviceHandle HALSIM_GetDutyCycleSimDevice(int32_t index) {
|
||||
return SimDutyCycleData[index].simDevice;
|
||||
@@ -51,7 +38,7 @@ HAL_SimDeviceHandle HALSIM_GetDutyCycleSimDevice(int32_t index) {
|
||||
SimDutyCycleData, LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, Initialized, initialized)
|
||||
DEFINE_CAPI(int32_t, Frequency, frequency)
|
||||
DEFINE_CAPI(double, Frequency, frequency)
|
||||
DEFINE_CAPI(double, Output, output)
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
|
||||
@@ -17,11 +17,10 @@ class DutyCycleData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Frequency)
|
||||
|
||||
public:
|
||||
std::atomic<int32_t> digitalChannel{0};
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedName> initialized{
|
||||
false};
|
||||
std::atomic<HAL_SimDeviceHandle> simDevice;
|
||||
SimDataValue<int32_t, HAL_MakeInt, GetFrequencyName> frequency{0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetFrequencyName> frequency{0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetOutputName> output{0};
|
||||
|
||||
virtual void ResetData();
|
||||
|
||||
Reference in New Issue
Block a user