6.3.0.10 Add command SetOption36

6.3.0.10 20181118
 * Add command SetOption36 0..255 milliseconds (10 default) to tune main loop dynamic delay
This commit is contained in:
Theo Arends 2018-11-18 16:49:02 +01:00
parent 18997e841f
commit 4899178362
8 changed files with 20 additions and 11 deletions

View File

@ -1,4 +1,7 @@
/* 6.3.0.9 20181118
/* 6.3.0.10 20181118
* Add command SetOption36 0..255 milliseconds (10 default) to tune main loop dynamic delay
*
* 6.3.0.9 20181118
* Moved command SetSensorXX to debugging driver freeing user code space
* Add dynamic delay to main loop providing time for wifi background tasks
* Remove delays introduced in 6.3.0.1 (#4233)

View File

@ -417,6 +417,7 @@ void SettingsDefaultSet2(void)
// Settings.flag.stop_flash_rotate = 0;
Settings.save_data = SAVE_DATA;
Settings.sleep = APP_SLEEP;
Settings.param[P_LOOP_SLEEP_DELAY] = LOOP_SLEEP_DELAY;
// Module
// Settings.flag.interlock = 0;
@ -853,6 +854,9 @@ void SettingsDelta(void)
if (Settings.version < 0x06030004) {
memset(&Settings.drivers, 0xFF, 32); // Enable all possible monitors, displays, drivers and sensors
}
if (Settings.version < 0x0603000A) {
Settings.param[P_LOOP_SLEEP_DELAY] = LOOP_SLEEP_DELAY;
}
Settings.version = VERSION;
SettingsSave(1);

View File

@ -189,8 +189,8 @@ typedef unsigned long power_t; // Power (Relay) type
#define KNX_MAX_device_param 30
#define MAX_KNXTX_CMNDS 5
#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
#define LOOP_SLEEP_DELAY 10 // Lowest number of milliseconds to go through the main loop using delay when needed
#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
#define LOOP_SLEEP_DELAY 10 // Lowest number of milliseconds to go through the main loop using delay when needed
/*********************************************************************************************\
* Enumeration
@ -222,7 +222,7 @@ enum ButtonStates { PRESSED, NOT_PRESSED };
enum Shortcuts { SC_CLEAR, SC_DEFAULT, SC_USER };
enum SettingsParmaIndex {P_HOLD_TIME, P_MAX_POWER_RETRY, P_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_MAX_PARAM8}; // Max is PARAM8_SIZE (18)
enum SettingsParmaIndex {P_HOLD_TIME, P_MAX_POWER_RETRY, P_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_LOOP_SLEEP_DELAY, P_MAX_PARAM8}; // Max is PARAM8_SIZE (18) - SetOption32 until SetOption49
enum DomoticzSensors {DZ_TEMP, DZ_TEMP_HUM, DZ_TEMP_HUM_BARO, DZ_POWER_ENERGY, DZ_ILLUMINANCE, DZ_COUNT, DZ_VOLTAGE, DZ_CURRENT, DZ_AIRQUALITY, DZ_MAX_SENSORS};
@ -233,7 +233,7 @@ enum LightSubtypes { LST_NONE, LST_SINGLE, LST_COLDWARM, LST_RGB, LST_RGBW, LS
enum LightTypes { LT_BASIC, LT_PWM1, LT_PWM2, LT_PWM3, LT_PWM4, LT_PWM5, LT_PWM6, LT_PWM7,
LT_NU8, LT_SERIAL1, LT_SERIAL2, LT_WS2812, LT_RGBW, LT_RGBWC, LT_NU14, LT_NU15 }; // Do not insert new fields
enum LichtSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX};
enum LightSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX};
enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_MODULE_INIT, FUNC_PRE_INIT, FUNC_INIT,
FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_100_MSECOND, FUNC_EVERY_200_MSECOND, FUNC_EVERY_250_MSECOND, FUNC_EVERY_SECOND,

View File

@ -2790,5 +2790,5 @@ void loop(void)
delay(sleep); // https://github.com/esp8266/Arduino/issues/2021
uint32_t my_activity = millis() - my_sleep;
if (my_activity < LOOP_SLEEP_DELAY) { delay(LOOP_SLEEP_DELAY - my_activity); } // Provide time for background tasks like wifi
if (my_activity < (uint32_t)Settings.param[P_LOOP_SLEEP_DELAY]) { delay((uint32_t)Settings.param[P_LOOP_SLEEP_DELAY] - my_activity); } // Provide time for background tasks like wifi
}

View File

@ -20,7 +20,7 @@
#ifndef _SONOFF_VERSION_H_
#define _SONOFF_VERSION_H_
#define VERSION 0x06030009
#define VERSION 0x0603000A
#define D_PROGRAMNAME "Sonoff-Tasmota"
#define D_AUTHOR "Theo Arends"

View File

@ -2055,10 +2055,12 @@ boolean Xdrv01(byte function)
switch (function) {
case FUNC_LOOP:
PollDnsWebserver();
if (!global_state.wifi_down) {
PollDnsWebserver();
#ifdef USE_EMULATION
if (Settings.flag2.emulation) PollUdp();
if (Settings.flag2.emulation) PollUdp();
#endif // USE_EMULATION
}
break;
case FUNC_COMMAND:
result = WebCommand();

View File

@ -926,7 +926,7 @@ boolean Xdrv02(byte function)
break;
#endif // USE_WEBSERVER
case FUNC_LOOP:
MqttLoop();
if (!global_state.mqtt_down) { MqttLoop(); }
break;
case FUNC_COMMAND:
result = MqttCommand();

View File

@ -1298,7 +1298,7 @@ boolean Xdrv11(byte function)
#endif // USE_KNX_WEB_MENU
#endif // USE_WEBSERVER
case FUNC_LOOP:
knx.loop(); // Process knx events
if (!global_state.wifi_down) { knx.loop(); } // Process knx events
break;
case FUNC_EVERY_50_MSECOND:
if (toggle_inhibit) {