@@ -447,13 +447,32 @@ public static void releasePin(int pin) {
447447 * Waits for the value of an input pin to change
448448 * @param pin GPIO pin
449449 * @param mode what to wait for: GPIO.CHANGE, GPIO.FALLING or GPIO.RISING
450- * @param timeout don't wait more than timeout milliseconds (-1 waits indefinitely)
451- * @return true if the interrupt occured, false if the timeout occured
452450 * @webref
453451 */
454- public static boolean waitForInterrupt (int pin , int mode , int timeout ) {
452+ public static void waitFor (int pin , int mode ) {
453+ waitForInterrupt (pin , mode , -1 );
454+ }
455+
456+
457+ /**
458+ * Waits for the value of an input pin to change
459+ *
460+ * This function will throw a RuntimeException in case of a timeout.
461+ * @param pin GPIO pin
462+ * @param mode what to wait for: GPIO.CHANGE, GPIO.FALLING or GPIO.RISING
463+ * @param timeout don't wait more than timeout milliseconds
464+ * @webref
465+ */
466+ public static void waitFor (int pin , int mode , int timeout ) {
455467 enableInterrupt (pin , mode );
456- return waitForInterrupt (pin , timeout );
468+ if (waitForInterrupt (pin , timeout ) == false ) {
469+ throw new RuntimeException ("Timeout occurred" );
470+ }
471+ }
472+
473+
474+ public static boolean waitForInterrupt (int pin , int mode , int timeout ) {
475+ throw new RuntimeException ("The waitForInterrupt function has been renamed to waitFor. Please update your sketch accordingly." );
457476 }
458477
459478
0 commit comments