mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	Fix prog button handling (#207)
* Update stm32_platform.cpp Addresses a side effect of https://github.com/thelsing/knx/pull/177, which causes the eeprom buffer to be overwritten every time getEepromBuffer is called. This prevented programming of STM32 boards as their initial bus address was lost before programming. * progbutton fix * Update stm32_platform.cpp Addresses a side effect of https://github.com/thelsing/knx/pull/177, which causes the eeprom buffer to be overwritten every time getEepromBuffer is called. This prevented programming of STM32 boards as their initial bus address was lost before programming. * Update knx_facade.h Remove superfluous attribute _buttonPinInterruptOn * Update knx_facade.h attachInterrup on CHANGE for progbutton detection
This commit is contained in:
		
							parent
							
								
									3948045c28
								
							
						
					
					
						commit
						bd907c242d
					
				| @ -15,35 +15,46 @@ | ||||
|             #define ICACHE_RAM_ATTR | ||||
|         #endif | ||||
| 
 | ||||
|         ICACHE_RAM_ATTR void buttonUp() | ||||
|         #ifndef PROG_BTN_PRESS_MIN_MILLIS | ||||
|             #define PROG_BTN_PRESS_MIN_MILLIS 50 | ||||
|         #endif | ||||
| 
 | ||||
|         #ifndef PROG_BTN_PRESS_MAX_MILLIS | ||||
|             #define PROG_BTN_PRESS_MAX_MILLIS 500 | ||||
|         #endif | ||||
| 
 | ||||
| 
 | ||||
|         ICACHE_RAM_ATTR void buttonEvent() | ||||
|         { | ||||
|             static uint32_t lastpressed=0; | ||||
|             if (millis() - lastpressed > 200){ | ||||
|             static uint32_t lastEvent=0; | ||||
|             uint32_t diff = millis() - lastEvent; | ||||
|             if (diff >= PROG_BTN_PRESS_MIN_MILLIS && diff <= PROG_BTN_PRESS_MAX_MILLIS){ | ||||
|                 knx.toggleProgMode(); | ||||
|                 lastpressed = millis(); | ||||
|             } | ||||
| 
 | ||||
|             lastEvent = millis(); | ||||
|         } | ||||
|     #endif | ||||
| 
 | ||||
|     #ifdef ARDUINO_ARCH_SAMD | ||||
|         // predefined global instance for TP or RF or TP/RF coupler
 | ||||
|         #if MASK_VERSION == 0x07B0 | ||||
|             KnxFacade<SamdPlatform, Bau07B0> knx(buttonUp); | ||||
|             KnxFacade<SamdPlatform, Bau07B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x27B0 | ||||
|             KnxFacade<SamdPlatform, Bau27B0> knx(buttonUp); | ||||
|             KnxFacade<SamdPlatform, Bau27B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x2920 | ||||
|             KnxFacade<SamdPlatform, Bau2920> knx(buttonUp); | ||||
|             KnxFacade<SamdPlatform, Bau2920> knx(buttonEvent); | ||||
|         #else | ||||
|             #error "Mask version not supported on ARDUINO_ARCH_SAMD" | ||||
|         #endif | ||||
|     #elif defined(ARDUINO_ARCH_RP2040) | ||||
|         // predefined global instance for TP or RF or TP/RF coupler
 | ||||
|         #if MASK_VERSION == 0x07B0 | ||||
|             KnxFacade<RP2040ArduinoPlatform, Bau07B0> knx(buttonUp); | ||||
|             KnxFacade<RP2040ArduinoPlatform, Bau07B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x27B0 | ||||
|             KnxFacade<RP2040ArduinoPlatform, Bau27B0> knx(buttonUp); | ||||
|             KnxFacade<RP2040ArduinoPlatform, Bau27B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x2920 | ||||
|             KnxFacade<RP2040ArduinoPlatform, Bau2920> knx(buttonUp); | ||||
|             KnxFacade<RP2040ArduinoPlatform, Bau2920> knx(buttonEvent); | ||||
|         #else | ||||
|             #error "Mask version not supported on ARDUINO_ARCH_RP2040" | ||||
|         #endif | ||||
| @ -51,11 +62,11 @@ | ||||
|     #elif defined(ARDUINO_ARCH_ESP8266) | ||||
|         // predefined global instance for TP or IP or TP/IP coupler
 | ||||
|         #if MASK_VERSION == 0x07B0 | ||||
|             KnxFacade<EspPlatform, Bau07B0> knx(buttonUp); | ||||
|             KnxFacade<EspPlatform, Bau07B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x57B0 | ||||
|             KnxFacade<EspPlatform, Bau57B0> knx(buttonUp); | ||||
|             KnxFacade<EspPlatform, Bau57B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x091A | ||||
|             KnxFacade<EspPlatform, Bau091A> knx(buttonUp); | ||||
|             KnxFacade<EspPlatform, Bau091A> knx(buttonEvent); | ||||
|         #else | ||||
|             #error "Mask version not supported on ARDUINO_ARCH_ESP8266" | ||||
|         #endif | ||||
| @ -63,18 +74,18 @@ | ||||
|     #elif defined(ARDUINO_ARCH_ESP32) | ||||
|         // predefined global instance for TP or IP or TP/IP coupler
 | ||||
|         #if MASK_VERSION == 0x07B0 | ||||
|             KnxFacade<Esp32Platform, Bau07B0> knx(buttonUp); | ||||
|             KnxFacade<Esp32Platform, Bau07B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x57B0 | ||||
|             KnxFacade<Esp32Platform, Bau57B0> knx(buttonUp); | ||||
|             KnxFacade<Esp32Platform, Bau57B0> knx(buttonEvent); | ||||
|         #elif MASK_VERSION == 0x091A | ||||
|             KnxFacade<Esp32Platform, Bau091A> knx(buttonUp); | ||||
|             KnxFacade<Esp32Platform, Bau091A> knx(buttonEvent); | ||||
|         #else | ||||
|             #error "Mask version not supported on ARDUINO_ARCH_ESP32" | ||||
|         #endif | ||||
| 
 | ||||
|     #elif defined(ARDUINO_ARCH_STM32) | ||||
|         #if MASK_VERSION == 0x07B0 | ||||
|             KnxFacade<Stm32Platform, Bau07B0> knx(buttonUp); | ||||
|             KnxFacade<Stm32Platform, Bau07B0> knx(buttonEvent); | ||||
|         #else | ||||
|             #error "Mask version not supported on ARDUINO_ARCH_STM32" | ||||
|         #endif | ||||
|  | ||||
| @ -177,23 +177,6 @@ template <class P, class B> class KnxFacade : private SaveRestore | ||||
|         _progLedOnCallback = progLedOnCallback; | ||||
|     } | ||||
| 
 | ||||
|     /**
 | ||||
|      * returns RISING if interrupt is created in a rising signal, FALLING otherwise | ||||
|      */ | ||||
|     uint32_t buttonPinInterruptOn() | ||||
|     { | ||||
|         return _buttonPinInterruptOn; | ||||
|     } | ||||
| 
 | ||||
|     /**
 | ||||
|      * Sets if the programming button creates a RISING or a FALLING signal.  | ||||
|      *  | ||||
|      * Set to RISING for GPIO--BUTTON--VDD or to FALLING for GPIO--BUTTON--GND | ||||
|      */ | ||||
|     void buttonPinInterruptOn(uint32_t value) | ||||
|     { | ||||
|         _buttonPinInterruptOn = value; | ||||
|     } | ||||
|    | ||||
|     uint32_t buttonPin() | ||||
|     { | ||||
| @ -281,9 +264,9 @@ template <class P, class B> class KnxFacade : private SaveRestore | ||||
|         { | ||||
|             // Workaround for https://github.com/arduino/ArduinoCore-samd/issues/587
 | ||||
|             #if (ARDUINO_API_VERSION >= 10200) | ||||
|                 attachInterrupt(_buttonPin, _progButtonISRFuncPtr, (PinStatus)_buttonPinInterruptOn); | ||||
|                 attachInterrupt(_buttonPin, _progButtonISRFuncPtr, (PinStatus)CHANGE); | ||||
|             #else | ||||
|                 attachInterrupt(_buttonPin, _progButtonISRFuncPtr, _buttonPinInterruptOn); | ||||
|                 attachInterrupt(_buttonPin, _progButtonISRFuncPtr, CHANGE); | ||||
|             #endif | ||||
|         } | ||||
| 
 | ||||
| @ -423,7 +406,6 @@ template <class P, class B> class KnxFacade : private SaveRestore | ||||
|     ProgLedOffCallback _progLedOffCallback = 0; | ||||
|     uint32_t _ledPinActiveOn = LOW; | ||||
|     uint32_t _ledPin = LED_BUILTIN; | ||||
|     uint32_t _buttonPinInterruptOn = RISING; | ||||
|     uint32_t _buttonPin = 0; | ||||
|     SaveCallback _saveCallback = 0; | ||||
|     RestoreCallback _restoreCallback = 0; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user