mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	Better handling of buttonUp() across platforms
This commit is contained in:
		
							parent
							
								
									9692a1a317
								
							
						
					
					
						commit
						197ea94ab8
					
				@ -5,6 +5,17 @@
 | 
			
		||||
 | 
			
		||||
KnxFacade<CC1310Platform, Bau27B0> *pKnx = nullptr;
 | 
			
		||||
 | 
			
		||||
void buttonUp()
 | 
			
		||||
{
 | 
			
		||||
    static uint32_t lastpressed=0;
 | 
			
		||||
    if (millis() - lastpressed > 200)
 | 
			
		||||
    {
 | 
			
		||||
        KnxFacade<CC1310Platform, Bau27B0> &knx = *pKnx;
 | 
			
		||||
        knx._toogleProgMode = true;
 | 
			
		||||
        lastpressed = millis();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void setup()
 | 
			
		||||
{
 | 
			
		||||
    pKnx = new KnxFacade<CC1310Platform, Bau27B0>;
 | 
			
		||||
 | 
			
		||||
@ -40,25 +40,30 @@
 | 
			
		||||
    #else
 | 
			
		||||
        #error Mask version not supported on ARDUINO_ARCH_STM32
 | 
			
		||||
    #endif
 | 
			
		||||
#elif __linux__
 | 
			
		||||
    // no predefined global instance
 | 
			
		||||
#else // Non-Arduino platforms
 | 
			
		||||
#else // Non-Arduino platforms and Linux platform
 | 
			
		||||
    // no predefined global instance
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// Only ESP8266 and ESP32 have this define. For all other platforms this is just empty.
 | 
			
		||||
#ifndef ICACHE_RAM_ATTR
 | 
			
		||||
    #define ICACHE_RAM_ATTR
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if (defined(ARDUINO_ARCH_STM32) || \
 | 
			
		||||
     defined(ARDUINO_ARCH_ESP32) || \
 | 
			
		||||
     defined(ARDUINO_ARCH_ESP8266) || \
 | 
			
		||||
     defined(ARDUINO_ARCH_SAMD))
 | 
			
		||||
ICACHE_RAM_ATTR void buttonUp()
 | 
			
		||||
{
 | 
			
		||||
    #if !defined(__linux__) && (defined(ARDUINO_ARCH_STM32) || \
 | 
			
		||||
                                defined(ARDUINO_ARCH_ESP32) || \
 | 
			
		||||
                                defined(ARDUINO_ARCH_ESP8266) || \
 | 
			
		||||
                                defined(ARDUINO_ARCH_SAMD))
 | 
			
		||||
    static uint32_t lastpressed=0;
 | 
			
		||||
    if (millis() - lastpressed > 200){
 | 
			
		||||
        knx._toogleProgMode = true;
 | 
			
		||||
        lastpressed = millis();
 | 
			
		||||
    }
 | 
			
		||||
    #endif
 | 
			
		||||
}
 | 
			
		||||
#elif defined(__linux__)
 | 
			
		||||
void buttonUp()
 | 
			
		||||
{
 | 
			
		||||
    // no de-bounce on linux platform, just satisfy the compiler
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
@ -8,18 +8,22 @@
 | 
			
		||||
    #include "knx/bau07B0.h"
 | 
			
		||||
    #include "knx/bau27B0.h"
 | 
			
		||||
    #include "knx/bau2920.h"
 | 
			
		||||
    void buttonUp();
 | 
			
		||||
#elif ARDUINO_ARCH_ESP8266
 | 
			
		||||
   #include "esp_platform.h"
 | 
			
		||||
   #include "knx/bau57B0.h"
 | 
			
		||||
   void buttonUp();
 | 
			
		||||
#elif ARDUINO_ARCH_ESP32
 | 
			
		||||
   #define LED_BUILTIN 13
 | 
			
		||||
   #include "esp32_platform.h"
 | 
			
		||||
   #include "knx/bau07B0.h"
 | 
			
		||||
   #include "knx/bau57B0.h"
 | 
			
		||||
   #include "knx/bau091A.h"
 | 
			
		||||
   void buttonUp();
 | 
			
		||||
#elif ARDUINO_ARCH_STM32
 | 
			
		||||
   #include "stm32_platform.h"
 | 
			
		||||
   #include "knx/bau07B0.h"
 | 
			
		||||
   void buttonUp();
 | 
			
		||||
#elif __linux__
 | 
			
		||||
   #define LED_BUILTIN 0
 | 
			
		||||
   #include "linux_platform.h"
 | 
			
		||||
@ -28,19 +32,18 @@
 | 
			
		||||
   #include "knx/bau07B0.h"
 | 
			
		||||
   #include "knx/bau091A.h"
 | 
			
		||||
   #include "knx/bau2920.h"
 | 
			
		||||
   void buttonUp();
 | 
			
		||||
#else
 | 
			
		||||
   #define LED_BUILTIN 0
 | 
			
		||||
   #include "cc1310_platform.h"
 | 
			
		||||
   #include "knx/bau57B0.h"
 | 
			
		||||
   #include "knx/bau27B0.h"
 | 
			
		||||
   #include "knx/bau07B0.h"
 | 
			
		||||
   #include "knx/bau091A.h"
 | 
			
		||||
   #include "knx/bau2920.h"
 | 
			
		||||
   extern void buttonUp();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void buttonUp();
 | 
			
		||||
typedef uint8_t* (*SaveRestoreCallback)(uint8_t* buffer);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
template <class P, class B> class KnxFacade : private SaveRestore
 | 
			
		||||
{
 | 
			
		||||
    friend void buttonUp();
 | 
			
		||||
@ -365,8 +368,6 @@ template <class P, class B> class KnxFacade : private SaveRestore
 | 
			
		||||
    #else
 | 
			
		||||
        #error Mask version not supported on ARDUINO_ARCH_STM32
 | 
			
		||||
    #endif
 | 
			
		||||
#elif __linux__
 | 
			
		||||
    // no predefined global instance
 | 
			
		||||
#else // Non-Arduino platforms
 | 
			
		||||
#else // Non-Arduino platforms and Linux platform
 | 
			
		||||
    // no predefined global instance
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user