mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[hal, wpilib] Remove digital source from encoder (#7740)
This commit is contained in:
@@ -18,21 +18,17 @@ extern "C" {
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_EncoderJNI
|
||||
* Method: initializeEncoder
|
||||
* Signature: (IIIIZI)I
|
||||
* Signature: (IIZI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_EncoderJNI_initializeEncoder
|
||||
(JNIEnv* env, jclass, jint digitalSourceHandleA, jint analogTriggerTypeA,
|
||||
jint digitalSourceHandleB, jint analogTriggerTypeB,
|
||||
jboolean reverseDirection, jint encodingType)
|
||||
(JNIEnv* env, jclass, jint aChannel, jint bChannel, jboolean reverseDirection,
|
||||
jint encodingType)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto encoder = HAL_InitializeEncoder(
|
||||
(HAL_Handle)digitalSourceHandleA,
|
||||
(HAL_AnalogTriggerType)analogTriggerTypeA,
|
||||
(HAL_Handle)digitalSourceHandleB,
|
||||
(HAL_AnalogTriggerType)analogTriggerTypeB, reverseDirection,
|
||||
(HAL_EncoderEncodingType)encodingType, &status);
|
||||
auto encoder =
|
||||
HAL_InitializeEncoder(aChannel, bChannel, reverseDirection,
|
||||
(HAL_EncoderEncodingType)encodingType, &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jint)encoder;
|
||||
}
|
||||
@@ -286,24 +282,6 @@ Java_edu_wpi_first_hal_EncoderJNI_getEncoderSamplesToAverage
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_EncoderJNI
|
||||
* Method: setEncoderIndexSource
|
||||
* Signature: (IIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_EncoderJNI_setEncoderIndexSource
|
||||
(JNIEnv* env, jclass, jint id, jint digitalSourceHandle,
|
||||
jint analogTriggerType, jint type)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderIndexSource((HAL_EncoderHandle)id,
|
||||
(HAL_Handle)digitalSourceHandle,
|
||||
(HAL_AnalogTriggerType)analogTriggerType,
|
||||
(HAL_EncoderIndexingType)type, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_EncoderJNI
|
||||
* Method: getEncoderFPGAIndex
|
||||
|
||||
@@ -41,25 +41,18 @@ extern "C" {
|
||||
/**
|
||||
* Initializes an encoder.
|
||||
*
|
||||
* @param[in] digitalSourceHandleA the A source (either a HAL_DigitalHandle or a
|
||||
* HAL_AnalogTriggerHandle)
|
||||
* @param[in] analogTriggerTypeA the analog trigger type of the A source if it
|
||||
* is an analog trigger
|
||||
* @param[in] digitalSourceHandleB the B source (either a HAL_DigitalHandle or a
|
||||
* HAL_AnalogTriggerHandle)
|
||||
* @param[in] analogTriggerTypeB the analog trigger type of the B source if it
|
||||
* is an analog trigger
|
||||
* @param[in] aChannel the A channel
|
||||
* @param[in] bChannel the B channel
|
||||
* @param[in] reverseDirection true to reverse the counting direction from
|
||||
* standard, otherwise false
|
||||
* @param[in] encodingType the encoding type
|
||||
* @param[out] status Error status variable. 0 on success.
|
||||
* @return the created encoder handle
|
||||
*/
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(
|
||||
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,
|
||||
HAL_Handle digitalSourceHandleB, HAL_AnalogTriggerType analogTriggerTypeB,
|
||||
HAL_Bool reverseDirection, HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status);
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
|
||||
HAL_Bool reverseDirection,
|
||||
HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status);
|
||||
|
||||
/**
|
||||
* Frees an encoder.
|
||||
@@ -260,26 +253,6 @@ void HAL_SetEncoderSamplesToAverage(HAL_EncoderHandle encoderHandle,
|
||||
int32_t HAL_GetEncoderSamplesToAverage(HAL_EncoderHandle encoderHandle,
|
||||
int32_t* status);
|
||||
|
||||
/**
|
||||
* Sets the source for an index pulse on the encoder.
|
||||
*
|
||||
* The index pulse can be used to cause an encoder to reset based on an external
|
||||
* input.
|
||||
*
|
||||
* @param[in] encoderHandle the encoder handle
|
||||
* @param[in] digitalSourceHandle the index source handle (either a
|
||||
* HAL_AnalogTriggerHandle or a
|
||||
* HAL_DigitalHandle)
|
||||
* @param[in] analogTriggerType the analog trigger type if the source is an
|
||||
* analog trigger
|
||||
* @param[in] type the index triggering type
|
||||
* @param[out] status Error status variable. 0 on success.
|
||||
*/
|
||||
void HAL_SetEncoderIndexSource(HAL_EncoderHandle encoderHandle,
|
||||
HAL_Handle digitalSourceHandle,
|
||||
HAL_AnalogTriggerType analogTriggerType,
|
||||
HAL_EncoderIndexingType type, int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets the FPGA index of the encoder.
|
||||
*
|
||||
|
||||
@@ -66,11 +66,10 @@ bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
|
||||
} // namespace hal
|
||||
|
||||
extern "C" {
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(
|
||||
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,
|
||||
HAL_Handle digitalSourceHandleB, HAL_AnalogTriggerType analogTriggerTypeB,
|
||||
HAL_Bool reverseDirection, HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status) {
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
|
||||
HAL_Bool reverseDirection,
|
||||
HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
HAL_Handle nativeHandle = HAL_kInvalidHandle;
|
||||
if (encodingType == HAL_EncoderEncodingType::HAL_Encoder_k4X) {
|
||||
@@ -95,8 +94,8 @@ HAL_EncoderHandle HAL_InitializeEncoder(
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
int16_t index = getHandleIndex(handle);
|
||||
SimEncoderData[index].digitalChannelA = getHandleIndex(digitalSourceHandleA);
|
||||
SimEncoderData[index].digitalChannelB = getHandleIndex(digitalSourceHandleB);
|
||||
SimEncoderData[index].digitalChannelA = aChannel;
|
||||
SimEncoderData[index].digitalChannelB = bChannel;
|
||||
SimEncoderData[index].initialized = true;
|
||||
SimEncoderData[index].reverseDirection = reverseDirection;
|
||||
SimEncoderData[index].simDevice = 0;
|
||||
@@ -328,13 +327,6 @@ int32_t HAL_GetEncoderSamplesToAverage(HAL_EncoderHandle encoderHandle,
|
||||
return SimEncoderData[encoder->index].samplesToAverage;
|
||||
}
|
||||
|
||||
void HAL_SetEncoderIndexSource(HAL_EncoderHandle encoderHandle,
|
||||
HAL_Handle digitalSourceHandle,
|
||||
HAL_AnalogTriggerType analogTriggerType,
|
||||
HAL_EncoderIndexingType type, int32_t* status) {
|
||||
// Not implemented yet
|
||||
}
|
||||
|
||||
int32_t HAL_GetEncoderFPGAIndex(HAL_EncoderHandle encoderHandle,
|
||||
int32_t* status) {
|
||||
auto encoder = encoderHandles->Get(encoderHandle);
|
||||
|
||||
@@ -17,25 +17,15 @@
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal {
|
||||
|
||||
namespace init {
|
||||
namespace hal::init {
|
||||
void InitializeEncoder() {}
|
||||
} // namespace init
|
||||
|
||||
bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
|
||||
HAL_FPGAEncoderHandle* fpgaHandle,
|
||||
HAL_CounterHandle* counterHandle) {
|
||||
return false;
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(
|
||||
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,
|
||||
HAL_Handle digitalSourceHandleB, HAL_AnalogTriggerType analogTriggerTypeB,
|
||||
HAL_Bool reverseDirection, HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status) {
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
|
||||
HAL_Bool reverseDirection,
|
||||
HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return HAL_kInvalidHandle;
|
||||
@@ -150,14 +140,6 @@ HAL_EncoderEncodingType HAL_GetEncoderEncodingType(
|
||||
return HAL_Encoder_k4X;
|
||||
}
|
||||
|
||||
void HAL_SetEncoderIndexSource(HAL_EncoderHandle encoderHandle,
|
||||
HAL_Handle digitalSourceHandle,
|
||||
HAL_AnalogTriggerType analogTriggerType,
|
||||
HAL_EncoderIndexingType type, int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t HAL_GetEncoderFPGAIndex(HAL_EncoderHandle encoderHandle,
|
||||
int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user