| LightHub v4.0.0 Smarthome controller firmware

options.h
Go to the documentation of this file.
1 #pragma once
2 #include <Arduino.h>
3 #define DEFAULT_FILESIZE_LIMIT 65535
4 #ifndef MAX_JSON_CONF_SIZE
5
6 #if defined(__SAM3X8E__)
7 #define MAX_JSON_CONF_SIZE 24000
8 #elif defined(ARDUINO_ARCH_AVR)
9 #define MAX_JSON_CONF_SIZE 4096
10 #elif defined(ARDUINO_ARCH_ESP32)
11 #define MAX_JSON_CONF_SIZE 65535
12 #else
13 #define MAX_JSON_CONF_SIZE 32000
14 #endif
15
16 #endif
17
18 #ifdef MDNS_ENABLE
19 #ifndef OTA_PORT
20 #define OTA_PORT 65280
21 #endif
22 #endif
23
24 // Configuration of drivers enabled
25 #define SYSLOG_LOCAL_SOCKET 514
26
27 #ifndef MODBUS_UART_RX_PIN
28 #define MODBUS_UART_RX_PIN -1
29 #endif
30
31 #ifndef MODBUS_UART_TX_PIN
32 #define MODBUS_UART_TX_PIN -1
33 #endif
34
35 #ifndef FASTLED
36 #define ADAFRUIT_LED
37 #endif
38 // ADAFRUIT library allow to dynamically configure SPI LED Strip Parameters
39
40 // If not defined ADAFRUIT_LED - FastLED library will be used instead
41 // And strip type, pin, order must defined on compilation time
42 #ifndef CONTROLLER
43 #define CONTROLLER TM1809
44 #endif
45
46 #ifndef SCALE_VOLUME_100
47 #define SCALE_VOLUME_100 false
48 #endif
49
50 #ifndef DATA_PIN
51 #define DATA_PIN 4
52 #endif
53
54 #ifndef ORDER
55 #define ORDER BRG
56 #endif
57
58 #ifndef MODBUS_TX_PIN
59 #define TXEnablePin 13
60 #else
61 #define TXEnablePin MODBUS_TX_PIN
62 #endif
63
64 //#define ESP_EEPROM_SIZE 2048
65
66 #ifndef AVR_DMXOUT_PIN
67 #define AVR_DMXOUT_PIN 18
68 #endif
69
70 #define WIFI_TIMEOUT 60000UL
71 #define TIMEOUT_RECONNECT 10000UL
72 #define TIMEOUT_REINIT 5000UL
73 #define TIMEOUT_RETAIN 8000UL
74 #define INTERVAL_1W 5000UL
75 #define PERIOD_THERMOSTAT_FAILED (600 * 1000UL)
76
77 //#define T_ATTEMPTS 200
78 //#define IET_TEMP 0
79 //#define IET_ATTEMPTS 1
80
81 #define THERMO_GIST_CELSIUS 1.
82 #define THERMO_OVERHEAT_CELSIUS 38.
83 #define FM_OVERHEAT_CELSIUS 40.
84
85 #define MIN_VOLUME 25
86 #define INIT_VOLUME 40
87
88 /*
89 #define MAXFLASHSTR 32
90 #define PWDFLASHSTR 16
91 #define EEPROM_SIGNATURE "LHCF"
92 #define EEPROM_SIGNATURE_LENGTH 4
93
94 #define OFFSET_MAC 0
95 #define OFFSET_IP OFFSET_MAC+6
96 #define OFFSET_DNS OFFSET_IP+4
97 #define OFFSET_GW OFFSET_DNS+4
98 #define OFFSET_MASK OFFSET_GW+4
99 #define OFFSET_CONFIGSERVER OFFSET_MASK+4
100 #define OFFSET_MQTT_PWD OFFSET_CONFIGSERVER+MAXFLASHSTR
101 #define OFFSET_SIGNATURE OFFSET_MQTT_PWD+PWDFLASHSTR
102 #define EEPROM_offset_NotAlligned OFFSET_SIGNATURE+EEPROM_SIGNATURE_LENGTH
103 #define EEPROM_offsetJSON EEPROM_offset_NotAlligned + (4 -(EEPROM_offset_NotAlligned & 3))
104 //#define EEPROM_offsetJSON IFLASH_PAGE_SIZE
105 #define EEPROM_FIX_PART_LEN EEPROM_offsetJSON-OFFSET_MAC
106 */
107
108 #ifndef INTERVAL_CHECK_INPUT
109 #define INTERVAL_CHECK_INPUT 11
110 #endif
111
112 #ifndef TIMER_CHECK_INPUT
113 #define TIMER_CHECK_INPUT 15
114 #endif
115 #ifndef INTERVAL_CHECK_SENSOR
116 #define INTERVAL_CHECK_SENSOR 5000
117 #endif
118
119 #define INTERVAL_SLOW_POLLING 1000
120 //#define INTERVAL_POLLING 100
121 #define THERMOSTAT_CHECK_PERIOD 30000
122
123 #ifndef OW_UPDATE_INTERVAL
124 #define OW_UPDATE_INTERVAL 5000
125 #endif
126
127 #ifndef MODBUS_SERIAL_BAUD
128 #define MODBUS_SERIAL_BAUD 9600
129 #endif
130
131 #ifndef MODBUS_DIMMER_PARAM
132 #define MODBUS_DIMMER_PARAM SERIAL_8N1
133 #endif
134
135 #define dimPar MODBUS_DIMMER_PARAM
136 #define fmPar SERIAL_8N1
137
138 #ifndef SERIAL_BAUD
139 #define SERIAL_BAUD 115200
140 #endif
141
142 #ifndef CUSTOM_FIRMWARE_MAC
143 #define DEFAULT_FIRMWARE_MAC {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xFF}
144 #endif
145
146 #ifndef MY_CONFIG_SERVER
147 #define CONFIG_SERVER "lazyhome.ru"
148 #else
149 #define CONFIG_SERVER QUOTE(MY_CONFIG_SERVER)
150 #endif
151
152 #ifndef HOMETOPIC
153 #define HOMETOPIC "myhome"
154 #endif
155
156 //Default output topic
157 #ifndef OUTTOPIC
158 #define OUTTOPIC "s_out"
159 #endif
160
161 //Topic to receive CLI commands
162 #ifndef CMDTOPIC
163 #define CMDTOPIC "$command"
164 #endif
165
166 //Default broadcast topic
167 #ifndef INTOPIC
168 #define INTOPIC "in"
169 #endif
170
171 #define MQTT_SUBJECT_LENGTH 20
172 #define MQTT_TOPIC_LENGTH 64
173
174 #ifndef DMX_DISABLE
175 #define _dmxin
176 #define _dmxout
177 #endif
178
179 #ifndef OWIRE_DISABLE
180 #define _owire
181 #endif
182
183 #if !(defined (MODBUS_DISABLE) && defined (MBUS_DISABLE))
184 #define _modbus
185 #endif
186
187 #ifdef ARTNET_ENABLE
188 #define _artnet
189 #endif
190
191 #ifndef LAN_INIT_DELAY
192 #define LAN_INIT_DELAY 500
193 #endif
194
195 #define DEFAULT_INC_STEP 5
196
197
198 #if defined(ARDUINO_ARCH_AVR)
199 //All options available
200 #ifdef CONTROLLINO
201 #define modbusSerial Serial3
202 #ifndef AC_Serial
203 #define AC_Serial Serial2
204 #endif
205 #else
206 #define modbusSerial Serial2
207 #ifndef AC_Serial
208 #define AC_Serial Serial3
209 #endif
210 #endif
211 #define dmxin DMXSerial
212 #define dmxout DmxSimple
213 #endif
214
215 #if defined(__SAM3X8E__)
216 #ifndef modbusSerial
217 #define modbusSerial Serial2
218 #endif
219
220 #ifndef AC_Serial
221 #define AC_Serial Serial3
222 #endif
223
224 #define dmxout DmxDue1
225 #define dmxin DmxDue1
226 #endif
227
228 #if defined(NRF5)
229 //#define modbusSerial Serial1
230 #undef _dmxin
231 #undef _dmxout
232 #undef _modbus
233 #endif
234
235 #if defined(ARDUINO_ARCH_ESP8266)
236 #undef _dmxin
237
238 #ifndef DMX_DISABLE
239 #define _espdmx
240 #endif
241
242 #ifndef modbusSerial
243 #define modbusSerial Serial1
244 #endif
245
246 #ifndef AC_Serial
247 #define AC_Serial Serial1
248 #endif
249
250 #endif
251
252 #if defined(ARDUINO_ARCH_ESP32)
253 #undef _dmxin
254 #ifndef DMX_DISABLE
255 #define _espdmx
256 #endif
257
258 #ifndef modbusSerial
259 #define modbusSerial Serial2
260 #endif
261
262 #ifndef AC_Serial
263 #define AC_Serial Serial2
264 #endif
265
266 #endif
267
268 #ifndef _dmxout
269 #undef _artnet
270 #endif
271
272 #ifdef WIFI_MANAGER_DISABLE
273 #ifndef ESP_WIFI_AP
274 #define ESP_WIFI_AP mywifiap
275 #endif
276
277 #ifndef ESP_WIFI_PWD
278 #define ESP_WIFI_PWD mywifipass
279 #endif
280 #endif
281
282 #define DHT_POLL_DELAY_DEFAULT 15000
283 #define UPTIME_POLL_DELAY_DEFAULT 30000
284
285 #ifdef ARDUINO_ARCH_STM32F1
286 #define strncpy_P strncpy
287 #endif
288
289 #ifndef DMX_SMOOTH_DELAY
290 #define DMX_SMOOTH_DELAY 10
291 #endif
292
293 //#ifdef M5STACK
294 //#define debugSerial M5.Lcd
295 //#endif
296
297 #ifndef debugSerialPort
298 #define debugSerialPort Serial
299 #endif
300
301
302 #ifndef Wiz5500
303 #define W5100_ETHERNET_SHIELD
304 #else
305 #define W5500_ETHERNET_SHIELD
306 #endif
307
308
309 #if defined(ARDUINO_ARCH_AVR)
310 #define PINS_COUNT NUM_DIGITAL_PINS
311 #define isAnalogPin(p) ((p >= 54) && (p<=69))
312 #endif
313
314 #if defined(__SAM3X8E__)
315 #define isAnalogPin(p) (g_APinDescription[p].ulPinAttribute & PIN_ATTR_ANALOG) == PIN_ATTR_ANALOG
316 #endif
317
318 #if defined(ARDUINO_ARCH_STM32)
319 #define PINS_COUNT NUM_DIGITAL_PINS
320 #define isAnalogPin(p) ((p >= 44) && (p<=57))
321 #endif
322
323 #if defined(ESP8266)
324 #define PINS_COUNT NUM_DIGITAL_PINS
325 #define isAnalogPin(p) ( p ==17 )
326 #endif
327
328 #if defined(ARDUINO_ARCH_ESP32)
329 #define PINS_COUNT NUM_DIGITAL_PINS
330 #define isAnalogPin(p) ((p ==4) || (p>=12)&& (p<=15) || (p>=25)&& (p<=27)||(p>=32)&& (p<=33) || (p>=37)&& (p<=38))
331 #endif
332
333 #if defined(NRF5)
334 //#define PINS_COUNT NUM_DIGITAL_PINS
335 #define isAnalogPin(p) ((p >= 14) && (p<=21))
336 #endif