mirror of https://github.com/arendst/Tasmota.git
Merge branch 'arendst/development' into development
This commit is contained in:
commit
4b76123af7
|
@ -4,6 +4,7 @@
|
|||
* 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)
|
||||
* 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
|
||||
* Update TasmotaSerial library to 1.1.0
|
||||
|
|
|
@ -100,9 +100,6 @@ typedef unsigned long power_t; // Power (Relay) type
|
|||
#define APP_BAUDRATE 115200 // Default serial baudrate
|
||||
#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
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
|
|
|
@ -1156,34 +1156,34 @@ uint32_t MakeTime(TIME_T &tm)
|
|||
|
||||
uint32_t RuleToTime(TimeChangeRule r, int yr)
|
||||
{
|
||||
TIME_T tm;
|
||||
uint32_t t;
|
||||
uint8_t m;
|
||||
uint8_t w; // temp copies of r.month and r.week
|
||||
TIME_T tm;
|
||||
uint32_t t;
|
||||
uint8_t m;
|
||||
uint8_t w; // temp copies of r.month and r.week
|
||||
|
||||
m = r.month;
|
||||
w = r.week;
|
||||
if (0 == w) { // Last week = 0
|
||||
if (++m > 12) { // for "Last", go to the next month
|
||||
m = 1;
|
||||
yr++;
|
||||
}
|
||||
w = 1; // and treat as first week of next month, subtract 7 days later
|
||||
m = r.month;
|
||||
w = r.week;
|
||||
if (0 == w) { // Last week = 0
|
||||
if (++m > 12) { // for "Last", go to the next month
|
||||
m = 1;
|
||||
yr++;
|
||||
}
|
||||
w = 1; // and treat as first week of next month, subtract 7 days later
|
||||
}
|
||||
|
||||
tm.hour = r.hour;
|
||||
tm.minute = 0;
|
||||
tm.second = 0;
|
||||
tm.day_of_month = 1;
|
||||
tm.month = m;
|
||||
tm.year = yr - 1970;
|
||||
t = MakeTime(tm); // First day of the month, or first day of next month for "Last" rules
|
||||
BreakTime(t, tm);
|
||||
t += (7 * (w - 1) + (r.dow - tm.day_of_week + 7) % 7) * SECS_PER_DAY;
|
||||
if (0 == r.week) {
|
||||
t -= 7 * SECS_PER_DAY; //back up a week if this is a "Last" rule
|
||||
}
|
||||
return t;
|
||||
tm.hour = r.hour;
|
||||
tm.minute = 0;
|
||||
tm.second = 0;
|
||||
tm.day_of_month = 1;
|
||||
tm.month = m;
|
||||
tm.year = yr - 1970;
|
||||
t = MakeTime(tm); // First day of the month, or first day of next month for "Last" rules
|
||||
BreakTime(t, tm);
|
||||
t += (7 * (w - 1) + (r.dow - tm.day_of_week + 7) % 7) * SECS_PER_DAY;
|
||||
if (0 == r.week) {
|
||||
t -= 7 * SECS_PER_DAY; // back up a week if this is a "Last" rule
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
String GetTime(int type)
|
||||
|
@ -1211,9 +1211,7 @@ uint32_t Midnight()
|
|||
boolean MidnightNow()
|
||||
{
|
||||
boolean mnflg = midnight_now;
|
||||
if (mnflg) {
|
||||
midnight_now = 0;
|
||||
}
|
||||
if (mnflg) midnight_now = 0;
|
||||
return mnflg;
|
||||
}
|
||||
|
||||
|
@ -1229,19 +1227,16 @@ void RtcSecond()
|
|||
ntp_time = sntp_get_current_timestamp();
|
||||
if (ntp_time) {
|
||||
utc_time = ntp_time;
|
||||
ntp_sync_minute = 60; // Sync so block further requests
|
||||
BreakTime(utc_time, tmpTime);
|
||||
RtcTime.year = tmpTime.year + 1970;
|
||||
daylight_saving_time = RuleToTime(DaylightSavingTime, 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);
|
||||
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 {
|
||||
ntp_sync_minute++; // Try again in next minute
|
||||
ntp_sync_minute++; // Try again in next minute
|
||||
}
|
||||
}
|
||||
utc_time++;
|
||||
|
|
|
@ -57,6 +57,84 @@ boolean (* const xdrv_func_ptr[])(byte) PROGMEM = { // Driver Function Pointer
|
|||
#ifdef XDRV_10
|
||||
&Xdrv10,
|
||||
#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
|
||||
|
|
|
@ -31,14 +31,13 @@
|
|||
|
||||
uint8_t tsl2561_address;
|
||||
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 *tsl = 0;
|
||||
|
||||
void Tsl2561Detect()
|
||||
{
|
||||
if (tsl2561_type) {
|
||||
if (tsl) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,10 +48,12 @@ void Tsl2561Detect()
|
|||
if (tsl->begin()) {
|
||||
tsl->setGain(TSL2561_GAIN_16X);
|
||||
tsl->setTiming(TSL2561_INTEGRATIONTIME_101MS);
|
||||
tsl2561_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "TSL2561", tsl2561_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
break;
|
||||
} else {
|
||||
delete tsl;
|
||||
tsl = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +66,23 @@ const char HTTP_SNS_TSL2561[] PROGMEM =
|
|||
|
||||
void Tsl2561Show(boolean json)
|
||||
{
|
||||
if (tsl2561_type) {
|
||||
uint16_t illuminance = tsl->getLuminosity(TSL2561_VISIBLE);
|
||||
if (tsl) {
|
||||
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) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"TSL2561\":{\"" D_JSON_ILLUMINANCE "\":%d}"), mqtt_data, illuminance);
|
||||
|
|
|
@ -97,6 +97,92 @@ boolean (* const xsns_func_ptr[])(byte) PROGMEM = { // Sensor Function Pointers
|
|||
#ifdef XSNS_20
|
||||
&Xsns20,
|
||||
#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
|
||||
|
|
Loading…
Reference in New Issue