mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[hal, wpilib] Remove built in accelerometer (#7702)
This commit is contained in:
@@ -1,55 +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 "AccelerometerDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeAccelerometerData() {
|
||||
static AccelerometerData sad[kAccelerometers];
|
||||
::hal::SimAccelerometerData = sad;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
AccelerometerData* hal::SimAccelerometerData;
|
||||
void AccelerometerData::ResetData() {
|
||||
active.Reset(false);
|
||||
range.Reset(static_cast<HAL_AccelerometerRange>(0));
|
||||
x.Reset(0.0);
|
||||
y.Reset(0.0);
|
||||
z.Reset(0.0);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetAccelerometerData(int32_t index) {
|
||||
SimAccelerometerData[index].ResetData();
|
||||
}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
||||
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, Accelerometer##CAPINAME, \
|
||||
SimAccelerometerData, LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, Active, active)
|
||||
DEFINE_CAPI(HAL_AccelerometerRange, Range, range)
|
||||
DEFINE_CAPI(double, X, x)
|
||||
DEFINE_CAPI(double, Y, y)
|
||||
DEFINE_CAPI(double, Z, z)
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
SimAccelerometerData[index].NAME.RegisterCallback(callback, param, \
|
||||
initialNotify)
|
||||
|
||||
void HALSIM_RegisterAccelerometerAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify) {
|
||||
REGISTER(active);
|
||||
REGISTER(range);
|
||||
REGISTER(x);
|
||||
REGISTER(y);
|
||||
REGISTER(z);
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -1,33 +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/AccelerometerData.h"
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
class AccelerometerData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Active)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Range)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(X)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Y)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Z)
|
||||
|
||||
static inline HAL_Value MakeRangeValue(HAL_AccelerometerRange value) {
|
||||
return HAL_MakeEnum(value);
|
||||
}
|
||||
|
||||
public:
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetActiveName> active{false};
|
||||
SimDataValue<HAL_AccelerometerRange, MakeRangeValue, GetRangeName> range{
|
||||
static_cast<HAL_AccelerometerRange>(0)};
|
||||
SimDataValue<double, HAL_MakeDouble, GetXName> x{0.0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetYName> y{0.0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetZName> z{0.0};
|
||||
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern AccelerometerData* SimAccelerometerData;
|
||||
} // namespace hal
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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/simulation/AccelerometerData.h>
|
||||
#include <hal/simulation/AddressableLEDData.h>
|
||||
#include <hal/simulation/AnalogInData.h>
|
||||
#include <hal/simulation/AnalogTriggerData.h>
|
||||
@@ -23,10 +22,6 @@
|
||||
#include "../PortsInternal.h"
|
||||
|
||||
extern "C" void HALSIM_ResetAllSimData(void) {
|
||||
for (int32_t i = 0; i < hal::kAccelerometers; i++) {
|
||||
HALSIM_ResetAccelerometerData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumAddressableLEDs; i++) {
|
||||
HALSIM_ResetAddressableLEDData(i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user