mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal, wpilib] PWM Rewrite (#7845)
The HAL will only contain the output period and the raw microseconds. Higher level things such as SimDevice can handle everything else.
This commit is contained in:
@@ -190,21 +190,6 @@ Java_edu_wpi_first_hal_DIOJNI_isAnyPulsing
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_DIOJNI
|
||||
* Method: getLoopTiming
|
||||
* Signature: ()S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL
|
||||
Java_edu_wpi_first_hal_DIOJNI_getLoopTiming
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
int32_t status = 0;
|
||||
jshort returnValue = HAL_GetPWMLoopTiming(&status);
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_DIOJNI
|
||||
* Method: allocateDigitalPWM
|
||||
|
||||
@@ -44,7 +44,6 @@ static JException halHandleExCls;
|
||||
static JException uncleanStatusExCls;
|
||||
static JException nullPointerEx;
|
||||
static JClass powerDistributionVersionCls;
|
||||
static JClass pwmConfigDataResultCls;
|
||||
static JClass canStatusCls;
|
||||
static JClass matchInfoDataCls;
|
||||
static JClass canReceiveMessageCls;
|
||||
@@ -56,7 +55,6 @@ static JClass canStreamOverflowExCls;
|
||||
static const JClassInit classes[] = {
|
||||
{"edu/wpi/first/hal/PowerDistributionVersion",
|
||||
&powerDistributionVersionCls},
|
||||
{"edu/wpi/first/hal/PWMConfigDataResult", &pwmConfigDataResultCls},
|
||||
{"edu/wpi/first/hal/can/CANStatus", &canStatusCls},
|
||||
{"edu/wpi/first/hal/MatchInfoData", &matchInfoDataCls},
|
||||
{"edu/wpi/first/hal/can/CANReceiveMessage", &canReceiveMessageCls},
|
||||
@@ -180,17 +178,6 @@ void ThrowBoundaryException(JNIEnv* env, double value, double lower,
|
||||
env->Throw(static_cast<jthrowable>(ex));
|
||||
}
|
||||
|
||||
jobject CreatePWMConfigDataResult(JNIEnv* env, int32_t maxPwm,
|
||||
int32_t deadbandMaxPwm, int32_t centerPwm,
|
||||
int32_t deadbandMinPwm, int32_t minPwm) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(pwmConfigDataResultCls, "<init>", "(IIIII)V");
|
||||
return env->NewObject(
|
||||
pwmConfigDataResultCls, constructor, static_cast<jint>(maxPwm),
|
||||
static_cast<jint>(deadbandMaxPwm), static_cast<jint>(centerPwm),
|
||||
static_cast<jint>(deadbandMinPwm), static_cast<jint>(minPwm));
|
||||
}
|
||||
|
||||
jobject CreateREVPHVersion(JNIEnv* env, uint32_t firmwareMajor,
|
||||
uint32_t firmwareMinor, uint32_t firmwareFix,
|
||||
uint32_t hardwareMinor, uint32_t hardwareMajor,
|
||||
|
||||
@@ -49,10 +49,6 @@ void ThrowIllegalArgumentException(JNIEnv* env, std::string_view msg);
|
||||
void ThrowBoundaryException(JNIEnv* env, double value, double lower,
|
||||
double upper);
|
||||
|
||||
jobject CreatePWMConfigDataResult(JNIEnv* env, int32_t maxPwm,
|
||||
int32_t deadbandMaxPwm, int32_t centerPwm,
|
||||
int32_t deadbandMinPwm, int32_t minPwm);
|
||||
|
||||
jobject CreateREVPHVersion(JNIEnv* env, uint32_t firmwareMajor,
|
||||
uint32_t firmwareMinor, uint32_t firmwareFix,
|
||||
uint32_t hardwareMinor, uint32_t hardwareMajor,
|
||||
|
||||
@@ -63,69 +63,14 @@ Java_edu_wpi_first_hal_PWMJNI_freePWMPort
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: setPWMConfigMicroseconds
|
||||
* Signature: (IIIIII)V
|
||||
* Method: setPWMSimDevice
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMConfigMicroseconds
|
||||
(JNIEnv* env, jclass, jint id, jint maxPwm, jint deadbandMaxPwm,
|
||||
jint centerPwm, jint deadbandMinPwm, jint minPwm)
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMSimDevice
|
||||
(JNIEnv* env, jclass, jint handle, jint device)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMConfigMicroseconds((HAL_DigitalHandle)id, maxPwm, deadbandMaxPwm,
|
||||
centerPwm, deadbandMinPwm, minPwm, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: getPWMConfigMicroseconds
|
||||
* Signature: (I)Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_getPWMConfigMicroseconds
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
int32_t maxPwm = 0;
|
||||
int32_t deadbandMaxPwm = 0;
|
||||
int32_t centerPwm = 0;
|
||||
int32_t deadbandMinPwm = 0;
|
||||
int32_t minPwm = 0;
|
||||
HAL_GetPWMConfigMicroseconds((HAL_DigitalHandle)id, &maxPwm, &deadbandMaxPwm,
|
||||
¢erPwm, &deadbandMinPwm, &minPwm, &status);
|
||||
CheckStatus(env, status);
|
||||
return CreatePWMConfigDataResult(env, maxPwm, deadbandMaxPwm, centerPwm,
|
||||
deadbandMinPwm, minPwm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: setPWMEliminateDeadband
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMEliminateDeadband
|
||||
(JNIEnv* env, jclass, jint id, jboolean value)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMEliminateDeadband((HAL_DigitalHandle)id, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: getPWMEliminateDeadband
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_getPWMEliminateDeadband
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto val = HAL_GetPWMEliminateDeadband((HAL_DigitalHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
return (jboolean)val;
|
||||
HAL_SetPWMSimDevice((HAL_DigitalHandle)handle, (HAL_SimDeviceHandle)device);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -142,34 +87,6 @@ Java_edu_wpi_first_hal_PWMJNI_setPulseTimeMicroseconds
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: setPWMSpeed
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMSpeed
|
||||
(JNIEnv* env, jclass, jint id, jdouble value)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMSpeed((HAL_DigitalHandle)id, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: setPWMPosition
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMPosition
|
||||
(JNIEnv* env, jclass, jint id, jdouble value)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMPosition((HAL_DigitalHandle)id, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: getPulseTimeMicroseconds
|
||||
@@ -188,87 +105,15 @@ Java_edu_wpi_first_hal_PWMJNI_getPulseTimeMicroseconds
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: getPWMSpeed
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_getPWMSpeed
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
jdouble returnValue = HAL_GetPWMSpeed((HAL_DigitalHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: getPWMPosition
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_getPWMPosition
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
jdouble returnValue = HAL_GetPWMPosition((HAL_DigitalHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: setPWMDisabled
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMDisabled
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMDisabled((HAL_DigitalHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: latchPWMZero
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_latchPWMZero
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_LatchPWMZero((HAL_DigitalHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: setAlwaysHighMode
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_setAlwaysHighMode
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMAlwaysHighMode((HAL_DigitalHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PWMJNI
|
||||
* Method: setPWMPeriodScale
|
||||
* Method: setPWMOutputPeriod
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMPeriodScale
|
||||
Java_edu_wpi_first_hal_PWMJNI_setPWMOutputPeriod
|
||||
(JNIEnv* env, jclass, jint id, jint value)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMPeriodScale((HAL_DigitalHandle)id, value, &status);
|
||||
HAL_SetPWMOutputPeriod((HAL_DigitalHandle)id, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,201 +114,52 @@ Java_edu_wpi_first_hal_simulation_PWMDataJNI_setPulseMicrosecond
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerSpeedCallback
|
||||
* Method: registerOutputPeriodCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerSpeedCallback
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerOutputPeriodCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMSpeedCallback);
|
||||
&HALSIM_RegisterPWMOutputPeriodCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelSpeedCallback
|
||||
* Method: cancelOutputPeriodCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelSpeedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index, &HALSIM_CancelPWMSpeedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getSpeed
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getSpeed
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMSpeed(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setSpeed
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setSpeed
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetPWMSpeed(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerPositionCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerPositionCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMPositionCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelPositionCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelPositionCallback
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelOutputPeriodCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMPositionCallback);
|
||||
&HALSIM_CancelPWMOutputPeriodCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getPosition
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getPosition
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMPosition(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setPosition
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setPosition
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetPWMPosition(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerPeriodScaleCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerPeriodScaleCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMPeriodScaleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelPeriodScaleCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelPeriodScaleCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMPeriodScaleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getPeriodScale
|
||||
* Method: getOutputPeriod
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getPeriodScale
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getOutputPeriod
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMPeriodScale(index);
|
||||
return HALSIM_GetPWMOutputPeriod(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setPeriodScale
|
||||
* Method: setOutputPeriod
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setPeriodScale
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setOutputPeriod
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetPWMPeriodScale(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerZeroLatchCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerZeroLatchCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMZeroLatchCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelZeroLatchCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelZeroLatchCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMZeroLatchCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getZeroLatch
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getZeroLatch
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMZeroLatch(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setZeroLatch
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setZeroLatch
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPWMZeroLatch(index, value);
|
||||
HALSIM_SetPWMOutputPeriod(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user