Merge branch 'development' of https://github.com/arendst/Sonoff-Tasmota into development

This commit is contained in:
andrethomas 2018-07-24 20:06:42 +02:00
commit 9ea3e7d80e
10 changed files with 33 additions and 12 deletions

View File

@ -1,4 +1,6 @@
/* 6.1.1c
* Fix possible WDT due to long MQTT publish handling (#3313)
* Fix CCS811 temperature and humidity compensation
* Add support for CCS811 sensor (#3309)
* Add command Timers 0/1 to globally disable or enable armed timers (#3270)
*

View File

@ -68,6 +68,7 @@ typedef unsigned long power_t; // Power (Relay) type
#define HLW_IREF_PULSE 3500 // was 1666us = 600Hz = 4.545A
#define MQTT_RETRY_SECS 10 // Minimum seconds to retry MQTT connection
#define GLOBAL_VALUES_VALID 300 // Max number of seconds to keep last received values
#define APP_POWER 0 // Default saved power state Off
#define WS2812_MAX_LEDS 512 // Max number of LEDs

View File

@ -188,8 +188,9 @@ uint8_t ntp_force_sync = 0; // Force NTP sync
StateBitfield global_state;
RulesBitfield rules_flag;
uint8_t glob_humidity = 0;
sint16_t glob_temperature = -9999;
uint32_t global_update = 0;
float global_temperature = 0;
float global_humidity = 0;
char my_version[33]; // Composed version string
char my_hostname[33]; // Composed Wifi hostname
@ -1544,6 +1545,8 @@ void PerformEverySecond()
}
}
ResetGlobalValues();
if (Settings.tele_period) {
tele_period++;
if (tele_period == Settings.tele_period -1) {

View File

@ -414,6 +414,22 @@ char TempUnit()
return (Settings.flag.temperature_conversion) ? 'F' : 'C';
}
void SetGlobalValues(float temperature, float humidity)
{
global_update = uptime;
global_temperature = temperature;
global_humidity = humidity;
}
void ResetGlobalValues()
{
if ((uptime - global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes
global_update = 0;
global_temperature = 0;
global_humidity = 0;
}
}
double FastPrecisePow(double a, double b)
{
// https://martin.ankerl.com/2012/01/25/optimized-approximative-pow-in-c-and-cpp/

View File

@ -231,6 +231,8 @@ void MqttPublishDirect(const char* topic, boolean retained)
if (Settings.ledstate &0x04) {
blinks++;
}
yield(); // #3313
}
void MqttPublish(const char* topic, boolean retained)

View File

@ -147,6 +147,8 @@ boolean ShtRead()
sht_humidity = (sht_temperature - 25) * (t1 + t2 * humRaw) + rhLinear;
sht_temperature = ConvertTemp(sht_temperature);
SetGlobalValues(sht_temperature, sht_humidity);
sht_valid = SENSOR_MAX_MISS;
return true;
}

View File

@ -185,6 +185,8 @@ boolean HtuRead()
htu_humidity = (-0.15) * (25 - htu_temperature) + htu_humidity;
}
SetGlobalValues(htu_temperature, htu_humidity);
htu_valid = SENSOR_MAX_MISS;
return true;
}

View File

@ -460,8 +460,7 @@ void BmpRead()
}
if (bmp_temperature != 0.0) { bmp_temperature = ConvertTemp(bmp_temperature); }
glob_humidity = bmp_humidity;
glob_temperature = bmp_temperature;
SetGlobalValues(bmp_temperature, bmp_humidity);
}
void BmpEverySecond()

View File

@ -102,10 +102,7 @@ void Sht3xShow(boolean json)
for (byte i = 0; i < sht3x_count; i++) {
if (Sht3xRead(t, h, sht3x_sensors[i].address)) {
if (0 == i) {
glob_humidity = h;
glob_temperature = t;
}
if (0 == i) { SetGlobalValues(t, h); }
dtostrfd(t, Settings.flag2.temperature_resolution, temperature);
dtostrfd(h, Settings.flag2.humidity_resolution, humidity);

View File

@ -62,10 +62,7 @@ void CCS811Update() // Perform every n second
TVOC = ccs.getTVOC();
eCO2 = ccs.geteCO2();
CCS811_ready = 1;
if ((glob_humidity != 0) && (glob_temperature != -9999)) {
double gtmp = glob_temperature * 4;
ccs.setEnvironmentalData(glob_humidity, gtmp / 4);
}
if (global_update) { ccs.setEnvironmentalData((uint8_t)global_humidity, global_temperature); }
ecnt = 0;
}
} else {