mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[hal, wpilib] Remove DigitalSource and AnalogTrigger (#7753)
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
// 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 "../PortsInternal.h"
|
||||
#include "AnalogTriggerDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeAnalogTriggerData() {
|
||||
static AnalogTriggerData satd[kNumAnalogTriggers];
|
||||
::hal::SimAnalogTriggerData = satd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
AnalogTriggerData* hal::SimAnalogTriggerData;
|
||||
void AnalogTriggerData::ResetData() {
|
||||
initialized.Reset(0);
|
||||
triggerLowerBound.Reset(0);
|
||||
triggerUpperBound.Reset(0);
|
||||
triggerMode.Reset(static_cast<HALSIM_AnalogTriggerMode>(0));
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int32_t HALSIM_FindAnalogTriggerForChannel(int32_t channel) {
|
||||
for (int i = 0; i < kNumAnalogTriggers; ++i) {
|
||||
if (SimAnalogTriggerData[i].initialized &&
|
||||
SimAnalogTriggerData[i].inputPort == channel) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void HALSIM_ResetAnalogTriggerData(int32_t index) {
|
||||
SimAnalogTriggerData[index].ResetData();
|
||||
}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
||||
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, AnalogTrigger##CAPINAME, \
|
||||
SimAnalogTriggerData, LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, Initialized, initialized)
|
||||
DEFINE_CAPI(double, TriggerLowerBound, triggerLowerBound)
|
||||
DEFINE_CAPI(double, TriggerUpperBound, triggerUpperBound)
|
||||
DEFINE_CAPI(HALSIM_AnalogTriggerMode, TriggerMode, triggerMode)
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
SimAnalogTriggerData[index].NAME.RegisterCallback(callback, param, \
|
||||
initialNotify)
|
||||
|
||||
void HALSIM_RegisterAnalogTriggerAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify) {
|
||||
REGISTER(initialized);
|
||||
REGISTER(triggerLowerBound);
|
||||
REGISTER(triggerUpperBound);
|
||||
REGISTER(triggerMode);
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -1,36 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/simulation/AnalogTriggerData.h"
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
class AnalogTriggerData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(TriggerLowerBound)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(TriggerUpperBound)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(TriggerMode)
|
||||
|
||||
static LLVM_ATTRIBUTE_ALWAYS_INLINE HAL_Value
|
||||
MakeTriggerModeValue(HALSIM_AnalogTriggerMode value) {
|
||||
return HAL_MakeEnum(value);
|
||||
}
|
||||
|
||||
public:
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedName> initialized{0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetTriggerLowerBoundName>
|
||||
triggerLowerBound{0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetTriggerUpperBoundName>
|
||||
triggerUpperBound{0};
|
||||
SimDataValue<HALSIM_AnalogTriggerMode, MakeTriggerModeValue,
|
||||
GetTriggerModeName>
|
||||
triggerMode{static_cast<HALSIM_AnalogTriggerMode>(0)};
|
||||
std::atomic<int32_t> inputPort;
|
||||
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern AnalogTriggerData* SimAnalogTriggerData;
|
||||
} // namespace hal
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <hal/simulation/AddressableLEDData.h>
|
||||
#include <hal/simulation/AnalogInData.h>
|
||||
#include <hal/simulation/AnalogTriggerData.h>
|
||||
#include <hal/simulation/CTREPCMData.h>
|
||||
#include <hal/simulation/CanData.h>
|
||||
#include <hal/simulation/DIOData.h>
|
||||
@@ -30,10 +29,6 @@ extern "C" void HALSIM_ResetAllSimData(void) {
|
||||
HALSIM_ResetAnalogInData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumAnalogTriggers; i++) {
|
||||
HALSIM_ResetAnalogTriggerData(i);
|
||||
}
|
||||
|
||||
HALSIM_ResetCanData();
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumCTREPCMModules; i++) {
|
||||
|
||||
Reference in New Issue
Block a user