diff --git a/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino b/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino index 8909ad2..8731fc5 100644 --- a/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino +++ b/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino @@ -20,7 +20,6 @@ * - Arduino Opta: press and hold the user button (BTN_USER) until the led (LED_USER) turns off * - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off * - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off - * - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off * - Nicla Vision: short the pin PA_13 to GND until the led turns off * - Portenta H7: short the pin 0 to GND until the led turns off * - Portenta C33: short the pin 0 to GND until the led turns off diff --git a/src/Arduino_NetworkConfigurator.cpp b/src/Arduino_NetworkConfigurator.cpp index f20485b..ea60b5d 100644 --- a/src/Arduino_NetworkConfigurator.cpp +++ b/src/Arduino_NetworkConfigurator.cpp @@ -117,7 +117,6 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() { * - Arduino Opta: press and hold the user button (BTN_USER) until the led (LED_USER) turns off * - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off * - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off - * - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off * - Nicla Vision: short the pin PA_13 to GND until the led turns off * - Portenta H7: short the pin 0 to GND until the led turns off * - Portenta C33: short the pin 0 to GND until the led turns off diff --git a/src/Arduino_NetworkConfigurator.h b/src/Arduino_NetworkConfigurator.h index 0b5c929..271e441 100644 --- a/src/Arduino_NetworkConfigurator.h +++ b/src/Arduino_NetworkConfigurator.h @@ -57,7 +57,6 @@ enum class NetworkConfiguratorStates { ZERO_TOUCH_CONFIG, * - Arduino Opta: press and hold the user button (BTN_USER) until the led (LED_USER) turns off * - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off * - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off - * - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off * - Nicla Vision: short the pin PA_13 to GND until the led turns off * - Portenta H7: short the pin 0 to GND until the led turns off * - Portenta C33: short the pin 0 to GND until the led turns off diff --git a/src/utility/ResetInput.cpp b/src/utility/ResetInput.cpp index 245b6d1..5fb20d5 100644 --- a/src/utility/ResetInput.cpp +++ b/src/utility/ResetInput.cpp @@ -49,6 +49,14 @@ ResetInput::ResetInput() { _pin = PIN_RECONFIGURE; #endif _ledFeedbackPin = LED_RECONFIGURE; + #if defined(ARDUINO_NANO_RP2040_CONNECT) + _ledOn = 1; + _ledOff = 0; + _lastEvent = 0; + #else + _ledOn = LED_ON; + _ledOff = LED_OFF; + #endif _expired = false; _startPressed = 0; _fireEvent = false; @@ -70,12 +78,15 @@ void ResetInput::begin() { if(_getPid_() != OPTA_WIFI_PID){ _ledFeedbackPin = GREEN_LED; } -#else +#elif !defined(ARDUINO_NANO_RP2040_CONNECT) pinMode(_pin, INPUT_PULLUP); #endif pinMode(_ledFeedbackPin, OUTPUT); - digitalWrite(_ledFeedbackPin, LED_OFF); + digitalWrite(_ledFeedbackPin, _ledOff); attachInterrupt(digitalPinToInterrupt(_pin),_pressedCallback, CHANGE); +#if defined(ARDUINO_NANO_RP2040_CONNECT) + pinMode(_pin, INPUT_PULLUP); +#endif } bool ResetInput::isEventFired() { @@ -84,7 +95,7 @@ bool ResetInput::isEventFired() { LEDFeedbackClass::getInstance().stop(); #endif if(micros() - _startPressed > RESET_HOLD_TIME){ - digitalWrite(_ledFeedbackPin, LED_OFF); + digitalWrite(_ledFeedbackPin, _ledOff); _expired = true; } } @@ -106,17 +117,20 @@ void ResetInput::setPin(int pin) { void ResetInput::_pressedCallback() { #if defined(ARDUINO_NANO_RP2040_CONNECT) - if(digitalRead(_pin) == HIGH){ -#else - if(digitalRead(_pin) == LOW){ + if(_lastEvent - micros() < 1000000){ + return; + } + _lastEvent = micros(); #endif + + if(digitalRead(_pin) == LOW){ #if !defined(ARDUINO_NANO_RP2040_CONNECT) && !defined(ARDUINO_SAMD_MKRWIFI1010) LEDFeedbackClass::getInstance().stop(); #endif _startPressed = micros(); - digitalWrite(_ledFeedbackPin, LED_ON); + digitalWrite(_ledFeedbackPin, _ledOn); } else { - digitalWrite(_ledFeedbackPin, LED_OFF); + digitalWrite(_ledFeedbackPin, _ledOff); if(_startPressed != 0 && _expired){ _fireEvent = true; }else{ diff --git a/src/utility/ResetInput.h b/src/utility/ResetInput.h index 320d220..1a372e3 100644 --- a/src/utility/ResetInput.h +++ b/src/utility/ResetInput.h @@ -66,9 +66,14 @@ class ResetInput{ static inline ResetInputCallback _pressedCustomCallback; static inline int _pin; static inline int _ledFeedbackPin; + static inline int _ledOff; + static inline int _ledOn; static inline volatile bool _expired; static inline volatile bool _fireEvent; static inline volatile uint32_t _startPressed; + #if defined(ARDUINO_NANO_RP2040_CONNECT) + static inline volatile uint32_t _lastEvent; + #endif /** * @brief Internal callback function to handle pin press events. */