Merge branch 'arendst/development' into development

This commit is contained in:
reloxx13 2018-02-08 16:47:23 +01:00
commit 4b76123af7
6 changed files with 218 additions and 45 deletions

View File

@ -4,6 +4,7 @@
* Fix Arilux RF induced exception by moving interrupt handler to iram on non esp/arduino lib v2.3.0 * Fix Arilux RF induced exception by moving interrupt handler to iram on non esp/arduino lib v2.3.0
* Add NTP sync based on chip id (#1773) * Add NTP sync based on chip id (#1773)
* Fix regression from 5.11.1h web console and http input max length from 100 to 254 characters (#1819) * Fix regression from 5.11.1h web console and http input max length from 100 to 254 characters (#1819)
* Update TSL2561 driver (#1825)
* *
* 5.11.1i * 5.11.1i
* Update TasmotaSerial library to 1.1.0 * Update TasmotaSerial library to 1.1.0

View File

@ -100,9 +100,6 @@ typedef unsigned long power_t; // Power (Relay) type
#define APP_BAUDRATE 115200 // Default serial baudrate #define APP_BAUDRATE 115200 // Default serial baudrate
#define MAX_STATUS 11 // Max number of status lines #define MAX_STATUS 11 // Max number of status lines
#define XDRV_MAX 10 // Max number of allowed Xdrv drivers (Update xdrv_interface.ino if changed)
#define XSNS_MAX 20 // Max number of allowed Xsns External Sensors (Update xsns_interface.ino if changed)
/* /*
// Removed from esp8266 core since 20171105 // Removed from esp8266 core since 20171105
#define min(a,b) ((a)<(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b))

View File

@ -1211,9 +1211,7 @@ uint32_t Midnight()
boolean MidnightNow() boolean MidnightNow()
{ {
boolean mnflg = midnight_now; boolean mnflg = midnight_now;
if (mnflg) { if (mnflg) midnight_now = 0;
midnight_now = 0;
}
return mnflg; return mnflg;
} }
@ -1229,17 +1227,14 @@ void RtcSecond()
ntp_time = sntp_get_current_timestamp(); ntp_time = sntp_get_current_timestamp();
if (ntp_time) { if (ntp_time) {
utc_time = ntp_time; utc_time = ntp_time;
ntp_sync_minute = 60; // Sync so block further requests
BreakTime(utc_time, tmpTime); BreakTime(utc_time, tmpTime);
RtcTime.year = tmpTime.year + 1970; RtcTime.year = tmpTime.year + 1970;
daylight_saving_time = RuleToTime(DaylightSavingTime, RtcTime.year); daylight_saving_time = RuleToTime(DaylightSavingTime, RtcTime.year);
standard_time = RuleToTime(StandardTime, RtcTime.year); standard_time = RuleToTime(StandardTime, RtcTime.year);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s"), GetTime(0).c_str()); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_DST_TIME ") %s"), GetTime(2).c_str());
AddLog(LOG_LEVEL_DEBUG);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_STD_TIME ") %s"), GetTime(3).c_str());
AddLog(LOG_LEVEL_DEBUG);
ntp_sync_minute = 60; // Sync so block further requests
} else { } else {
ntp_sync_minute++; // Try again in next minute ntp_sync_minute++; // Try again in next minute
} }

View File

@ -57,6 +57,84 @@ boolean (* const xdrv_func_ptr[])(byte) PROGMEM = { // Driver Function Pointer
#ifdef XDRV_10 #ifdef XDRV_10
&Xdrv10, &Xdrv10,
#endif #endif
#ifdef XDRV_11
&Xdrv11,
#endif
#ifdef XDRV_12
&Xdrv12,
#endif
#ifdef XDRV_13
&Xdrv13,
#endif
#ifdef XDRV_14
&Xdrv14,
#endif
#ifdef XDRV_15
&Xdrv15,
#endif
#ifdef XDRV_16
&Xdrv16,
#endif
#ifdef XDRV_17
&Xdrv17,
#endif
#ifdef XDRV_18
&Xdrv18,
#endif
#ifdef XDRV_19
&Xdrv19,
#endif
#ifdef XDRV_20
&Xdrv20,
#endif
// Optional user defined drivers in range 91 - 99
#ifdef XDRV_91
&Xdrv91,
#endif
#ifdef XDRV_92
&Xdrv92,
#endif
#ifdef XDRV_93
&Xdrv93,
#endif
#ifdef XDRV_94
&Xdrv94,
#endif
#ifdef XDRV_95
&Xdrv95,
#endif
#ifdef XDRV_96
&Xdrv96,
#endif
#ifdef XDRV_97
&Xdrv97,
#endif
#ifdef XDRV_98
&Xdrv98,
#endif
#ifdef XDRV_99
&Xdrv99
#endif
}; };
const uint8_t xdrv_present = sizeof(xdrv_func_ptr) / sizeof(xdrv_func_ptr[0]); // Number of drivers found const uint8_t xdrv_present = sizeof(xdrv_func_ptr) / sizeof(xdrv_func_ptr[0]); // Number of drivers found

View File

@ -31,14 +31,13 @@
uint8_t tsl2561_address; uint8_t tsl2561_address;
uint8_t tsl2561_addresses[] = { TSL2561_ADDR_LOW, TSL2561_ADDR_FLOAT, TSL2561_ADDR_HIGH }; uint8_t tsl2561_addresses[] = { TSL2561_ADDR_LOW, TSL2561_ADDR_FLOAT, TSL2561_ADDR_HIGH };
uint8_t tsl2561_type = 0;
//TSL2561 tsl(TSL2561_ADDR_FLOAT); //TSL2561 tsl(TSL2561_ADDR_FLOAT);
TSL2561 *tsl; TSL2561 *tsl = 0;
void Tsl2561Detect() void Tsl2561Detect()
{ {
if (tsl2561_type) { if (tsl) {
return; return;
} }
@ -49,10 +48,12 @@ void Tsl2561Detect()
if (tsl->begin()) { if (tsl->begin()) {
tsl->setGain(TSL2561_GAIN_16X); tsl->setGain(TSL2561_GAIN_16X);
tsl->setTiming(TSL2561_INTEGRATIONTIME_101MS); tsl->setTiming(TSL2561_INTEGRATIONTIME_101MS);
tsl2561_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "TSL2561", tsl2561_address); snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "TSL2561", tsl2561_address);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
break; break;
} else {
delete tsl;
tsl = 0;
} }
} }
} }
@ -65,8 +66,23 @@ const char HTTP_SNS_TSL2561[] PROGMEM =
void Tsl2561Show(boolean json) void Tsl2561Show(boolean json)
{ {
if (tsl2561_type) { if (tsl) {
uint16_t illuminance = tsl->getLuminosity(TSL2561_VISIBLE); union {
uint32_t full;
struct { uint16_t both, ir; };
} light;
light.full = tsl->getFullLuminosity();
uint32_t illuminance = 0;
if ((light.full == 0 || light.full == 0xffffffff)) {
if (!I2cDevice(tsl2561_address)) {
delete tsl;
tsl = 0;
}
} else {
illuminance = tsl->calculateLux(light.both, light.ir);
}
snprintf(log_data, sizeof(log_data), PSTR(D_ILLUMINANCE " 0x%08lx = b 0x%04x, i 0x%04x -> %lu " D_UNIT_LUX), light.full, light.both, light.ir, illuminance);
AddLog(LOG_LEVEL_DEBUG);
if (json) { if (json) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"TSL2561\":{\"" D_JSON_ILLUMINANCE "\":%d}"), mqtt_data, illuminance); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"TSL2561\":{\"" D_JSON_ILLUMINANCE "\":%d}"), mqtt_data, illuminance);

View File

@ -97,6 +97,92 @@ boolean (* const xsns_func_ptr[])(byte) PROGMEM = { // Sensor Function Pointers
#ifdef XSNS_20 #ifdef XSNS_20
&Xsns20, &Xsns20,
#endif #endif
#ifdef XSNS_21
&Xsns21,
#endif
#ifdef XSNS_22
&Xsns22,
#endif
#ifdef XSNS_23
&Xsns23,
#endif
#ifdef XSNS_24
&Xsns24,
#endif
#ifdef XSNS_25
&Xsns25,
#endif
#ifdef XSNS_26
&Xsns26,
#endif
#ifdef XSNS_27
&Xsns27,
#endif
#ifdef XSNS_28
&Xsns28,
#endif
#ifdef XSNS_29
&Xsns29,
#endif
#ifdef XSNS_30
&Xsns30,
#endif
#ifdef XSNS_31
&Xsns31,
#endif
#ifdef XSNS_32
&Xsns32,
#endif
// Optional user defined sensors in range 91 - 99
#ifdef XSNS_91
&Xsns91,
#endif
#ifdef XSNS_92
&Xsns92,
#endif
#ifdef XSNS_93
&Xsns93,
#endif
#ifdef XSNS_94
&Xsns94,
#endif
#ifdef XSNS_95
&Xsns95,
#endif
#ifdef XSNS_96
&Xsns96,
#endif
#ifdef XSNS_97
&Xsns97,
#endif
#ifdef XSNS_98
&Xsns98,
#endif
#ifdef XSNS_99
&Xsns99
#endif
}; };
const uint8_t xsns_present = sizeof(xsns_func_ptr) / sizeof(xsns_func_ptr[0]); // Number of External Sensors found const uint8_t xsns_present = sizeof(xsns_func_ptr) / sizeof(xsns_func_ptr[0]); // Number of External Sensors found