Move the button check at start of the program (#1330)
So as to enable to trigger the wm portal before the setup of all the modules
This commit is contained in:
1 parent
74a8698117
commit
3e9fbb21ff
2 files changed
+7
-6
No files matched your search
@@ -11,6 +11,8 @@ On M5Stack boards you may do a long press to these buttons in low power mode 0 (
|
|||||||
* Button C on M5Stack (GPIO 37)
|
* Button C on M5Stack (GPIO 37)
|
||||||
* Button lateral on M5stick (GPIO 35)
|
* Button lateral on M5stick (GPIO 35)
|
||||||
|
|
||||||
|
You can also do a long press when powering the board so as to reset it.
|
||||||
|
|
||||||
### Low power mode for ESP32
|
### Low power mode for ESP32
|
||||||
OpenMQTTGateway support a low power mode for ESP32, this mode can be set by MQTT:
|
OpenMQTTGateway support a low power mode for ESP32, this mode can be set by MQTT:
|
||||||
|
|
||||||
|
|||||||
+5
-6
@@ -631,7 +631,10 @@ void setup() {
|
|||||||
Serial.begin(SERIAL_BAUD);
|
Serial.begin(SERIAL_BAUD);
|
||||||
Log.begin(LOG_LEVEL, &Serial);
|
Log.begin(LOG_LEVEL, &Serial);
|
||||||
Log.notice(F(CR "************* WELCOME TO OpenMQTTGateway **************" CR));
|
Log.notice(F(CR "************* WELCOME TO OpenMQTTGateway **************" CR));
|
||||||
|
#if defined(TRIGGER_GPIO) && !defined(ESPWifiManualSetup)
|
||||||
|
pinMode(TRIGGER_GPIO, INPUT_PULLUP);
|
||||||
|
checkButton();
|
||||||
|
#endif
|
||||||
//setup LED status
|
//setup LED status
|
||||||
SetupIndicators();
|
SetupIndicators();
|
||||||
|
|
||||||
@@ -1058,7 +1061,7 @@ void saveConfigCallback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ifdef TRIGGER_GPIO
|
# ifdef TRIGGER_GPIO
|
||||||
void checkButton() { // code from tzapu/wifimanager examples
|
void checkButton() { // Check if button is pressed so as to reset the credentials and parameters stored into the flash, code from tzapu/wifimanager examples
|
||||||
# if defined(INPUT_GPIO) && defined(ZsensorGPIOInput) && INPUT_GPIO == TRIGGER_GPIO
|
# if defined(INPUT_GPIO) && defined(ZsensorGPIOInput) && INPUT_GPIO == TRIGGER_GPIO
|
||||||
MeasureGPIOInput();
|
MeasureGPIOInput();
|
||||||
# else
|
# else
|
||||||
@@ -1068,7 +1071,6 @@ void checkButton() { // code from tzapu/wifimanager examples
|
|||||||
delay(50);
|
delay(50);
|
||||||
if (digitalRead(TRIGGER_GPIO) == LOW) {
|
if (digitalRead(TRIGGER_GPIO) == LOW) {
|
||||||
Log.trace(F("Trigger button Pressed" CR));
|
Log.trace(F("Trigger button Pressed" CR));
|
||||||
// still holding button for 3000 ms, reset settings, code not ideaa for production
|
|
||||||
delay(3000); // reset delay hold
|
delay(3000); // reset delay hold
|
||||||
if (digitalRead(TRIGGER_GPIO) == LOW) {
|
if (digitalRead(TRIGGER_GPIO) == LOW) {
|
||||||
Log.trace(F("Button Held" CR));
|
Log.trace(F("Button Held" CR));
|
||||||
@@ -1122,9 +1124,6 @@ void saveMqttConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup_wifimanager(bool reset_settings) {
|
void setup_wifimanager(bool reset_settings) {
|
||||||
# ifdef TRIGGER_GPIO
|
|
||||||
pinMode(TRIGGER_GPIO, INPUT_PULLUP);
|
|
||||||
# endif
|
|
||||||
delay(10);
|
delay(10);
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user