From 1000cb836f8d16eb021724a6a37f740f6ef4339c Mon Sep 17 00:00:00 2001 From: andrethomas Date: Thu, 1 Nov 2018 17:24:49 +0200 Subject: [PATCH] Make driver boot delay configurable --- sonoff/my_user_config.h | 4 ++++ sonoff/xdrv_interface.ino | 2 +- sonoff/xdsp_interface.ino | 1 + sonoff/xnrg_interface.ino | 1 + sonoff/xsns_interface.ino | 4 ++-- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 5b721af2a..05a97c5e6 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -269,6 +269,10 @@ // -- Internal Analog input ----------------------- #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices +// -- BOOT Delay for drivers ---------------------- + +#define DRIVER_BOOT_DELAY 1 // Number of milliseconds to retard driver cycles during boot-up time to reduce overall CPU load whilst Wifi is connecting + // -- One wire sensors ---------------------------- // WARNING: Select none for default one DS18B20 sensor or enable one of the following two options for multiple sensors //#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code) diff --git a/sonoff/xdrv_interface.ino b/sonoff/xdrv_interface.ino index a578343b4..69bbcbada 100644 --- a/sonoff/xdrv_interface.ino +++ b/sonoff/xdrv_interface.ino @@ -233,7 +233,7 @@ boolean XdrvCall(byte Function) boolean result = false; for (byte x = 0; x < xdrv_present; x++) { - if (global_state.wifi_down) { delay(1); } + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xdrv_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xdsp_interface.ino b/sonoff/xdsp_interface.ino index 8d6d5a814..a2b19ebb8 100644 --- a/sonoff/xdsp_interface.ino +++ b/sonoff/xdsp_interface.ino @@ -117,6 +117,7 @@ boolean XdspCall(byte Function) boolean result = false; for (byte x = 0; x < xdsp_present; x++) { + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xdsp_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xnrg_interface.ino b/sonoff/xnrg_interface.ino index 015d5d284..1706c4e26 100644 --- a/sonoff/xnrg_interface.ino +++ b/sonoff/xnrg_interface.ino @@ -90,6 +90,7 @@ int XnrgCall(byte Function) int result = 0; for (byte x = 0; x < xnrg_present; x++) { + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xnrg_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xsns_interface.ino b/sonoff/xsns_interface.ino index 8132b8c30..a51ab5947 100644 --- a/sonoff/xsns_interface.ino +++ b/sonoff/xsns_interface.ino @@ -273,7 +273,7 @@ boolean XsnsNextCall(byte Function) { xsns_index++; if (xsns_index == xsns_present) xsns_index = 0; - if (global_state.wifi_down) { delay(1); } + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } return xsns_func_ptr[xsns_index](Function); } @@ -290,7 +290,7 @@ boolean XsnsCall(byte Function) #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND uint32_t profile_start_millis = millis(); #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND - if (global_state.wifi_down) { delay(1); } + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xsns_func_ptr[x](Function); #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND