[hal] Notifier: simplify ack API (#8457)

Adding an ack parameter to both set and cancel is cleaner than adding
all the set alarm parameters to the ack function. It also provides an
ack-and-cancel method.
This commit is contained in:
Peter Johnson
2025-12-09 20:28:15 -07:00
committed by GitHub
parent 936be71a7d
commit 06a9a055b3
12 changed files with 111 additions and 177 deletions

View File

@@ -82,49 +82,45 @@ Java_org_wpilib_hardware_hal_NotifierJNI_destroyNotifier
/*
* Class: org_wpilib_hardware_hal_NotifierJNI
* Method: setNotifierAlarm
* Signature: (IJJZ)V
* Signature: (IJJZZ)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_NotifierJNI_setNotifierAlarm
(JNIEnv* env, jclass cls, jint notifierHandle, jlong alarmTime,
jlong intervalTime, jboolean absolute)
jlong intervalTime, jboolean absolute, jboolean ack)
{
int32_t status = 0;
HAL_SetNotifierAlarm((HAL_NotifierHandle)notifierHandle,
static_cast<uint64_t>(alarmTime),
static_cast<uint64_t>(intervalTime), absolute, &status);
HAL_SetNotifierAlarm(
(HAL_NotifierHandle)notifierHandle, static_cast<uint64_t>(alarmTime),
static_cast<uint64_t>(intervalTime), absolute, ack, &status);
CheckStatus(env, status);
}
/*
* Class: org_wpilib_hardware_hal_NotifierJNI
* Method: cancelNotifierAlarm
* Signature: (I)V
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_NotifierJNI_cancelNotifierAlarm
(JNIEnv* env, jclass cls, jint notifierHandle)
(JNIEnv* env, jclass cls, jint notifierHandle, jboolean ack)
{
int32_t status = 0;
HAL_CancelNotifierAlarm((HAL_NotifierHandle)notifierHandle, &status);
HAL_CancelNotifierAlarm((HAL_NotifierHandle)notifierHandle, ack, &status);
CheckStatus(env, status);
}
/*
* Class: org_wpilib_hardware_hal_NotifierJNI
* Method: acknowledgeNotifierAlarm
* Signature: (IZJJZ)V
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_NotifierJNI_acknowledgeNotifierAlarm
(JNIEnv* env, jclass cls, jint notifierHandle, jboolean setAlarm,
jlong alarmTime, jlong intervalTime, jboolean absolute)
(JNIEnv* env, jclass cls, jint notifierHandle)
{
int32_t status = 0;
HAL_AcknowledgeNotifierAlarm((HAL_NotifierHandle)notifierHandle, setAlarm,
static_cast<uint64_t>(alarmTime),
static_cast<uint64_t>(intervalTime), absolute,
&status);
HAL_AcknowledgeNotifierAlarm((HAL_NotifierHandle)notifierHandle, &status);
CheckStatus(env, status);
}