diff --git a/include/hasp_macro.h b/include/hasp_macro.h index 9c60218e..afa22ae3 100644 --- a/include/hasp_macro.h +++ b/include/hasp_macro.h @@ -4,6 +4,11 @@ #if defined(WINDOWS) || defined(POSIX) #define LOG_OUTPUT(x, ...) printf(__VA_ARGS__) #else + +#ifndef HASP_LOG_LEVEL +#define HASP_LOG_LEVEL LOG_LEVEL_TRACE +#endif + #define LOG_OUTPUT(...) Log.output(...) #if HASP_LOG_LEVEL >= LOG_LEVEL_FATAL diff --git a/platformio.ini b/platformio.ini index 6c8ba0b6..809fe00a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -61,7 +61,6 @@ build_flags = -D HASP_VER_MAJ=0 -D HASP_VER_MIN=6 -D HASP_VER_REV=0 - -D HASP_LOG_LEVEL=LOG_LEVEL_OUTPUT ${override.build_flags} ; -- Shared library dependencies in all environments diff --git a/src/drv/old/hasp_drv_tft_espi.cpp b/src/drv/old/hasp_drv_tft_espi.cpp index d680dd57..61be6796 100644 --- a/src/drv/old/hasp_drv_tft_espi.cpp +++ b/src/drv/old/hasp_drv_tft_espi.cpp @@ -13,6 +13,7 @@ #include "hasp_drv_tft_espi.h" #include "ArduinoLog.h" +#include "hasp_debug.h" #include "hasp_macro.h" void tft_espi_calibrate(uint16_t* calData) diff --git a/src/hasp_debug.h b/src/hasp_debug.h index c60ffc13..13a445ef 100644 --- a/src/hasp_debug.h +++ b/src/hasp_debug.h @@ -4,7 +4,10 @@ #ifndef HASP_DEBUG_H #define HASP_DEBUG_H +#include "hasp_conf.h" + #include "ArduinoJson.h" +#include "hasp_debug.h" #include "hasp_macro.h" #include "lvgl.h" diff --git a/src/main_arduino copy.cpp b/src/main_arduino copy.cpp deleted file mode 100644 index eef0a3f5..00000000 --- a/src/main_arduino copy.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* MIT License - Copyright (c) 2019-2021 Francis Van Roie - For full license information read the LICENSE file in the project folder */ - -#if 0 && ARDUINO - -#include -#include "lvgl.h" -#include "hasp_conf.h" // load first - -#if HASP_USE_CONFIG > 0 -#include "hasp_debug.h" -#endif - -#if HASP_USE_CONFIG > 0 -#include "hasp_config.h" -#include "hasp_gui.h" -#endif - -#include "hasp_oobe.h" - -#include "hasp/hasp_dispatch.h" -#include "hasp/hasp.h" - -#include "sys/net/hasp_network.h" - -#include "dev/device.h" - -bool isConnected; -uint8_t mainLoopCounter = 0; -unsigned long mainLastLoopTime = 0; - -void setup() -{ - hal_setup(); - - haspDevice.init(); - - /**************************** - * Storage initializations - ***************************/ -#if HASP_USE_EEPROM > 0 - eepromSetup(); // Don't start at boot, only at write -#endif - - // #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 - // filesystemSetup(); // FS mount is done in configSetup() - // #endif - - // #if HASP_USE_SDCARD > 0 - // sdcardSetup(); - // #endif - - /**************************** - * Read & Apply User Configuration - ***************************/ -#if HASP_USE_CONFIG > 0 - configSetup(); // also runs debugSetup() and debugStart() -#endif - - dispatchSetup(); - guiSetup(); - -#if HASP_USE_GPIO > 0 - gpioSetup(); -#endif - - /**************************** - * Apply User Configuration - ***************************/ - -#if HASP_USE_MQTT > 0 - mqttSetup(); // Load Hostname before starting WiFi -#endif - -#if HASP_USE_WIFI > 0 || HASP_USE_ETHERNET > 0 - networkSetup(); -#endif - -#if HASP_USE_CONFIG > 0 - if(!oobeSetup()) -#endif - { - haspSetup(); - } - -#if HASP_USE_MDNS > 0 - mdnsSetup(); -#endif - -#if HASP_USE_OTA > 0 - otaSetup(); -#endif - -#if HASP_USE_HTTP > 0 - httpSetup(); -#endif - -#if HASP_USE_TELNET > 0 - telnetSetup(); -#endif - -#if HASP_USE_TASMOTA_CLIENT > 0 - slaveSetup(); -#endif - - mainLastLoopTime = millis() - 1000; // reset loop counter - delay(20); - guiStart(); -} - -void loop() -{ - networkLoop(); - guiLoop(); - haspLoop(); - -#if HASP_USE_MQTT > 0 - mqttLoop(); -#endif // MQTT - -#if HASP_USE_TASMOTA_CLIENT > 0 - slaveLoop(); -#endif // TASMOTASLAVE - -#if HASP_USE_HTTP > 0 - httpLoop(); -#endif // HTTP - -#if HASP_USE_GPIO > 0 - gpioLoop(); -#endif // GPIO - -#if HASP_USE_OTA > 0 - otaLoop(); -#endif // OTA - -#if HASP_USE_MDNS > 0 - mdnsLoop(); -#endif // MDNS - -#if HASP_USE_TELNET > 0 - telnetLoop(); // Console -#endif // TELNET - - debugLoop(); // Console - haspDevice.loop(); - - /* Timer Loop */ - if(millis() - mainLastLoopTime >= 1000) { - /* Runs Every Second */ - haspEverySecond(); // sleep timer - debugEverySecond(); // statusupdate - -#if HASP_USE_OTA > 0 - otaEverySecond(); // progressbar -#endif - - /* Runs Every 5 Seconds */ - if(mainLoopCounter == 0 || mainLoopCounter == 5) { - isConnected = networkEvery5Seconds(); // Check connection - -#if HASP_USE_HTTP > 0 - // httpEvery5Seconds(); -#endif - -#if HASP_USE_MQTT > 0 - mqttEvery5Seconds(isConnected); -#endif - -#if HASP_USE_GPIO > 0 - // gpioEvery5Seconds(); -#endif - - haspDevice.loop_5s(); - } - - /* Reset loop counter every 10 seconds */ - if(mainLoopCounter >= 9) { - mainLoopCounter = 0; - } else { - mainLoopCounter++; - } - mainLastLoopTime += 1000; - } - -#ifdef ARDUINO_ARCH_ESP8266 - delay(2); -#else - delay(6); -#endif -} - -#endif \ No newline at end of file diff --git a/src/main_arduino.cpp b/src/main_arduino.cpp index 4fb3f9c5..0047a7f2 100644 --- a/src/main_arduino.cpp +++ b/src/main_arduino.cpp @@ -12,6 +12,7 @@ #if HASP_USE_CONFIG > 0 #include "hasp_debug.h" +#include "hasp_macro.h" #endif #if HASP_USE_CONFIG > 0