Move from button to gpio

This commit is contained in:
fvanroie 2020-05-02 00:19:29 +02:00
parent 81ad865456
commit ec37e3d72a

View File

@ -1,12 +1,11 @@
#include "hasp_conf.h" // load first #include "hasp_conf.h" // load first
#include <Arduino.h> #include <Arduino.h>
#include "hasp_conf.h"
#include "hasp_debug.h" #include "hasp_debug.h"
#include "hasp_spiffs.h"
#include "hasp_config.h" #include "hasp_config.h"
#include "hasp_gui.h" #include "hasp_gui.h"
#include "hasp.h" #include "hasp.h"
#include "hasp_conf.h"
#include "hasp_oobe.h" #include "hasp_oobe.h"
#include "hasp_gpio.h" #include "hasp_gpio.h"
@ -23,7 +22,7 @@ void setup()
/* Init Storage */ /* Init Storage */
#if HASP_USE_EEPROM #if HASP_USE_EEPROM
// eepromSetup(); // Don't start at boot, only at write eepromSetup(); // Don't start at boot, only at write
#endif #endif
#if HASP_USE_SPIFFS #if HASP_USE_SPIFFS
@ -44,7 +43,10 @@ void setup()
***************************/ ***************************/
debugSetup(); debugSetup();
gpioSetup(); gpioSetup();
#if HASP_USE_GPIO
guiSetup(); guiSetup();
#endif
#if HASP_USE_WIFI #if HASP_USE_WIFI
wifiSetup(); wifiSetup();
@ -76,10 +78,6 @@ void setup()
#endif // WIFI #endif // WIFI
#if HASP_USE_BUTTON
buttonSetup();
#endif
#if HASP_USE_TASMOTA_SLAVE #if HASP_USE_TASMOTA_SLAVE
slaveSetup(); slaveSetup();
#endif #endif
@ -90,15 +88,21 @@ void setup()
void loop() void loop()
{ {
/* Storage Loops */ /* Storage Loops */
/*
#if HASP_USE_EEPROM #if HASP_USE_EEPROM
eepromLoop(); // eepromLoop(); // Not used
#endif
// spiffsLoop();
#if HASP_USE_SDCARD
// sdcardLoop();
#endif #endif
// configLoop(); #if HASP_USE_SPIFFS
// spiffsLoop(); // Not used
#endif
#if HASP_USE_SDCARD
// sdcardLoop(); // Not used
#endif
// configLoop(); // Not used
*/
/* Graphics Loops */ /* Graphics Loops */
// tftLoop(); // tftLoop();
@ -107,6 +111,10 @@ void loop()
/* Application Loops */ /* Application Loops */
// haspLoop(); // haspLoop();
#if HASP_USE_GPIO
gpioLoop();
#endif
/* Network Services Loops */ /* Network Services Loops */
#if HASP_USE_WIFI #if HASP_USE_WIFI
@ -126,10 +134,6 @@ void loop()
mdnsLoop(); mdnsLoop();
#endif // MDNS #endif // MDNS
#if HASP_USE_BUTTON
buttonLoop();
#endif // BUTTON
#if HASP_USE_OTA #if HASP_USE_OTA
otaLoop(); otaLoop();
#endif // OTA #endif // OTA
@ -140,7 +144,9 @@ void loop()
slaveLoop(); slaveLoop();
#endif // TASMOTASLAVE #endif // TASMOTASLAVE
// Every Second Loop // digitalWrite(HASP_OUTPUT_PIN, digitalRead(HASP_INPUT_PIN)); // sets the LED to the button's value
/* Timer Loop */
if(millis() - mainLastLoopTime >= 1000) { if(millis() - mainLastLoopTime >= 1000) {
/* Run Every Second */ /* Run Every Second */
#if HASP_USE_OTA #if HASP_USE_OTA
@ -149,27 +155,25 @@ void loop()
debugEverySecond(); debugEverySecond();
/* Run Every 5 Seconds */ /* Run Every 5 Seconds */
if(mainLoopCounter == 0 || mainLoopCounter == 4) { #if HASP_USE_WIFI
if(mainLoopCounter == 0 || mainLoopCounter == 5) {
isConnected = wifiEvery5Seconds();
#if HASP_USE_HTTP #if HASP_USE_HTTP
httpEvery5Seconds(); httpEvery5Seconds();
#endif #endif
#if HASP_USE_WIFI
isConnected = wifiEvery5Seconds();
#if HASP_USE_MQTT #if HASP_USE_MQTT
mqttEvery5Seconds(isConnected); mqttEvery5Seconds(isConnected);
#endif
#endif #endif
} }
#endif // Wifi
/* Update counters */ /* Reset loop counter every 10 seconds */
if(mainLoopCounter >= 9) {
mainLoopCounter = 0;
} else {
mainLoopCounter++;
}
mainLastLoopTime += 1000; mainLastLoopTime += 1000;
mainLoopCounter++;
if(mainLoopCounter >= 10) {
mainLoopCounter = 0;
}
} }
delay(3); delay(3);