[wpilibj] Fix java async interrupts (#3559)

This commit is contained in:
Thad House
2021-09-11 09:21:02 -07:00
committed by GitHub
parent 5e6c34c61c
commit d8e0b6c977
4 changed files with 102 additions and 6 deletions

View File

@@ -121,16 +121,18 @@ static void ProcessInterruptDigitalSynchronous(const char* name, void* param,
return;
}
bool retVal = value->data.v_boolean;
auto previousState = interrupt->previousState;
interrupt->previousState = retVal;
// If no change in interrupt, return;
if (retVal == interrupt->previousState) {
if (retVal == previousState) {
return;
}
// If its a falling change, and we dont fire on falling return
if (interrupt->previousState && !interrupt->fireOnDown) {
if (previousState && !interrupt->fireOnDown) {
return;
}
// If its a rising change, and we dont fire on rising return.
if (!interrupt->previousState && !interrupt->fireOnUp) {
if (!previousState && !interrupt->fireOnUp) {
return;
}
@@ -174,16 +176,18 @@ static void ProcessInterruptAnalogSynchronous(const char* name, void* param,
// Pulse interrupt
interruptData->waitCond.notify_all();
}
auto previousState = interrupt->previousState;
interrupt->previousState = retVal;
// If no change in interrupt, return;
if (retVal == interrupt->previousState) {
if (retVal == previousState) {
return;
}
// If its a falling change, and we dont fire on falling return
if (interrupt->previousState && !interrupt->fireOnDown) {
if (previousState && !interrupt->fireOnDown) {
return;
}
// If its a rising change, and we dont fire on rising return.
if (!interrupt->previousState && !interrupt->fireOnUp) {
if (!previousState && !interrupt->fireOnUp) {
return;
}