Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Arduino_NetworkConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Arduino_NetworkConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 22 additions & 8 deletions src/utility/ResetInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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;
}
}
Expand All @@ -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{
Expand Down
5 changes: 5 additions & 0 deletions src/utility/ResetInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Loading