6.3.0.12 Change boot delays

6.3.0.12 20181122
 * Remove delays introduced in 6.3.0.11 (#4233)
 * Add additional start-up delay during initial wifi connection
 * Add support for I2C MGC3130 Electric Field Effect sensor by Christian Baars (#3774, #4404)
 * Add initial support for Hass sensor discovery (#4380)
This commit is contained in:
Theo Arends 2018-11-22 12:25:18 +01:00
parent 29f46c5804
commit d71ae77900
8 changed files with 74 additions and 74 deletions

View File

@ -1,4 +1,10 @@
/* 6.3.0.11 20181120 /* 6.3.0.12 20181122
* Remove delays introduced in 6.3.0.11 (#4233)
* Add additional start-up delay during initial wifi connection
* Add support for I2C MGC3130 Electric Field Effect sensor by Christian Baars (#3774, #4404)
* Add initial support for Hass sensor discovery (#4380)
*
* 6.3.0.11 20181120
* Add delays removed in 6.3.0.9 (#4233) * Add delays removed in 6.3.0.9 (#4233)
* Allow user definition of defines WIFI_RSSI_THRESHOLD (default 10) and WIFI_RESCAN_MINUTES (default 44) * Allow user definition of defines WIFI_RSSI_THRESHOLD (default 10) and WIFI_RESCAN_MINUTES (default 44)
* Add support for Fujitsu HVac and IrRemote (#4387) * Add support for Fujitsu HVac and IrRemote (#4387)

View File

@ -48,7 +48,9 @@
// -- Project ------------------------------------- // -- Project -------------------------------------
#define PROJECT "sonoff" // PROJECT is used as the default topic delimiter #define PROJECT "sonoff" // PROJECT is used as the default topic delimiter
//#define MODULE SONOFF_BASIC // [Module] Select default model from sonoff_template.h. If none is selected the default will be SONOFF_BASIC
// If not selected the default will be SONOFF_BASIC
//#define MODULE SONOFF_BASIC // [Module] Select default model from sonoff_template.h
#define SAVE_DATA 1 // [SaveData] Save changed parameters to Flash (0 = disable, 1 - 3600 seconds) #define SAVE_DATA 1 // [SaveData] Save changed parameters to Flash (0 = disable, 1 - 3600 seconds)
#define SAVE_STATE 1 // [SetOption0] Save changed power state to Flash (0 = disable, 1 = enable) #define SAVE_STATE 1 // [SetOption0] Save changed power state to Flash (0 = disable, 1 = enable)
@ -299,7 +301,6 @@
// #define USE_SI1145 // Enable SI1145/46/47 sensor (I2C address 0x60) (+1k code) // #define USE_SI1145 // Enable SI1145/46/47 sensor (I2C address 0x60) (+1k code)
#define USE_LM75AD // Enable LM75AD sensor (I2C addresses 0x48 - 0x4F) (+0k5 code) #define USE_LM75AD // Enable LM75AD sensor (I2C addresses 0x48 - 0x4F) (+0k5 code)
// #define USE_APDS9960 // Enable APDS9960 Proximity Sensor (I2C address 0x39). Disables SHT and VEML6070 (+4k7 code) // #define USE_APDS9960 // Enable APDS9960 Proximity Sensor (I2C address 0x39). Disables SHT and VEML6070 (+4k7 code)
// #define USE_MGC3130 // Enable MGC3130 Electric Field Effect Sensor (I2C address 0x42)
// #define USE_MCP230xx // Enable MCP23008/MCP23017 - Must define I2C Address in #define USE_MCP230xx_ADDR below - range 0x20 - 0x27 (+4k7 code) // #define USE_MCP230xx // Enable MCP23008/MCP23017 - Must define I2C Address in #define USE_MCP230xx_ADDR below - range 0x20 - 0x27 (+4k7 code)
// #define USE_MCP230xx_ADDR 0x20 // Enable MCP23008/MCP23017 I2C Address to use (Must be within range 0x20 through 0x27 - set according to your wired setup) // #define USE_MCP230xx_ADDR 0x20 // Enable MCP23008/MCP23017 I2C Address to use (Must be within range 0x20 through 0x27 - set according to your wired setup)
// #define USE_MCP230xx_OUTPUT // Enable MCP23008/MCP23017 OUTPUT support through sensor29 commands (+1k5 code) // #define USE_MCP230xx_OUTPUT // Enable MCP23008/MCP23017 OUTPUT support through sensor29 commands (+1k5 code)
@ -312,6 +313,7 @@
// #define USE_MPU6050 // Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+2k6 code) // #define USE_MPU6050 // Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+2k6 code)
// #define USE_DS3231 // Enable DS3231 external RTC in case no Wifi is avaliable. See docs in the source file (+1k2 code) // #define USE_DS3231 // Enable DS3231 external RTC in case no Wifi is avaliable. See docs in the source file (+1k2 code)
// #define USE_RTC_ADDR 0x68 // Default I2C address 0x68 // #define USE_RTC_ADDR 0x68 // Default I2C address 0x68
// #define USE_MGC3130 // Enable MGC3130 Electric Field Effect Sensor (I2C address 0x42) (+2k7 code, 0k3 mem)
// #define USE_DISPLAY // Add I2C Display Support (+2k code) // #define USE_DISPLAY // Add I2C Display Support (+2k code)
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0 #define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0

View File

@ -2778,5 +2778,11 @@ void loop(void)
delay(sleep); // https://github.com/esp8266/Arduino/issues/2021 delay(sleep); // https://github.com/esp8266/Arduino/issues/2021
uint32_t my_activity = millis() - my_sleep; uint32_t my_activity = millis() - my_sleep;
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 if (global_state.wifi_down) {
delay(my_activity /2); // Force max of 50% processing vs. yield time while wifi is down
} else {
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

@ -91,6 +91,7 @@ void KNX_CB_Action(message_t const &msg, void *arg);
//#define USE_CCS811 // Add I2C code for CCS811 sensor (+2k2 code) //#define USE_CCS811 // Add I2C code for CCS811 sensor (+2k2 code)
//#define USE_MPU6050 // Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+2k6 code) //#define USE_MPU6050 // Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+2k6 code)
//#define USE_DS3231 // Enable DS3231 external RTC in case no Wifi is avaliable. See docs in the source file (+1k2 code) //#define USE_DS3231 // Enable DS3231 external RTC in case no Wifi is avaliable. See docs in the source file (+1k2 code)
//#define USE_MGC3130 // Enable MGC3130 Electric Field Effect Sensor (I2C address 0x42) (+2k7 code, 0k3 mem)
#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code) #define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code)
#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code) #define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code)
#ifndef CO2_LOW #ifndef CO2_LOW

View File

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

View File

@ -238,7 +238,7 @@ boolean XdrvCall(byte Function)
boolean result = false; boolean result = false;
for (byte x = 0; x < xdrv_present; x++) { for (byte x = 0; x < xdrv_present; x++) {
AppDelay(); // AppDelay();
result = xdrv_func_ptr[x](Function); result = xdrv_func_ptr[x](Function);
if (result) break; if (result) break;
} }

View File

@ -1,37 +1,26 @@
/* /*
xsns_91_MGC3130.ino - Support for I2C MGC3130 Electric Field Sensor for Sonoff-Tasmota xsns_36_MGC3130.ino - Support for I2C MGC3130 Electric Field Sensor for Sonoff-Tasmota
Copyright (C) 2018 Christian Baars & Theo Arends Copyright (C) 2018 Christian Baars & Theo Arends
Redistribution and use in source and binary forms, with or without This program is free software: you can redistribute it and/or modify
modification, are permitted provided that the following conditions are met: it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Redistributions of source code must retain the above copyright notice, This program is distributed in the hope that it will be useful,
this list of conditions and the following disclaimer. but WITHOUT ANY WARRANTY; without even the implied warranty of
- Redistributions in binary form must reproduce the above copyright notice, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
this list of conditions and the following disclaimer in the documentation GNU General Public License for more details.
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" You should have received a copy of the GNU General Public License
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE along with this program. If not, see <http://www.gnu.org/licenses/>.
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/ */
//#define USE_MGC3130 //#define USE_MGC3130
#ifdef USE_I2C #ifdef USE_I2C
#ifdef USE_MGC3130 #ifdef USE_MGC3130
#define XSNS_36 36
/*********************************************************************************************\ /*********************************************************************************************\
* MGC3130 - Electric Field Sensor * MGC3130 - Electric Field Sensor
* *
@ -43,9 +32,11 @@
* Wiring: SDA/SCL as usual plus RESET and TRANSFER -> 4 Wires * Wiring: SDA/SCL as usual plus RESET and TRANSFER -> 4 Wires
\*********************************************************************************************/ \*********************************************************************************************/
#define XSNS_36 36
#warning **** MGC3130: It is recommended to disable all unneeded I2C-drivers **** #warning **** MGC3130: It is recommended to disable all unneeded I2C-drivers ****
#define MGC3130_I2C_ADDR 0x42 #define MGC3130_I2C_ADDR 0x42
#define MGC3130_xfer pin[GPIO_MGC3130_XFER] #define MGC3130_xfer pin[GPIO_MGC3130_XFER]
#define MGC3130_reset pin[GPIO_MGC3130_RESET] #define MGC3130_reset pin[GPIO_MGC3130_RESET]
@ -527,25 +518,21 @@ bool MGC3130_detect(void)
void MGC3130_show(boolean json) void MGC3130_show(boolean json)
{ {
if (!MGC3130_type) { if (!MGC3130_type) { return; }
return;
}
char status_chr[2]; char status_chr[2];
if(MGC_data.out.systemInfo.DSPRunning){ if (MGC_data.out.systemInfo.DSPRunning) {
sprintf (status_chr, "1"); sprintf (status_chr, "1");
} }
else{ else{
sprintf (status_chr, "0"); sprintf (status_chr, "0");
} }
if (json) { if (json) {
if (MGC3130_mode == 3 && !MGC3130_triggeredByTouch) if (MGC3130_mode == 3 && !MGC3130_triggeredByTouch) {
{ if (MGC_data.out.systemInfo.positionValid && !(MGC_data.out.x == MGC3130_lastSentX && MGC_data.out.y == MGC3130_lastSentY && MGC_data.out.z == MGC3130_lastSentZ)) {
if(MGC_data.out.systemInfo.positionValid && !(MGC_data.out.x == MGC3130_lastSentX && MGC_data.out.y == MGC3130_lastSentY && MGC_data.out.z == MGC3130_lastSentZ)){
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"X\":%u,\"Y\":%u,\"Z\":%u}"), snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"X\":%u,\"Y\":%u,\"Z\":%u}"),
mqtt_data, MGC3130stype, MGC_data.out.x/64, MGC_data.out.y/64, (MGC_data.out.z-(uint16_t)MGC3130_MIN_ZVALUE)/64); mqtt_data, MGC3130stype, MGC_data.out.x/64, MGC_data.out.y/64, (MGC_data.out.z-(uint16_t)MGC3130_MIN_ZVALUE)/64);
MGC3130_lastSentX = MGC_data.out.x; MGC3130_lastSentX = MGC_data.out.x;
MGC3130_lastSentY = MGC_data.out.y; MGC3130_lastSentY = MGC_data.out.y;
MGC3130_lastSentZ = MGC_data.out.z; MGC3130_lastSentZ = MGC_data.out.z;
@ -553,40 +540,38 @@ void MGC3130_show(boolean json)
} }
MGC3130_triggeredByTouch = false; MGC3130_triggeredByTouch = false;
if (MGC3130_mode == 2){ if (MGC3130_mode == 2) {
if (MGC_data.out.systemInfo.airWheelValid && (MGC3130_rotValue != MGC3130_lastSentRotValue)){ if (MGC_data.out.systemInfo.airWheelValid && (MGC3130_rotValue != MGC3130_lastSentRotValue)) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"AW\":%i}"), mqtt_data, MGC3130stype, MGC3130_rotValue); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"AW\":%i}"), mqtt_data, MGC3130stype, MGC3130_rotValue);
MGC3130_lastSentRotValue = MGC3130_rotValue; MGC3130_lastSentRotValue = MGC3130_rotValue;
} }
} }
if (MGC3130_currentGesture[0] != '\0'){ if (MGC3130_currentGesture[0] != '\0') {
if (millis() - MGC3130_touchTimeStamp > 220 ){ if (millis() - MGC3130_touchTimeStamp > 220 ) {
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"%s\":%u}"), mqtt_data, MGC3130stype, MGC3130_currentGesture, MGC3130_touchCounter); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"%s\":%u}"), mqtt_data, MGC3130stype, MGC3130_currentGesture, MGC3130_touchCounter);
MGC3130_currentGesture[0] = '\0'; MGC3130_currentGesture[0] = '\0';
MGC3130_touchTimeStamp = millis(); MGC3130_touchTimeStamp = millis();
}
}
#ifdef USE_WEBSERVER
else {
if (true){
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_MGC_3130_SNS, mqtt_data, MGC3130stype, status_chr, hwRev[0], hwRev[1], loaderVersion[0], loaderVersion[1], loaderPlatform );
} }
#ifdef USE_WEBSERVER
} else {
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_MGC_3130_SNS, mqtt_data, MGC3130stype, status_chr, hwRev[0], hwRev[1], loaderVersion[0], loaderVersion[1], loaderPlatform );
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
}
} }
}
/*********************************************************************************************\ /*********************************************************************************************\
* Command Sensor91 * Command Sensor36
* *
* Command | Payload | Description * Command | Payload | Description
* ---------|---------|-------------------------- * ---------|---------|--------------------------
* Sensor91 | | ... * Sensor36 | | ...
* Sensor91 | 0 | Next Mode - cycle through the modes * Sensor36 | 0 | Next Mode - cycle through the modes
* Sensor91 | 1 | Gesture Mode * Sensor36 | 1 | Gesture Mode
* Sensor91 | 2 | Airwheel Mode * Sensor36 | 2 | Airwheel Mode
* Sensor91 | 3 | Position Mode with x,y,z - z must be higher than half of the max. sensing height * Sensor36 | 3 | Position Mode with x,y,z - z must be higher than half of the max. sensing height
\*********************************************************************************************/ \*********************************************************************************************/
bool MGC3130CommandSensor() bool MGC3130CommandSensor()
@ -624,19 +609,20 @@ boolean Xsns36(byte function)
if (i2c_flg) { if (i2c_flg) {
if ((FUNC_INIT == function) && (pin[GPIO_MGC3130_XFER] < 99) && (pin[GPIO_MGC3130_RESET] < 99)) { if ((FUNC_INIT == function) && (pin[GPIO_MGC3130_XFER] < 99) && (pin[GPIO_MGC3130_RESET] < 99)) {
MGC3130_detect(); MGC3130_detect();
} else if (MGC3130_type) { }
else if (MGC3130_type) {
switch (function) { switch (function) {
case FUNC_EVERY_50_MSECOND: case FUNC_EVERY_50_MSECOND:
MGC3130_loop(); MGC3130_loop();
break; break;
case FUNC_COMMAND: case FUNC_COMMAND:
if (XSNS_36 == XdrvMailbox.index) { if (XSNS_36 == XdrvMailbox.index) {
result = MGC3130CommandSensor(); result = MGC3130CommandSensor();
} }
break; break;
case FUNC_JSON_APPEND: case FUNC_JSON_APPEND:
MGC3130_show(1); MGC3130_show(1);
break; break;
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
case FUNC_WEB_APPEND: case FUNC_WEB_APPEND:
MGC3130_show(0); MGC3130_show(0);

View File

@ -270,7 +270,6 @@ const uint8_t xsns_present = sizeof(xsns_func_ptr) / sizeof(xsns_func_ptr[0]);
boolean XsnsNextCall(byte Function, uint8_t &xsns_index) boolean XsnsNextCall(byte Function, uint8_t &xsns_index)
{ {
xsns_index++; xsns_index++;
if (xsns_index == xsns_present) { xsns_index = 0; } if (xsns_index == xsns_present) { xsns_index = 0; }
#ifdef USE_DEBUG_DRIVER #ifdef USE_DEBUG_DRIVER
@ -279,7 +278,7 @@ boolean XsnsNextCall(byte Function, uint8_t &xsns_index)
if (xsns_index == xsns_present) { xsns_index = 0; } if (xsns_index == xsns_present) { xsns_index = 0; }
} }
#endif #endif
AppDelay(); // AppDelay();
return xsns_func_ptr[xsns_index](Function); return xsns_func_ptr[xsns_index](Function);
} }
@ -299,7 +298,7 @@ boolean XsnsCall(byte Function)
#ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND
uint32_t profile_start_millis = millis(); uint32_t profile_start_millis = millis();
#endif // PROFILE_XSNS_SENSOR_EVERY_SECOND #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND
AppDelay(); // AppDelay();
result = xsns_func_ptr[x](Function); result = xsns_func_ptr[x](Function);
#ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND