Merge branch 'development' into sm16716
This commit is contained in:
commit
654826f78d
@ -163,6 +163,20 @@ typedef union {
|
||||
};
|
||||
} Mcp230xxCfg;
|
||||
|
||||
typedef union {
|
||||
uint8_t data;
|
||||
struct {
|
||||
uint8_t spare0 : 1;
|
||||
uint8_t spare1 : 1;
|
||||
uint8_t spare2 : 1;
|
||||
uint8_t spare3 : 1;
|
||||
uint8_t spare4 : 1;
|
||||
uint8_t spare5 : 1;
|
||||
uint8_t spare6 : 1;
|
||||
uint8_t mhz19b_abc_disable : 1; // Disable ABC (Automatic Baseline Correction for MHZ19(B) (0 = Enabled (default), 1 = Disabled with Sensor15 command)
|
||||
};
|
||||
} SensorCfg1;
|
||||
|
||||
/*
|
||||
struct SYSCFG {
|
||||
unsigned long cfg_holder; // 000 Pre v6 header
|
||||
@ -311,8 +325,7 @@ struct SYSCFG {
|
||||
uint8_t knx_CB_param[MAX_KNX_CB]; // 6EC Type of Output (set relay, toggle relay, reply sensor value)
|
||||
Mcp230xxCfg mcp230xx_config[16]; // 6F6
|
||||
uint8_t mcp230xx_int_prio; // 716
|
||||
|
||||
uint8_t free_717[1]; // 717
|
||||
SensorCfg1 SensorBits1; // 717 On/Off settings used by Sensor Commands
|
||||
|
||||
uint16_t mcp230xx_int_timer; // 718
|
||||
uint8_t rgbwwTable[5]; // 71A
|
||||
|
||||
@ -472,7 +472,7 @@ void SettingsLoad(void)
|
||||
if (Settings.save_flag > save_flag) {
|
||||
save_flag = Settings.save_flag;
|
||||
settings_location = flash_location;
|
||||
if (Settings.flag.stop_flash_rotate) {
|
||||
if (Settings.flag.stop_flash_rotate && (0 == i)) { // Stop only if eeprom area should be used and it is valid
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,6 +297,7 @@ enum SupportedModules {
|
||||
ZX2820,
|
||||
MI_DESK_LAMP,
|
||||
SP10,
|
||||
WAGA,
|
||||
SYF05,
|
||||
MAXMODULE };
|
||||
|
||||
@ -584,6 +585,7 @@ const uint8_t kModuleNiceList[MAXMODULE] PROGMEM = {
|
||||
DIGOO,
|
||||
KA10,
|
||||
SP10,
|
||||
WAGA,
|
||||
NEO_COOLCAM, // Socket Relay Devices
|
||||
OBI,
|
||||
OBI2,
|
||||
@ -1807,7 +1809,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
||||
GPIO_ROT_B, // GPIO13 Rotary switch B pin
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "SP10", // Tuya SP10 (ESP8285 - BL0937 Energy Monitoring)
|
||||
{ "SP10", // Tuya SP10 (BL0937 Energy Monitoring)
|
||||
// https://www.aliexpress.com/item/Smart-Mini-WiFi-Plug-Outlet-Switch-Work-With-ForEcho-Alexa-Google-Home-Remote-EU-Smart-Socket/32963670423.html
|
||||
0, // GPIO00
|
||||
GPIO_PWM1, // GPIO01 Nightlight
|
||||
@ -1823,9 +1825,29 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
||||
// GPIO11 (SD_CMD Flash)
|
||||
GPIO_NRG_SEL_INV, // GPIO12 BL0937 Sel output (1 = Voltage)
|
||||
GPIO_LED1, // GPIO13 Blue LED - Link status
|
||||
GPIO_REL1, // GPIO14 Relay 1 and red LED
|
||||
GPIO_REL1, // GPIO14 Relay and red LED
|
||||
0, 0, 0
|
||||
},
|
||||
{ "WAGA CHCZ02MB", // WAGA life CHCZ02MB (HJL-01 Energy Monitoring)
|
||||
// https://www.ebay.com/itm/332595697006
|
||||
GPIO_LED2_INV, // GPIO00 Red LED
|
||||
0, // GPIO01 Serial TX
|
||||
0, // GPIO02
|
||||
GPIO_NRG_SEL_INV, // GPIO03 HJL-01 Sel output (1 = Voltage)
|
||||
0, // GPIO04
|
||||
GPIO_HJL_CF, // GPIO05 HJL-01 CF power
|
||||
// GPIO06 (SD_CLK Flash)
|
||||
// GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
|
||||
// GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT)
|
||||
0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285)
|
||||
0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285)
|
||||
// GPIO11 (SD_CMD Flash)
|
||||
GPIO_REL1, // GPIO12 Relay
|
||||
GPIO_KEY1, // GPIO13 Button
|
||||
GPIO_NRG_CF1, // GPIO14 HJL-01 CF1 voltage / current
|
||||
GPIO_LED1_INV, // GPIO15 Blue LED - Link status
|
||||
0, 0
|
||||
},
|
||||
{ "SYF05", // Sunyesmart SYF05 (a.k.a. Fcmila) = TYWE3S + SM16726
|
||||
// Also works with Merkury 904 RGBW Bulbs with 13 set to GPIO_SM16716_SEL
|
||||
// https://www.flipkart.com/fc-mila-bxav-xs-ad-smart-bulb/p/itmf85zgs45fzr7n
|
||||
|
||||
@ -145,28 +145,31 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM =
|
||||
"return false;"
|
||||
"}"
|
||||
"</script>";
|
||||
|
||||
const char HTTP_SCRIPT_MODULE1[] PROGMEM =
|
||||
"var os;"
|
||||
"function sk(s,g){" // s = value, g = id and name
|
||||
"var o=os.replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");"
|
||||
"var o=os.replace(/}1/g,\"<option value=\").replace(/}2/g,\"</option>\").replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");"
|
||||
"eb('g'+g).innerHTML=o;"
|
||||
"}"
|
||||
"function sl(){"
|
||||
"if(x!=null){x.abort();}" // Abort any request pending
|
||||
"x=new XMLHttpRequest();"
|
||||
"x.onreadystatechange=function(){"
|
||||
"if(x.readyState==4&&x.status==200){"
|
||||
"var i,o=x.responseText.replace(/}1/g,\"<option value=\").replace(/}2/g,\"</option>\");"
|
||||
"i=o.indexOf(\"}3\");" // String separator means do not use "}3" in Module name and Sensor name
|
||||
"os=o.substring(0,i);"
|
||||
"a=new XMLHttpRequest();"
|
||||
"a.onreadystatechange=function(){"
|
||||
"if(a.readyState==4&&a.status==200){"
|
||||
"os=a.responseText;"
|
||||
"sk(}4,99);"
|
||||
"os=o.substring(i+2);"; // +2 is length "}3"
|
||||
"}"
|
||||
"};"
|
||||
"a.open('GET','md?m=1',true);" // ?m related to WebServer->hasArg("m")
|
||||
"a.send();"
|
||||
"b=new XMLHttpRequest();"
|
||||
"b.onreadystatechange=function(){"
|
||||
"if(b.readyState==4&&b.status==200){"
|
||||
"os=b.responseText;";
|
||||
const char HTTP_SCRIPT_MODULE2[] PROGMEM =
|
||||
"}"
|
||||
"};"
|
||||
"x.open('GET','md?m=1',true);" // ?m related to WebServer->hasArg("m")
|
||||
"x.send();"
|
||||
"b.open('GET','md?g=1',true);" // ?g related to WebServer->hasArg("g")
|
||||
"b.send();"
|
||||
"}";
|
||||
const char HTTP_SCRIPT_MODULE3[] PROGMEM =
|
||||
"}1'%d'>%s (%d)}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name
|
||||
@ -817,7 +820,12 @@ void HandleModuleConfiguration(void)
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, AnyModuleName(midx).c_str(), midx +1);
|
||||
page += mqtt_data;
|
||||
}
|
||||
page += "}3"; // String separator means do not use "}3" in Module name and Sensor name
|
||||
WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), page);
|
||||
return;
|
||||
}
|
||||
|
||||
if (WebServer->hasArg("g")) {
|
||||
String page = "";
|
||||
for (uint8_t j = 0; j < sizeof(kGpioNiceList); j++) {
|
||||
midx = pgm_read_byte(kGpioNiceList + j);
|
||||
if (!GetUsedInModule(midx, cmodule.io)) {
|
||||
|
||||
@ -39,7 +39,10 @@ enum MhzFilterOptions {MHZ19_FILTER_OFF, MHZ19_FILTER_OFF_ALLSAMPLES, MHZ19_FILT
|
||||
/*********************************************************************************************\
|
||||
* Source: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
|
||||
*
|
||||
* Automatic Baseline Correction (ABC logic function)
|
||||
* Automatic Baseline Correction (ABC logic function) is enabled by default but may be disabled with command
|
||||
* Sensor15 0
|
||||
* and enabled again with command
|
||||
* Sensor15 1
|
||||
*
|
||||
* ABC logic function refers to that sensor itself do zero point judgment and automatic calibration procedure
|
||||
* intelligently after a continuous operation period. The automatic calibration cycle is every 24 hours after powered on.
|
||||
@ -52,10 +55,6 @@ enum MhzFilterOptions {MHZ19_FILTER_OFF, MHZ19_FILTER_OFF_ALLSAMPLES, MHZ19_FILT
|
||||
* Please do zero calibration timely, such as manual or commend calibration.
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define MHZ19_ABC_ENABLE 1 // Automatic Baseline Correction (0 = off, 1 = on (default))
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
#include <TasmotaSerial.h>
|
||||
|
||||
#ifndef CO2_LOW
|
||||
@ -72,6 +71,9 @@ TasmotaSerial *MhzSerial;
|
||||
|
||||
const char kMhzModels[] PROGMEM = "|B";
|
||||
|
||||
const char ABC_ENABLED[] PROGMEM = "ABC is Enabled";
|
||||
const char ABC_DISABLED[] PROGMEM = "ABC is Enabled";
|
||||
|
||||
enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000 };
|
||||
const uint8_t kMhzCommands[][4] PROGMEM = {
|
||||
// 2 3 6 7
|
||||
@ -88,7 +90,6 @@ const uint8_t kMhzCommands[][4] PROGMEM = {
|
||||
uint8_t mhz_type = 1;
|
||||
uint16_t mhz_last_ppm = 0;
|
||||
uint8_t mhz_filter = MHZ19_FILTER_OPTION;
|
||||
bool mhz_abc_enable = MHZ19_ABC_ENABLE;
|
||||
bool mhz_abc_must_apply = false;
|
||||
|
||||
float mhz_temperature = 0;
|
||||
@ -218,7 +219,7 @@ void MhzEverySecond(void)
|
||||
|
||||
uint16_t u = (mhz_response[6] << 8) | mhz_response[7];
|
||||
if (15000 == u) { // During (and only ever at) sensor boot, 'u' is reported as 15000
|
||||
if (!mhz_abc_enable) {
|
||||
if (Settings.SensorBits1.mhz19b_abc_disable) {
|
||||
// After bootup of the sensor the ABC will be enabled.
|
||||
// Thus only actively disable after bootup.
|
||||
mhz_abc_must_apply = true;
|
||||
@ -235,7 +236,7 @@ void MhzEverySecond(void)
|
||||
if (0 == s || 64 == s) { // Reading is stable.
|
||||
if (mhz_abc_must_apply) {
|
||||
mhz_abc_must_apply = false;
|
||||
if (mhz_abc_enable) {
|
||||
if (!Settings.SensorBits1.mhz19b_abc_disable) {
|
||||
MhzSendCmd(MHZ_CMND_ABCENABLE);
|
||||
} else {
|
||||
MhzSendCmd(MHZ_CMND_ABCDISABLE);
|
||||
@ -252,8 +253,8 @@ void MhzEverySecond(void)
|
||||
/*********************************************************************************************\
|
||||
* Command Sensor15
|
||||
*
|
||||
* 0 - (Not implemented) ABC Off
|
||||
* 1 - (Not implemented) ABC On
|
||||
* 0 - ABC Off
|
||||
* 1 - ABC On (Default)
|
||||
* 2 - Manual start = ABC Off
|
||||
* 3 - (Not implemented) Optional filter settings
|
||||
* 9 - Reset
|
||||
@ -273,6 +274,16 @@ bool MhzCommandSensor(void)
|
||||
bool serviced = true;
|
||||
|
||||
switch (XdrvMailbox.payload) {
|
||||
case 0:
|
||||
Settings.SensorBits1.mhz19b_abc_disable = true;
|
||||
MhzSendCmd(MHZ_CMND_ABCDISABLE);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_DISABLED);
|
||||
break;
|
||||
case 1:
|
||||
Settings.SensorBits1.mhz19b_abc_disable = false;
|
||||
MhzSendCmd(MHZ_CMND_ABCENABLE);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_ENABLED);
|
||||
break;
|
||||
case 2:
|
||||
MhzSendCmd(MHZ_CMND_ZEROPOINT);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_ZERO_POINT_CALIBRATION);
|
||||
@ -298,7 +309,11 @@ bool MhzCommandSensor(void)
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_5000);
|
||||
break;
|
||||
default:
|
||||
serviced = false;
|
||||
if (!Settings.SensorBits1.mhz19b_abc_disable) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_ENABLED);
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
return serviced;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user