diff --git a/src/knx_facade.cpp b/src/knx_facade.cpp index 7219cb0..a26089c 100644 --- a/src/knx_facade.cpp +++ b/src/knx_facade.cpp @@ -15,28 +15,37 @@ #else #error "No medium type specified for platform Arduino_SAMD! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)" #endif - #define ICACHE_RAM_ATTR #elif ARDUINO_ARCH_ESP8266 // predefined global instance for IP only KnxFacade knx; #elif ARDUINO_ARCH_ESP32 - // predefined global instance for IP only - KnxFacade knx; + // predefined global instance for TP or IP + #ifdef MEDIUM_TYPE + #if MEDIUM_TYPE == 0 + KnxFacade knx; + #elif MEDIUM_TYPE == 5 + KnxFacade knx; + #else + #error "Only TP and IP supported for Arduino ESP32 platform!" + #endif + #else + // Compatibility + KnxFacade knx; + //#error "No medium type specified for platform Arduino ESP32! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)" + #endif #elif ARDUINO_ARCH_STM32 KnxFacade knx; - // no predefined global instance - #define ICACHE_RAM_ATTR #elif __linux__ // no predefined global instance - #define ICACHE_RAM_ATTR #endif -#ifndef __linux__ -uint32_t lastpressed=0; +#ifndef ICACHE_RAM_ATTR + #define ICACHE_RAM_ATTR #endif ICACHE_RAM_ATTR void buttonUp() { #ifndef __linux__ + static uint32_t lastpressed=0; if (millis() - lastpressed > 200){ knx._toogleProgMode = true; lastpressed = millis(); diff --git a/src/knx_facade.h b/src/knx_facade.h index 7aa862c..44afb4a 100644 --- a/src/knx_facade.h +++ b/src/knx_facade.h @@ -17,6 +17,7 @@ #elif ARDUINO_ARCH_ESP32 #define LED_BUILTIN 13 #include "esp32_platform.h" + #include "knx/bau07B0.h" #include "knx/bau57B0.h" #elif ARDUINO_ARCH_STM32 #include "stm32_platform.h" @@ -334,11 +335,21 @@ template class KnxFacade : private SaveRestore // predefined global instance for IP only extern KnxFacade knx; #elif ARDUINO_ARCH_ESP32 - // predefined global instance for IP only - extern KnxFacade knx; + // predefined global instance for TP or IP + #ifdef MEDIUM_TYPE + #if MEDIUM_TYPE == 0 + extern KnxFacade knx; + #elif MEDIUM_TYPE == 5 + extern KnxFacade knx; + #else + #error "Only TP and IP supported for Arduino ESP32 platform!" + #endif + #else + #error "No medium type specified for Arduino ESP32 platform! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)" + #endif #elif ARDUINO_ARCH_STM32 // predefined global instance for TP only extern KnxFacade knx; #elif __linux__ // no predefined global instance -#endif +#endif \ No newline at end of file