knx
ETS configurable knx-stack
knx_facade.cpp
Go to the documentation of this file.
1
#include "
knx_facade.h
"
2
3
#include "
knx/bits.h
"
4
5
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
6
7
#if (defined(ARDUINO_ARCH_STM32) || \
8
defined(ARDUINO_ARCH_ESP32) || \
9
defined(ARDUINO_ARCH_ESP8266) || \
10
defined(ARDUINO_ARCH_SAMD) || \
11
defined(ARDUINO_ARCH_RP2040)) || \
12
defined(LIBRETINY)
13
14
// Only ESP8266 and ESP32 have this define. For all other platforms this is just empty.
15
#ifndef IRAM_ATTR
16
#define IRAM_ATTR
17
#endif
18
19
#ifndef PROG_BTN_PRESS_MIN_MILLIS
20
#define PROG_BTN_PRESS_MIN_MILLIS 50
21
#endif
22
23
#ifndef PROG_BTN_PRESS_MAX_MILLIS
24
#define PROG_BTN_PRESS_MAX_MILLIS 500
25
#endif
26
27
28
IRAM_ATTR
void
buttonEvent
()
29
{
30
static
uint32_t lastEvent = 0;
31
static
uint32_t lastPressed = 0;
32
33
uint32_t diff =
millis
() - lastEvent;
34
35
if
(diff >= PROG_BTN_PRESS_MIN_MILLIS && diff <= PROG_BTN_PRESS_MAX_MILLIS)
36
{
37
if
(
millis
() - lastPressed > 200)
38
{
39
knx
.toggleProgMode();
40
lastPressed =
millis
();
41
}
42
}
43
44
lastEvent =
millis
();
45
}
46
#endif
47
48
#ifdef ARDUINO_ARCH_SAMD
49
// predefined global instance for TP or RF or TP/RF coupler
50
#if MASK_VERSION == 0x07B0
51
KnxFacade<SamdPlatform, Bau07B0>
knx
(
buttonEvent
);
52
#elif MASK_VERSION == 0x27B0
53
KnxFacade<SamdPlatform, Bau27B0>
knx
(
buttonEvent
);
54
#elif MASK_VERSION == 0x2920
55
KnxFacade<SamdPlatform, Bau2920>
knx
(
buttonEvent
);
56
#else
57
#error "Mask version not supported on ARDUINO_ARCH_SAMD"
58
#endif
59
#elif defined(ARDUINO_ARCH_RP2040)
60
// predefined global instance for TP or RF or IP or TP/RF coupler or TP/IP coupler
61
#if MASK_VERSION == 0x07B0
62
KnxFacade<RP2040ArduinoPlatform, Bau07B0>
knx
(
buttonEvent
);
63
#elif MASK_VERSION == 0x27B0
64
KnxFacade<RP2040ArduinoPlatform, Bau27B0>
knx
(
buttonEvent
);
65
#elif MASK_VERSION == 0x57B0
66
KnxFacade<RP2040ArduinoPlatform, Bau57B0>
knx
(
buttonEvent
);
67
#elif MASK_VERSION == 0x2920
68
KnxFacade<RP2040ArduinoPlatform, Bau2920>
knx
(
buttonEvent
);
69
#elif MASK_VERSION == 0x091A
70
KnxFacade<RP2040ArduinoPlatform, Bau091A>
knx
(
buttonEvent
);
71
#else
72
#error "Mask version not supported on ARDUINO_ARCH_RP2040"
73
#endif
74
75
#elif defined(ARDUINO_ARCH_ESP8266)
76
// predefined global instance for TP or IP or TP/IP coupler
77
#if MASK_VERSION == 0x07B0
78
KnxFacade<EspPlatform, Bau07B0>
knx
(
buttonEvent
);
79
#elif MASK_VERSION == 0x57B0
80
KnxFacade<EspPlatform, Bau57B0>
knx
(
buttonEvent
);
81
#elif MASK_VERSION == 0x091A
82
KnxFacade<EspPlatform, Bau091A>
knx
(
buttonEvent
);
83
#else
84
#error "Mask version not supported on ARDUINO_ARCH_ESP8266"
85
#endif
86
87
#elif defined(ARDUINO_ARCH_ESP32)
88
// predefined global instance for TP or IP or TP/IP coupler
89
#if MASK_VERSION == 0x07B0
90
KnxFacade<Esp32Platform, Bau07B0>
knx
(
buttonEvent
);
91
#elif MASK_VERSION == 0x57B0
92
KnxFacade<Esp32Platform, Bau57B0>
knx
(
buttonEvent
);
93
#elif MASK_VERSION == 0x091A
94
KnxFacade<Esp32Platform, Bau091A>
knx
(
buttonEvent
);
95
#else
96
#error "Mask version not supported on ARDUINO_ARCH_ESP32"
97
#endif
98
99
#elif defined(LIBRETINY)
100
// predefined global instance for TP or IP or TP/IP coupler
101
#if MASK_VERSION == 0x07B0
102
KnxFacade<LibretinyPlatform, Bau07B0>
knx
(
buttonEvent
);
103
#elif MASK_VERSION == 0x57B0
104
KnxFacade<LibretinyPlatform, Bau57B0>
knx
(
buttonEvent
);
105
#elif MASK_VERSION == 0x091A
106
KnxFacade<LibretinyPlatform, Bau091A>
knx
(
buttonEvent
);
107
#else
108
#error "Mask version not supported on LIBRETINY"
109
#endif
110
111
#elif defined(ESP_PLATFORM)
112
// predefined global instance for TP or IP or TP/IP coupler
113
#if MASK_VERSION == 0x07B0
114
KnxFacade<Esp32IdfPlatform, Bau07B0>
knx
(
buttonEvent
);
115
#elif MASK_VERSION == 0x57B0
116
KnxFacade<Esp32IdfPlatform, Bau57B0>
knx
(
buttonEvent
);
117
#elif MASK_VERSION == 0x091A
118
KnxFacade<Esp32IdfPlatform, Bau091A>
knx
(
buttonEvent
);
119
#else
120
#error "Mask version not supported on ESP_IDF_ESP32"
121
#endif
122
123
#elif defined(ARDUINO_ARCH_STM32)
124
#if MASK_VERSION == 0x07B0
125
KnxFacade<Stm32Platform, Bau07B0>
knx
(
buttonEvent
);
126
#else
127
#error "Mask version not supported on ARDUINO_ARCH_STM32"
128
#endif
129
#else
// Non-Arduino platforms and Linux platform
130
// no predefined global instance
131
#endif
132
133
#endif
// KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
bits.h
millis
uint32_t millis()
Definition:
cc1310_platform.cpp:123
KnxFacade
Definition:
knx_facade.h:76
knx
KnxFacade< SamdPlatform, Bau07B0 > knx(buttonEvent)
Definition:
knx_facade.h:514
buttonEvent
IRAM_ATTR void buttonEvent()
Definition:
knx_facade.cpp:28
knx_facade.h
src
knx_facade.cpp
Generated by
1.9.1