mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[hal, wpilib] Remove built in accelerometer (#7702)
This commit is contained in:
@@ -1,72 +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 <jni.h>
|
||||
|
||||
#include "edu_wpi_first_hal_AccelerometerJNI.h"
|
||||
#include "hal/Accelerometer.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AccelerometerJNI
|
||||
* Method: setAccelerometerActive
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_AccelerometerJNI_setAccelerometerActive
|
||||
(JNIEnv*, jclass, jboolean active)
|
||||
{
|
||||
HAL_SetAccelerometerActive(active);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AccelerometerJNI
|
||||
* Method: setAccelerometerRange
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_AccelerometerJNI_setAccelerometerRange
|
||||
(JNIEnv*, jclass, jint range)
|
||||
{
|
||||
HAL_SetAccelerometerRange((HAL_AccelerometerRange)range);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AccelerometerJNI
|
||||
* Method: getAccelerometerX
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_AccelerometerJNI_getAccelerometerX
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HAL_GetAccelerometerX();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AccelerometerJNI
|
||||
* Method: getAccelerometerY
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_AccelerometerJNI_getAccelerometerY
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HAL_GetAccelerometerY();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AccelerometerJNI
|
||||
* Method: getAccelerometerZ
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_AccelerometerJNI_getAccelerometerZ
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HAL_GetAccelerometerZ();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -1,278 +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 <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_AccelerometerDataJNI.h"
|
||||
#include "hal/simulation/AccelerometerData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerActiveCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerActiveCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerActiveCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelActiveCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelActiveCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerActiveCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getActive
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getActive
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerActive(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setActive
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setActive
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAccelerometerActive(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerRangeCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerRangeCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerRangeCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelRangeCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelRangeCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerRangeCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getRange
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getRange
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerRange(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setRange
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setRange
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAccelerometerRange(index,
|
||||
static_cast<HAL_AccelerometerRange>(value));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerXCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerXCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerXCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelXCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelXCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerXCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getX
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getX
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerX(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setX
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setX
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAccelerometerX(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerYCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerYCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerYCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelYCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelYCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerYCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getY
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getY
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerY(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setY
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setY
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAccelerometerY(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerZCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerZCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerZCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelZCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelZCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerZCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getZ
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getZ
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerZ(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setZ
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setZ
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAccelerometerZ(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAccelerometerData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -1,74 +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/Types.h"
|
||||
|
||||
/**
|
||||
* @defgroup hal_accelerometer Accelerometer Functions
|
||||
* @ingroup hal_capi
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The acceptable accelerometer ranges.
|
||||
*/
|
||||
HAL_ENUM(HAL_AccelerometerRange) {
|
||||
HAL_AccelerometerRange_k2G = 0,
|
||||
HAL_AccelerometerRange_k4G = 1,
|
||||
HAL_AccelerometerRange_k8G = 2,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* Sets the accelerometer to active or standby mode.
|
||||
*
|
||||
* It must be in standby mode to change any configuration.
|
||||
*
|
||||
* @param active true to set to active, false for standby
|
||||
*/
|
||||
void HAL_SetAccelerometerActive(HAL_Bool active);
|
||||
|
||||
/**
|
||||
* Sets the range of values that can be measured (either 2, 4, or 8 g-forces).
|
||||
*
|
||||
* The accelerometer should be in standby mode when this is called.
|
||||
*
|
||||
* @param range the accelerometer range
|
||||
*/
|
||||
void HAL_SetAccelerometerRange(HAL_AccelerometerRange range);
|
||||
|
||||
/**
|
||||
* Gets the x-axis acceleration.
|
||||
*
|
||||
* This is a floating point value in units of 1 g-force.
|
||||
*
|
||||
* @return the X acceleration
|
||||
*/
|
||||
double HAL_GetAccelerometerX(void);
|
||||
|
||||
/**
|
||||
* Gets the y-axis acceleration.
|
||||
*
|
||||
* This is a floating point value in units of 1 g-force.
|
||||
*
|
||||
* @return the Y acceleration
|
||||
*/
|
||||
double HAL_GetAccelerometerY(void);
|
||||
|
||||
/**
|
||||
* Gets the z-axis acceleration.
|
||||
*
|
||||
* This is a floating point value in units of 1 g-force.
|
||||
*
|
||||
* @return the Z acceleration
|
||||
*/
|
||||
double HAL_GetAccelerometerZ(void);
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/Accelerometer.h"
|
||||
#include "hal/AnalogInput.h"
|
||||
#include "hal/AnalogTrigger.h"
|
||||
#include "hal/CAN.h"
|
||||
|
||||
@@ -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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/Accelerometer.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HALSIM_ResetAccelerometerData(int32_t index);
|
||||
int32_t HALSIM_RegisterAccelerometerActiveCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelAccelerometerActiveCallback(int32_t index, int32_t uid);
|
||||
HAL_Bool HALSIM_GetAccelerometerActive(int32_t index);
|
||||
void HALSIM_SetAccelerometerActive(int32_t index, HAL_Bool active);
|
||||
|
||||
int32_t HALSIM_RegisterAccelerometerRangeCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelAccelerometerRangeCallback(int32_t index, int32_t uid);
|
||||
HAL_AccelerometerRange HALSIM_GetAccelerometerRange(int32_t index);
|
||||
void HALSIM_SetAccelerometerRange(int32_t index, HAL_AccelerometerRange range);
|
||||
|
||||
int32_t HALSIM_RegisterAccelerometerXCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelAccelerometerXCallback(int32_t index, int32_t uid);
|
||||
double HALSIM_GetAccelerometerX(int32_t index);
|
||||
void HALSIM_SetAccelerometerX(int32_t index, double x);
|
||||
|
||||
int32_t HALSIM_RegisterAccelerometerYCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelAccelerometerYCallback(int32_t index, int32_t uid);
|
||||
double HALSIM_GetAccelerometerY(int32_t index);
|
||||
void HALSIM_SetAccelerometerY(int32_t index, double y);
|
||||
|
||||
int32_t HALSIM_RegisterAccelerometerZCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelAccelerometerZCallback(int32_t index, int32_t uid);
|
||||
double HALSIM_GetAccelerometerZ(int32_t index);
|
||||
void HALSIM_SetAccelerometerZ(int32_t index, double z);
|
||||
|
||||
void HALSIM_RegisterAccelerometerAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1,32 +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 "hal/Accelerometer.h"
|
||||
|
||||
#include "mockdata/AccelerometerDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeAccelerometer() {}
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
void HAL_SetAccelerometerActive(HAL_Bool active) {
|
||||
SimAccelerometerData[0].active = active;
|
||||
}
|
||||
|
||||
void HAL_SetAccelerometerRange(HAL_AccelerometerRange range) {
|
||||
SimAccelerometerData[0].range = range;
|
||||
}
|
||||
double HAL_GetAccelerometerX(void) {
|
||||
return SimAccelerometerData[0].x;
|
||||
}
|
||||
double HAL_GetAccelerometerY(void) {
|
||||
return SimAccelerometerData[0].y;
|
||||
}
|
||||
double HAL_GetAccelerometerZ(void) {
|
||||
return SimAccelerometerData[0].z;
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -66,7 +66,6 @@ void InitializeDriverStation();
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeHAL() {
|
||||
InitializeAccelerometerData();
|
||||
InitializeAddressableLEDData();
|
||||
InitializeAnalogInData();
|
||||
InitializeAnalogTriggerData();
|
||||
@@ -84,7 +83,6 @@ void InitializeHAL() {
|
||||
InitializePWMData();
|
||||
InitializeRoboRioData();
|
||||
InitializeSimDeviceData();
|
||||
InitializeAccelerometer();
|
||||
InitializeAddressableLED();
|
||||
InitializeAnalogInput();
|
||||
InitializeAnalogInternal();
|
||||
|
||||
@@ -16,7 +16,6 @@ inline void CheckInit() {
|
||||
RunInitialize();
|
||||
}
|
||||
|
||||
extern void InitializeAccelerometerData();
|
||||
extern void InitializeAddressableLEDData();
|
||||
extern void InitializeAnalogInData();
|
||||
extern void InitializeAnalogTriggerData();
|
||||
@@ -35,7 +34,6 @@ extern void InitializePowerDistributionData();
|
||||
extern void InitializePWMData();
|
||||
extern void InitializeRoboRioData();
|
||||
extern void InitializeSimDeviceData();
|
||||
extern void InitializeAccelerometer();
|
||||
extern void InitializeAddressableLED();
|
||||
extern void InitializeAnalogInput();
|
||||
extern void InitializeAnalogInternal();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,58 +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 "hal/Accelerometer.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "hal/HAL.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeAccelerometer() {}
|
||||
} // namespace hal::init
|
||||
|
||||
namespace hal {
|
||||
|
||||
/**
|
||||
* Initialize the accelerometer.
|
||||
*/
|
||||
static void initializeAccelerometer() {
|
||||
hal::init::CheckInit();
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
|
||||
extern "C" {
|
||||
|
||||
void HAL_SetAccelerometerActive(HAL_Bool active) {
|
||||
initializeAccelerometer();
|
||||
}
|
||||
|
||||
void HAL_SetAccelerometerRange(HAL_AccelerometerRange range) {
|
||||
initializeAccelerometer();
|
||||
}
|
||||
|
||||
double HAL_GetAccelerometerX(void) {
|
||||
initializeAccelerometer();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double HAL_GetAccelerometerY(void) {
|
||||
initializeAccelerometer();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double HAL_GetAccelerometerZ(void) {
|
||||
initializeAccelerometer();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -49,7 +49,6 @@ void InitializeHAL() {
|
||||
InitializeCTREPCM();
|
||||
InitializeREVPH();
|
||||
InitializeAddressableLED();
|
||||
InitializeAccelerometer();
|
||||
InitializeAnalogInput();
|
||||
InitializeAnalogTrigger();
|
||||
InitializeCAN();
|
||||
|
||||
@@ -18,7 +18,6 @@ inline void CheckInit() {
|
||||
|
||||
extern void InitializeCTREPCM();
|
||||
extern void InitializeREVPH();
|
||||
extern void InitializeAccelerometer();
|
||||
extern void InitializeAddressableLED();
|
||||
extern void InitializeAnalogInput();
|
||||
extern void InitializeAnalogInternal();
|
||||
|
||||
@@ -1,25 +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 "hal/simulation/AccelerometerData.h"
|
||||
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetAccelerometerData(int32_t index) {}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \
|
||||
HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, Accelerometer##CAPINAME, RETURN)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, Active, false)
|
||||
DEFINE_CAPI(HAL_AccelerometerRange, Range, HAL_AccelerometerRange_k2G)
|
||||
DEFINE_CAPI(double, X, 0)
|
||||
DEFINE_CAPI(double, Y, 0)
|
||||
DEFINE_CAPI(double, Z, 0)
|
||||
|
||||
void HALSIM_RegisterAccelerometerAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify) {}
|
||||
} // extern "C"
|
||||
Reference in New Issue
Block a user