21 #include "../../include/esp3d_config.h"
22 #ifdef RECOVERY_FEATURE
24 #include "../../core/settings_esp3d.h"
25 #include "../../core/esp3doutput.h"
28 #ifdef PIN_RESET_FEATURE
29 #include "../../core/esp3d.h"
30 volatile bool interruptswitch =
false;
31 #ifdef ARDUINO_ARCH_ESP32
32 portMUX_TYPE espmux = portMUX_INITIALIZER_UNLOCKED;
33 #endif //ARDUINO_ARCH_ESP32
35 #ifdef ARDUINO_ARCH_ESP8266
36 void handlePinResetInterrupt()
38 #endif //ARDUINO_ARCH_ESP8266
39 #ifdef ARDUINO_ARCH_ESP32
40 void IRAM_ATTR handlePinResetInterrupt() {
41 portENTER_CRITICAL_ISR(&espmux);
42 #endif //ARDUINO_ARCH_ESP32
43 interruptswitch =
true;
44 #ifdef ARDUINO_ARCH_ESP32
45 portEXIT_CRITICAL_ISR(&espmux);
46 #endif //ARDUINO_ARCH_ESP32
48 #endif //PIN_RESET_FEATURE
60 #ifdef PIN_RESET_FEATURE
61 pinMode(ESP3D_RESET_PIN, INPUT_PULLUP);
62 attachInterrupt(digitalPinToInterrupt(ESP3D_RESET_PIN), handlePinResetInterrupt, FALLING);
63 #endif //PIN_RESET_FEATURE
76 #ifdef PIN_RESET_FEATURE
77 detachInterrupt(digitalPinToInterrupt(ESP3D_RESET_PIN));
78 #endif //PIN_RESET_FEATURE
89 #ifdef PIN_RESET_FEATURE
90 if (interruptswitch) {
91 static uint32_t lastreset = 0;
92 interruptswitch =
false;
93 if ((millis() - lastreset) > 1000) {
96 output.printMSG(
"Reset requested");
100 #endif //PIN_RESET_FEATURE
104 #endif //RECOVERY_FEATURE