mirror of https://github.com/arendst/Tasmota.git
v5.9.0a - Streamline External Sensor Support
This commit is contained in:
parent
68cdc6130c
commit
ee93b64800
|
@ -183,6 +183,7 @@ uint8_t light_type = 0; // Light types
|
|||
|
||||
boolean mdns_begun = false;
|
||||
|
||||
uint8_t xsns_present = 0; // Number of External Sensors found
|
||||
boolean (*xsns_func_ptr[XSNS_MAX])(byte); // External Sensor Function Pointers for simple implementation of sensors
|
||||
char version[16]; // Version string from VERSION define
|
||||
char my_hostname[33]; // Composed Wifi hostname
|
||||
|
@ -1791,19 +1792,16 @@ void MqttShowState()
|
|||
|
||||
boolean MqttShowSensor()
|
||||
{
|
||||
boolean json_data_available = false;
|
||||
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{\"" D_TIME "\":\"%s\""), mqtt_data, GetDateAndTime().c_str());
|
||||
int json_data_start = strlen(mqtt_data);
|
||||
for (byte i = 0; i < MAX_SWITCHES; i++) {
|
||||
if (pin[GPIO_SWT1 +i] < 99) {
|
||||
boolean swm = ((FOLLOW_INV == Settings.switchmode[i]) || (PUSHBUTTON_INV == Settings.switchmode[i]) || (PUSHBUTTONHOLD_INV == Settings.switchmode[i]));
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_SWITCH "%d\":\"%s\""), mqtt_data, i +1, GetStateText(swm ^ lastwallswitch[i]));
|
||||
json_data_available = true;
|
||||
}
|
||||
}
|
||||
if (XsnsCall(FUNC_XSNS_JSON)) {
|
||||
json_data_available = true;
|
||||
}
|
||||
XsnsCall(FUNC_XSNS_JSON);
|
||||
boolean json_data_available = (strlen(mqtt_data) - json_data_start);
|
||||
if (strstr_P(mqtt_data, PSTR(D_TEMPERATURE))) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_TEMPERATURE_UNIT "\":\"%c\""), mqtt_data, TempUnit());
|
||||
}
|
||||
|
|
|
@ -1228,28 +1228,23 @@ int GetCommandCode(char* destination, size_t destination_size, const char* needl
|
|||
* ADC support
|
||||
\*********************************************************************************************/
|
||||
|
||||
uint16_t GetAdc0()
|
||||
void AdcShow(boolean json)
|
||||
{
|
||||
uint16_t alr = 0;
|
||||
uint16_t analog = 0;
|
||||
for (byte i = 0; i < 32; i++) {
|
||||
alr += analogRead(A0);
|
||||
analog += analogRead(A0);
|
||||
delay(1);
|
||||
}
|
||||
return alr >> 5;
|
||||
}
|
||||
|
||||
boolean MqttShowAdc()
|
||||
{
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_ANALOG_INPUT0 "\":%d"), mqtt_data, GetAdc0());
|
||||
return true;
|
||||
}
|
||||
analog >>= 5;
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_ANALOG_INPUT0 "\":%d"), mqtt_data, analog);
|
||||
#ifdef USE_WEBSERVER
|
||||
void WebShowAdc()
|
||||
{
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{s}" D_ANALOG_INPUT0 "{m}%d{e}"), mqtt_data, GetAdc0());
|
||||
}
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{s}" D_ANALOG_INPUT0 "{m}%d{e}"), mqtt_data, analog);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -1268,23 +1263,22 @@ boolean Xsns02(byte function)
|
|||
// case FUNC_XSNS_PREP:
|
||||
// break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowAdc();
|
||||
AdcShow(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowAdc();
|
||||
AdcShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // USE_ADC_VCC
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Syslog
|
||||
*
|
||||
*
|
||||
* Example:
|
||||
* snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_LOG "Any value %d"), value);
|
||||
* AddLog(LOG_LEVEL_DEBUG);
|
||||
|
|
|
@ -60,7 +60,8 @@ const char HTTP_HEAD[] PROGMEM =
|
|||
"x=new XMLHttpRequest();"
|
||||
"x.onreadystatechange=function(){"
|
||||
"if(x.readyState==4&&x.status==200){"
|
||||
"document.getElementById('l1').innerHTML=x.responseText;"
|
||||
"var s=x.responseText.replace(/{s}/g,\"<tr><th>\").replace(/{m}/g,\"</th><td>\").replace(/{e}/g,\"</td></tr>\").replace(/{t}/g,\"%'><div style='text-align:center;font-weight:\");"
|
||||
"document.getElementById('l1').innerHTML=s;"
|
||||
"}"
|
||||
"};"
|
||||
"x.open('GET','ay'+a,true);"
|
||||
|
@ -279,9 +280,6 @@ const char HTTP_END[] PROGMEM =
|
|||
"</body>"
|
||||
"</html>";
|
||||
|
||||
const char HTTP_ROW_START[] PROGMEM = "<tr><th>"; // Replaces {s}
|
||||
const char HTTP_ROW_MIDDLE[] PROGMEM = "</th><td>"; // Replases {m}
|
||||
const char HTTP_ROW_END[] PROGMEM = "</td></tr>"; // Replaces {e}
|
||||
const char HTTP_SNS_TEMP[] PROGMEM = "%s{s}%s " D_TEMPERATURE "{m}%s°%c{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
const char HTTP_SNS_HUM[] PROGMEM = "%s{s}%s " D_HUMIDITY "{m}%s%{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
const char HTTP_SNS_PRESSURE[] PROGMEM = "%s{s}%s " D_PRESSURE "{m}%s " D_UNIT_PRESSURE "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
|
@ -514,27 +512,23 @@ void HandleAjaxStatusRefresh()
|
|||
ExecuteCommand(svalue);
|
||||
}
|
||||
|
||||
String page = "";
|
||||
mqtt_data[0] = '\0';
|
||||
XsnsCall(FUNC_XSNS_WEB);
|
||||
String tpage = mqtt_data;
|
||||
tpage.replace(F("{s}"), FPSTR(HTTP_ROW_START)); // = <tr><th>
|
||||
tpage.replace(F("{m}"), FPSTR(HTTP_ROW_MIDDLE)); // = </th><td>
|
||||
tpage.replace(F("{e}"), FPSTR(HTTP_ROW_END)); // = </td></tr>
|
||||
|
||||
String page = "";
|
||||
if (tpage.length() > 0) {
|
||||
if (strlen(mqtt_data)) {
|
||||
page += FPSTR(HTTP_TABLE100);
|
||||
page += tpage;
|
||||
page += mqtt_data;
|
||||
page += F("</table>");
|
||||
}
|
||||
char line[160];
|
||||
char line[80];
|
||||
if (devices_present) {
|
||||
page += FPSTR(HTTP_TABLE100);
|
||||
page += F("<tr>");
|
||||
uint8_t fsize = (devices_present < 5) ? 70 - (devices_present * 8) : 32;
|
||||
for (byte idx = 1; idx <= devices_present; idx++) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(power, idx -1));
|
||||
snprintf_P(line, sizeof(line), PSTR("<td style='width:%d%'><div style='text-align:center;font-weight:%s;font-size:%dpx'>%s</div></td>"),
|
||||
// snprintf_P(line, sizeof(line), PSTR("<td style='width:%d%'><div style='text-align:center;font-weight:%s;font-size:%dpx'>%s</div></td>"),
|
||||
snprintf_P(line, sizeof(line), PSTR("<td style='width:%d{t}%s;font-size:%dpx'>%s</div></td>"), // {t} = %'><div style='text-align:center;font-weight:
|
||||
100 / devices_present, (bitRead(power, idx -1)) ? "bold" : "normal", fsize, (devices_present < 5) ? GetStateText(bitRead(power, idx -1)) : svalue);
|
||||
page += line;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ void CounterSaveState()
|
|||
}
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
void CounterInit()
|
||||
{
|
||||
typedef void (*function) () ;
|
||||
|
@ -81,57 +83,41 @@ void CounterInit()
|
|||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_SNS_COUNTER[] PROGMEM =
|
||||
"%s{s}" D_COUNTER "%d{m}%s%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
boolean MqttShowCounter()
|
||||
void CounterShow(boolean json)
|
||||
{
|
||||
char stemp[16];
|
||||
boolean json_data_available = false;
|
||||
char counter[16];
|
||||
|
||||
byte dsxflg = 0;
|
||||
for (byte i = 0; i < MAX_COUNTERS; i++) {
|
||||
if (pin[GPIO_CNTR1 +i] < 99) {
|
||||
if (bitRead(Settings.pulse_counter_type, i)) {
|
||||
dtostrfd((double)RtcSettings.pulse_counter[i] / 1000, 3, stemp);
|
||||
dtostrfd((double)RtcSettings.pulse_counter[i] / 1000, 3, counter);
|
||||
} else {
|
||||
dsxflg++;
|
||||
dtostrfd(RtcSettings.pulse_counter[i], 0, stemp);
|
||||
dtostrfd(RtcSettings.pulse_counter[i], 0, counter);
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_COUNTER "%d\":%s"), mqtt_data, i +1, stemp);
|
||||
json_data_available = true;
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_COUNTER "%d\":%s"), mqtt_data, i +1, counter);
|
||||
#ifdef USE_DOMOTICZ
|
||||
if (1 == dsxflg) {
|
||||
DomoticzSensor(DZ_COUNT, RtcSettings.pulse_counter[i]);
|
||||
dsxflg++;
|
||||
}
|
||||
if (1 == dsxflg) {
|
||||
DomoticzSensor(DZ_COUNT, RtcSettings.pulse_counter[i]);
|
||||
dsxflg++;
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
}
|
||||
return json_data_available;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_SNS_COUNTER[] PROGMEM =
|
||||
"%s{s}" D_COUNTER "%d{m}%s%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
|
||||
void WebShowCounter()
|
||||
{
|
||||
char stemp[16];
|
||||
|
||||
for (byte i = 0; i < MAX_COUNTERS; i++) {
|
||||
if (pin[GPIO_CNTR1 +i] < 99) {
|
||||
if (bitRead(Settings.pulse_counter_type, i)) {
|
||||
dtostrfi((double)RtcSettings.pulse_counter[i] / 1000, 3, stemp);
|
||||
} else {
|
||||
dtostrfi(RtcSettings.pulse_counter[i], 0, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_COUNTER, mqtt_data, i +1, counter, (bitRead(Settings.pulse_counter_type, i)) ? " " D_UNIT_SECOND : "");
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_COUNTER, mqtt_data, i +1, stemp, (bitRead(Settings.pulse_counter_type, i)) ? " " D_UNIT_SECOND : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -150,11 +136,11 @@ boolean Xsns01(byte function)
|
|||
// case FUNC_XSNS_PREP:
|
||||
// break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowCounter();
|
||||
CounterShow(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowCounter();
|
||||
CounterShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
|
|
@ -650,11 +650,20 @@ boolean HlwCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len,
|
|||
return serviced;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
|
||||
void HlwMqttStat(byte option)
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_ENERGY_SNS[] PROGMEM =
|
||||
"{s}" D_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}"
|
||||
"{s}" D_CURRENT "{m}%s " D_UNIT_AMPERE "{e}"
|
||||
"{s}" D_POWERUSAGE "{m}%s " D_UNIT_WATT "{e}"
|
||||
"{s}" D_POWER_FACTOR "{m}%s{e}"
|
||||
"{s}" D_ENERGY_TODAY "{m}%s " D_UNIT_KILOWATTHOUR "{e}"
|
||||
"{s}" D_ENERGY_YESTERDAY "{m}%s " D_UNIT_KILOWATTHOUR "{e}"
|
||||
"{s}" D_ENERGY_TOTAL "{m}%s " D_UNIT_KILOWATTHOUR "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
void HlwShow(boolean json, boolean option)
|
||||
{
|
||||
/* option 0 = do not show period energy usage
|
||||
* option 1 = show period energy usage
|
||||
|
@ -685,17 +694,24 @@ void HlwMqttStat(byte option)
|
|||
dtostrfd(current, 3, scurrent);
|
||||
dtostrfd(power_factor, 2, spower_factor);
|
||||
dtostrfd((float)Settings.hlw_kWhyesterday / 100000000, Settings.flag.energy_resolution, syesterday_energy);
|
||||
snprintf_P(speriod, sizeof(speriod), PSTR(", \"" D_PERIOD "\":%s"), senergy);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_TOTAL "\":%s, \"" D_YESTERDAY "\":%s, \"" D_TODAY "\":%s%s, \"" D_POWERUSAGE "\":%s, \"" D_POWERFACTOR "\":%s, \"" D_VOLTAGE "\":%s, \"" D_CURRENT "\":%s}"),
|
||||
mqtt_data, stotal_energy, syesterday_energy, sdaily_energy, (option) ? speriod : "", swatts, spower_factor, svoltage, scurrent);
|
||||
|
||||
if (json) {
|
||||
snprintf_P(speriod, sizeof(speriod), PSTR(", \"" D_PERIOD "\":%s"), senergy);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_TOTAL "\":%s, \"" D_YESTERDAY "\":%s, \"" D_TODAY "\":%s%s, \"" D_POWERUSAGE "\":%s, \"" D_POWERFACTOR "\":%s, \"" D_VOLTAGE "\":%s, \"" D_CURRENT "\":%s}"),
|
||||
mqtt_data, stotal_energy, syesterday_energy, sdaily_energy, (option) ? speriod : "", swatts, spower_factor, svoltage, scurrent);
|
||||
#ifdef USE_DOMOTICZ
|
||||
if (option) { // Only send if telemetry
|
||||
dtostrfd(total_energy * 1000, 1, stotal_energy);
|
||||
DomoticzSensorPowerEnergy((uint16_t)watts, stotal_energy); // PowerUsage, EnergyToday
|
||||
DomoticzSensor(DZ_VOLTAGE, svoltage); // Voltage
|
||||
DomoticzSensor(DZ_CURRENT, scurrent); // Current
|
||||
}
|
||||
if (option) { // Only send if telemetry
|
||||
dtostrfd(total_energy * 1000, 1, stotal_energy);
|
||||
DomoticzSensorPowerEnergy((uint16_t)watts, stotal_energy); // PowerUsage, EnergyToday
|
||||
DomoticzSensor(DZ_VOLTAGE, svoltage); // Voltage
|
||||
DomoticzSensor(DZ_CURRENT, scurrent); // Current
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_ENERGY_SNS, svoltage, scurrent, swatts, spower_factor, sdaily_energy, syesterday_energy, stotal_energy);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
|
||||
void MqttShowHlw8012(byte option)
|
||||
|
@ -705,56 +721,17 @@ void MqttShowHlw8012(byte option)
|
|||
*/
|
||||
// {"Time":"2017-03-04T13:37:24", "Total":0.013, "Yesterday":0.013, "Today":0.000, "Period":0, "Power":0, "Factor":0.00, "Voltage":0, "Current":0.000}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_TIME "\":\"%s\", "), GetDateAndTime().c_str());
|
||||
HlwMqttStat(option);
|
||||
HlwShow(1, option);
|
||||
MqttPublishPrefixTopic_P(2, PSTR(D_RSLT_ENERGY), Settings.flag.mqtt_sensor_retain);
|
||||
}
|
||||
|
||||
void HlwMqttStatus()
|
||||
{
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS D_STATUS8_POWER "\":{"));
|
||||
HlwMqttStat(0);
|
||||
HlwShow(1, 0);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_ENERGY_SNS[] PROGMEM =
|
||||
"{s}" D_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}"
|
||||
"{s}" D_CURRENT "{m}%s " D_UNIT_AMPERE "{e}"
|
||||
"{s}" D_POWERUSAGE "{m}%s " D_UNIT_WATT "{e}"
|
||||
"{s}" D_POWER_FACTOR "{m}%s{e}"
|
||||
"{s}" D_ENERGY_TODAY "{m}%s " D_UNIT_KILOWATTHOUR "{e}"
|
||||
"{s}" D_ENERGY_YESTERDAY "{m}%s " D_UNIT_KILOWATTHOUR "{e}"
|
||||
"{s}" D_ENERGY_TOTAL "{m}%s " D_UNIT_KILOWATTHOUR "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
|
||||
void WebShowHlw()
|
||||
{
|
||||
float total_energy;
|
||||
float daily_energy;
|
||||
float energy;
|
||||
float watts;
|
||||
float voltage;
|
||||
float current;
|
||||
float power_factor;
|
||||
char stotal_energy[10];
|
||||
char sdaily_energy[10];
|
||||
char swatts[10];
|
||||
char svoltage[10];
|
||||
char scurrent[10];
|
||||
char spower_factor[10];
|
||||
char syesterday_energy[10];
|
||||
|
||||
HlwReadEnergy(0, total_energy, daily_energy, energy, watts, voltage, current, power_factor);
|
||||
dtostrfi(total_energy, Settings.flag.energy_resolution, stotal_energy);
|
||||
dtostrfi(daily_energy, Settings.flag.energy_resolution, sdaily_energy);
|
||||
dtostrfi(watts, Settings.flag.wattage_resolution, swatts);
|
||||
dtostrfi(voltage, Settings.flag.voltage_resolution, svoltage);
|
||||
dtostrfi(current, 3, scurrent);
|
||||
dtostrfi(power_factor, 2, spower_factor);
|
||||
dtostrfi((float)Settings.hlw_kWhyesterday / 100000000, Settings.flag.energy_resolution, syesterday_energy);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_ENERGY_SNS, svoltage, scurrent, swatts, spower_factor, sdaily_energy, syesterday_energy, stotal_energy);
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
@ -777,7 +754,7 @@ boolean Xsns03(byte function)
|
|||
// break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowHlw();
|
||||
HlwShow(0, 0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
|
|
@ -101,54 +101,40 @@ void SonoffScSerialInput(char *rcvstat)
|
|||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean MqttShowSonoffSC()
|
||||
{
|
||||
boolean json_data_available = false;
|
||||
|
||||
if (sc_value[0] > 0) {
|
||||
char stemp1[10];
|
||||
char stemp2[10];
|
||||
|
||||
float t = ConvertTemp(sc_value[1]);
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, stemp1);
|
||||
float h = sc_value[0];
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, stemp2);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_TEMPERATURE "\":%s, \"" D_HUMIDITY "\":%s, \"" D_LIGHT "\":%d, \"" D_NOISE "\":%d, \"" D_AIRQUALITY "\":%d"),
|
||||
mqtt_data, stemp1, stemp2, sc_value[2], sc_value[3], sc_value[4]);
|
||||
json_data_available = true;
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumSensor(stemp1, stemp2);
|
||||
DomoticzSensor(DZ_ILLUMINANCE, sc_value[2]);
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
return json_data_available;
|
||||
}
|
||||
/********************************************************************************************/
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_SNS_SCPLUS[] PROGMEM = "%s"
|
||||
"{s}" D_LIGHT "{m}%d%{e}"
|
||||
"{s}" D_NOISE "{m}%d%{e}"
|
||||
"{s}" D_AIR_QUALITY "{m}%d%{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
const char HTTP_SNS_SCPLUS[] PROGMEM =
|
||||
"%s{s}" D_LIGHT "{m}%d%{e}{s}" D_NOISE "{m}%d%{e}{s}" D_AIR_QUALITY "{m}%d%{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
void WebShowSonoffSc()
|
||||
void SonoffScShow(boolean json)
|
||||
{
|
||||
if (sc_value[0] > 0) {
|
||||
char stemp[10];
|
||||
char temperature[10];
|
||||
char humidity[10];
|
||||
|
||||
float t = ConvertTemp(sc_value[1]);
|
||||
dtostrfi(t, Settings.flag.temperature_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "", stemp, TempUnit());
|
||||
float h = sc_value[0];
|
||||
dtostrfi(h, Settings.flag.humidity_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, "", stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_SCPLUS, mqtt_data, sc_value[2], sc_value[3], sc_value[4]);
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, temperature);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, humidity);
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"" D_TEMPERATURE "\":%s, \"" D_HUMIDITY "\":%s, \"" D_LIGHT "\":%d, \"" D_NOISE "\":%d, \"" D_AIRQUALITY "\":%d"),
|
||||
mqtt_data, temperature, humidity, sc_value[2], sc_value[3], sc_value[4]);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumSensor(temperature, humidity);
|
||||
DomoticzSensor(DZ_ILLUMINANCE, sc_value[2]);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "", temperature, TempUnit());
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, "", humidity);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_SCPLUS, mqtt_data, sc_value[2], sc_value[3], sc_value[4]);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -167,11 +153,11 @@ boolean Xsns04(byte function)
|
|||
// case FUNC_XSNS_PREP:
|
||||
// break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowSonoffSC();
|
||||
SonoffScShow(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowSonoffSc();
|
||||
SonoffScShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
|
|
@ -181,41 +181,34 @@ boolean Ds18b20ReadTemperature(float &t)
|
|||
return !isnan(t);
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
|
||||
boolean MqttShowDs18b20()
|
||||
void Ds18b20Show(boolean json)
|
||||
{
|
||||
char stemp1[10];
|
||||
float t;
|
||||
boolean json_data_available = false;
|
||||
|
||||
if (Ds18b20ReadTemperature(t)) { // Check if read failed
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, stemp1);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"DS18B20\":{\"" D_TEMPERATURE "\":%s}"), mqtt_data, stemp1);
|
||||
json_data_available = true;
|
||||
char temperature[10];
|
||||
|
||||
dtostrfi(t, Settings.flag.temperature_resolution, temperature);
|
||||
|
||||
if(json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"DS18B20\":{\"" D_TEMPERATURE "\":%s}"), mqtt_data, temperature);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzSensor(DZ_TEMP, stemp1);
|
||||
DomoticzSensor(DZ_TEMP, temperature);
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
return json_data_available;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
void WebShowDs18b20()
|
||||
{
|
||||
float st;
|
||||
|
||||
if (Ds18b20ReadTemperature(st)) { // Check if read failed
|
||||
char stemp[10];
|
||||
|
||||
dtostrfi(st, Settings.flag.temperature_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "DS18B20", stemp, TempUnit());
|
||||
}
|
||||
Ds18b20ReadTempPrep();
|
||||
}
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "DS18B20", temperature, TempUnit());
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
#ifdef USE_WEBSERVER
|
||||
if (!json) {
|
||||
Ds18b20ReadTempPrep();
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -235,11 +228,11 @@ boolean Xsns05(byte function)
|
|||
Ds18b20ReadTempPrep();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowDs18b20();
|
||||
Ds18b20Show(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowDs18b20();
|
||||
Ds18b20Show(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
|
|
@ -143,79 +143,69 @@ boolean Ds18x20Read(uint8_t sensor, float &t)
|
|||
return (!isnan(t));
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
|
||||
void Ds18x20Type(uint8_t sensor)
|
||||
{
|
||||
strcpy_P(ds18x20_types, PSTR("DS18x20"));
|
||||
switch(ds18x20_address[ds18x20_index[sensor]][0]) {
|
||||
case DS18S20_CHIPID:
|
||||
strcpy_P(ds18x20_types, PSTR("DS18S20"));
|
||||
break;
|
||||
case DS18B20_CHIPID:
|
||||
strcpy_P(ds18x20_types, PSTR("DS18B20"));
|
||||
break;
|
||||
case MAX31850_CHIPID:
|
||||
strcpy_P(ds18x20_types, PSTR("MAX31850"));
|
||||
break;
|
||||
case DS18S20_CHIPID:
|
||||
strcpy_P(ds18x20_types, PSTR("DS18S20"));
|
||||
break;
|
||||
case DS18B20_CHIPID:
|
||||
strcpy_P(ds18x20_types, PSTR("DS18B20"));
|
||||
break;
|
||||
case MAX31850_CHIPID:
|
||||
strcpy_P(ds18x20_types, PSTR("MAX31850"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean MqttShowDs18x20()
|
||||
void Ds18x20Show(boolean json)
|
||||
{
|
||||
char stemp1[10];
|
||||
char stemp2[10];
|
||||
char temperature[10];
|
||||
char stemp[10];
|
||||
float t;
|
||||
boolean json_data_available = false;
|
||||
|
||||
byte dsxflg = 0;
|
||||
for (byte i = 0; i < Ds18x20Sensors(); i++) {
|
||||
if (Ds18x20Read(i, t)) { // Check if read failed
|
||||
Ds18x20Type(i);
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, stemp2);
|
||||
if (!dsxflg) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"DS18x20\":{"), mqtt_data);
|
||||
json_data_available = true;
|
||||
stemp1[0] = '\0';
|
||||
}
|
||||
dsxflg++;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s\"DS%d\":{\"" D_TYPE "\":\"%s\", \"" D_ADDRESS "\":\"%s\", \"" D_TEMPERATURE "\":%s}"),
|
||||
mqtt_data, stemp1, i +1, ds18x20_types, Ds18x20Addresses(i).c_str(), stemp2);
|
||||
strcpy(stemp1, ", ");
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, temperature);
|
||||
|
||||
if (json) {
|
||||
if (!dsxflg) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"DS18x20\":{"), mqtt_data);
|
||||
stemp[0] = '\0';
|
||||
}
|
||||
dsxflg++;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s\"DS%d\":{\"" D_TYPE "\":\"%s\", \"" D_ADDRESS "\":\"%s\", \"" D_TEMPERATURE "\":%s}"),
|
||||
mqtt_data, stemp, i +1, ds18x20_types, Ds18x20Addresses(i).c_str(), temperature);
|
||||
strcpy(stemp, ", ");
|
||||
#ifdef USE_DOMOTICZ
|
||||
if (1 == dsxflg) {
|
||||
DomoticzSensor(DZ_TEMP, stemp2);
|
||||
}
|
||||
if (1 == dsxflg) {
|
||||
DomoticzSensor(DZ_TEMP, temperature);
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
}
|
||||
if (dsxflg) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
||||
}
|
||||
return json_data_available;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
void WebShowDs18x20()
|
||||
{
|
||||
char stemp[10];
|
||||
char stemp2[16];
|
||||
float t;
|
||||
|
||||
for (byte i = 0; i < Ds18x20Sensors(); i++) {
|
||||
if (Ds18x20Read(i, t)) { // Check if read failed
|
||||
Ds18x20Type(i);
|
||||
dtostrfi(t, Settings.flag.temperature_resolution, stemp);
|
||||
snprintf_P(stemp2, sizeof(stemp2), PSTR("%s-%d"), ds18x20_types, i +1);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, stemp2, stemp, TempUnit());
|
||||
} else {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("%s-%d"), ds18x20_types, i +1);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, stemp, temperature, TempUnit());
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
Ds18x20Search(); // Check for changes in sensors number
|
||||
Ds18x20Convert(); // Start Conversion, takes up to one second
|
||||
}
|
||||
if (json) {
|
||||
if (dsxflg) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
||||
}
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
Ds18x20Search(); // Check for changes in sensors number
|
||||
Ds18x20Convert(); // Start Conversion, takes up to one second
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -237,11 +227,11 @@ boolean Xsns05(byte function)
|
|||
Ds18x20Convert(); // Start Conversion, takes up to one second
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowDs18x20();
|
||||
Ds18x20Show(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowDs18x20();
|
||||
Ds18x20Show(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
|
|
@ -194,6 +194,8 @@ boolean DhtSetup(byte pin, byte type)
|
|||
return success;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
void DhtInit()
|
||||
{
|
||||
dht_max_cycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for reading pulses from DHT sensor.
|
||||
|
@ -218,53 +220,36 @@ void DhtInit()
|
|||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean MqttShowDht()
|
||||
void DhtShow(boolean json)
|
||||
{
|
||||
char stemp1[10];
|
||||
char stemp2[10];
|
||||
char temperature[10];
|
||||
char humidity[10];
|
||||
float t;
|
||||
float h;
|
||||
boolean json_data_available = false;
|
||||
|
||||
byte dsxflg = 0;
|
||||
for (byte i = 0; i < dht_sensors; i++) {
|
||||
if (DhtReadTempHum(i, t, h)) { // Read temperature
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, stemp1);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, stemp2);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, Dht[i].stype, stemp1, stemp2);
|
||||
json_data_available = true;
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, temperature);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, humidity);
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, Dht[i].stype, temperature, humidity);
|
||||
#ifdef USE_DOMOTICZ
|
||||
if (!dsxflg) {
|
||||
DomoticzTempHumSensor(stemp1, stemp2);
|
||||
dsxflg++;
|
||||
}
|
||||
if (!dsxflg) {
|
||||
DomoticzTempHumSensor(temperature, humidity);
|
||||
dsxflg++;
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
}
|
||||
return json_data_available;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
void WebShowDht()
|
||||
{
|
||||
char stemp[10];
|
||||
float t;
|
||||
float h;
|
||||
|
||||
for (byte i = 0; i < dht_sensors; i++) {
|
||||
if (DhtReadTempHum(i, t, h)) {
|
||||
dtostrfi(t, Settings.flag.temperature_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, Dht[i].stype, stemp, TempUnit());
|
||||
dtostrfi(h, Settings.flag.humidity_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, Dht[i].stype, stemp);
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, Dht[i].stype, temperature, TempUnit());
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, Dht[i].stype, humidity);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -285,11 +270,11 @@ boolean Xsns06(byte function)
|
|||
DhtReadPrep();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowDht();
|
||||
DhtShow(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowDht();
|
||||
DhtShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
|
|
@ -159,6 +159,8 @@ boolean ShtReadTempHum(float &t, float &h)
|
|||
return (!isnan(t) && !isnan(h));
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
boolean ShtDetect()
|
||||
{
|
||||
if (sht_type) {
|
||||
|
@ -180,53 +182,33 @@ boolean ShtDetect()
|
|||
return sht_type;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean MqttShowSht()
|
||||
void ShtShow(boolean json)
|
||||
{
|
||||
if (!sht_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean json_data_available = false;
|
||||
float t;
|
||||
float h;
|
||||
|
||||
if (ShtReadTempHum(t, h)) {
|
||||
char stemp[10];
|
||||
char shum[10];
|
||||
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, stemp);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, shum);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, "SHT1X", stemp, shum);
|
||||
json_data_available = true;
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumSensor(stemp, shum);
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
return json_data_available;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
void WebShowSht()
|
||||
{
|
||||
float t;
|
||||
float h;
|
||||
|
||||
if (sht_type) {
|
||||
if (ShtReadTempHum(t, h)) {
|
||||
char stemp[10];
|
||||
float t;
|
||||
float h;
|
||||
|
||||
dtostrfi(t, Settings.flag.temperature_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "SHT1X", stemp, TempUnit());
|
||||
dtostrfi(h, Settings.flag.humidity_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, "SHT1X", stemp);
|
||||
if (ShtReadTempHum(t, h)) {
|
||||
char temperature[10];
|
||||
char humidity[10];
|
||||
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, temperature);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, humidity);
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, "SHT1X", temperature, humidity);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumSensor(temperature, humidity);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "SHT1X", temperature, TempUnit());
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, "SHT1X", humidity);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -238,20 +220,22 @@ boolean Xsns07(byte function)
|
|||
{
|
||||
boolean result = false;
|
||||
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
ShtDetect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowSht();
|
||||
break;
|
||||
if (i2c_flg) {
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
ShtDetect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
ShtShow(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowSht();
|
||||
break;
|
||||
case FUNC_XSNS_WEB:
|
||||
ShtShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -205,6 +205,8 @@ float HtuCompensatedHumidity(float humidity, float temperature)
|
|||
}
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
uint8_t HtuDetect()
|
||||
{
|
||||
if (htu_type) {
|
||||
|
@ -251,47 +253,31 @@ uint8_t HtuDetect()
|
|||
return success;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean MqttShowHtu()
|
||||
{
|
||||
if (!htu_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char stemp1[10];
|
||||
char stemp2[10];
|
||||
|
||||
float t = HtuReadTemperature();
|
||||
float h = HtuReadHumidity();
|
||||
h = HtuCompensatedHumidity(h, t);
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, stemp1);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, stemp2);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, htu_types, stemp1, stemp2);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumSensor(stemp1, stemp2);
|
||||
#endif // USE_DOMOTICZ
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
void WebShowHtu()
|
||||
void HtuShow(boolean json)
|
||||
{
|
||||
if (htu_type) {
|
||||
char stemp[10];
|
||||
char temperature[10];
|
||||
char humidity[10];
|
||||
|
||||
float t_htu21 = HtuReadTemperature();
|
||||
float h_htu21 = HtuReadHumidity();
|
||||
h_htu21 = HtuCompensatedHumidity(h_htu21, t_htu21);
|
||||
dtostrfi(t_htu21, Settings.flag.temperature_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, htu_types, stemp, TempUnit());
|
||||
dtostrfi(h_htu21, Settings.flag.humidity_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, htu_types, stemp);
|
||||
float t = HtuReadTemperature();
|
||||
float h = HtuReadHumidity();
|
||||
h = HtuCompensatedHumidity(h, t);
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, temperature);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, humidity);
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, htu_types, temperature, humidity);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumSensor(temperature, humidity);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, htu_types, temperature, TempUnit());
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, htu_types, humidity);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -303,20 +289,22 @@ boolean Xsns08(byte function)
|
|||
{
|
||||
boolean result = false;
|
||||
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
HtuDetect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowHtu();
|
||||
break;
|
||||
if (i2c_flg) {
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
HtuDetect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
HtuShow(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowHtu();
|
||||
break;
|
||||
case FUNC_XSNS_WEB:
|
||||
HtuShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -369,6 +369,8 @@ double BmpReadHumidity(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
boolean BmpDetect()
|
||||
{
|
||||
if (bmp_type) {
|
||||
|
@ -407,69 +409,50 @@ boolean BmpDetect()
|
|||
return success;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean MqttShowBmp()
|
||||
{
|
||||
if (!bmp_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char temperature[10];
|
||||
char pressure[10];
|
||||
char humidity[10];
|
||||
char sea_pressure[10];
|
||||
char sealevel[40];
|
||||
|
||||
double t = BmpReadTemperature();
|
||||
double p = BmpReadPressure();
|
||||
double h = BmpReadHumidity();
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, temperature);
|
||||
dtostrfd(p, Settings.flag.pressure_resolution, pressure);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, humidity);
|
||||
|
||||
dtostrfd(bmp_sealevel, Settings.flag.pressure_resolution, sea_pressure);
|
||||
snprintf_P(sealevel, sizeof(sealevel), PSTR(", \"" D_PRESSUREATSEALEVEL "\":%s"), sea_pressure);
|
||||
if (BME280_CHIPID == bmp_type) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_TEMPERATURE "\":%s, \"" D_HUMIDITY "\":%s, \"" D_PRESSURE "\":%s%s}"),
|
||||
mqtt_data, bmp_types, temperature, humidity, pressure, (Settings.altitude != 0) ? sealevel : "");
|
||||
}
|
||||
else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_TEMPERATURE "\":%s, \"" D_PRESSURE "\":%s%s}"),
|
||||
mqtt_data, bmp_types, temperature, pressure, (Settings.altitude != 0) ? sealevel : "");
|
||||
}
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumPressureSensor(temperature, humidity, pressure);
|
||||
#endif // USE_DOMOTICZ
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
void WebShowBmp()
|
||||
void BmpShow(boolean json)
|
||||
{
|
||||
if (bmp_type) {
|
||||
char stemp[10];
|
||||
char temperature[10];
|
||||
char pressure[10];
|
||||
char humidity[10];
|
||||
char sea_pressure[10];
|
||||
char sealevel[40];
|
||||
|
||||
double t = BmpReadTemperature();
|
||||
double p = BmpReadPressure();
|
||||
double h = BmpReadHumidity();
|
||||
dtostrfi(t, Settings.flag.temperature_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, bmp_types, stemp, TempUnit());
|
||||
if (BME280_CHIPID == bmp_type) {
|
||||
dtostrfi(h, Settings.flag.humidity_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, bmp_types, stemp);
|
||||
}
|
||||
dtostrfi(p, Settings.flag.pressure_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_PRESSURE, mqtt_data, bmp_types, stemp);
|
||||
if (Settings.altitude != 0) {
|
||||
dtostrfi(bmp_sealevel, Settings.flag.pressure_resolution, stemp);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_SEAPRESSURE, mqtt_data, bmp_types, stemp);
|
||||
dtostrfd(t, Settings.flag.temperature_resolution, temperature);
|
||||
dtostrfd(p, Settings.flag.pressure_resolution, pressure);
|
||||
dtostrfd(h, Settings.flag.humidity_resolution, humidity);
|
||||
dtostrfd(bmp_sealevel, Settings.flag.pressure_resolution, sea_pressure);
|
||||
|
||||
if (json) {
|
||||
snprintf_P(sealevel, sizeof(sealevel), PSTR(", \"" D_PRESSUREATSEALEVEL "\":%s"), sea_pressure);
|
||||
if (BME280_CHIPID == bmp_type) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_TEMPERATURE "\":%s, \"" D_HUMIDITY "\":%s, \"" D_PRESSURE "\":%s%s}"),
|
||||
mqtt_data, bmp_types, temperature, humidity, pressure, (Settings.altitude != 0) ? sealevel : "");
|
||||
}
|
||||
else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_TEMPERATURE "\":%s, \"" D_PRESSURE "\":%s%s}"),
|
||||
mqtt_data, bmp_types, temperature, pressure, (Settings.altitude != 0) ? sealevel : "");
|
||||
}
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzTempHumPressureSensor(temperature, humidity, pressure);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, bmp_types, temperature, TempUnit());
|
||||
if (BME280_CHIPID == bmp_type) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, bmp_types, humidity);
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_PRESSURE, mqtt_data, bmp_types, pressure);
|
||||
if (Settings.altitude != 0) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_SEAPRESSURE, mqtt_data, bmp_types, sea_pressure);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -481,20 +464,22 @@ boolean Xsns09(byte function)
|
|||
{
|
||||
boolean result = false;
|
||||
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
BmpDetect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowBmp();
|
||||
break;
|
||||
if (i2c_flg) {
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
BmpDetect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
BmpShow(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowBmp();
|
||||
break;
|
||||
case FUNC_XSNS_WEB:
|
||||
BmpShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ uint16_t Bh1750ReadLux()
|
|||
return value;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
boolean Bh1750Detect()
|
||||
{
|
||||
if (bh1750_type) {
|
||||
|
@ -74,35 +76,28 @@ boolean Bh1750Detect()
|
|||
return success;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean MqttShowBh1750()
|
||||
{
|
||||
if (!bh1750_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t l = Bh1750ReadLux();
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_ILLUMINANCE "\":%d}"), mqtt_data, bh1750_types, l);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzSensor(DZ_ILLUMINANCE, l);
|
||||
#endif // USE_DOMOTICZ
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_SNS_ILLUMINANCE[] PROGMEM =
|
||||
"%s{s}BH1750 " D_ILLUMINANCE "{m}%d " D_UNIT_LUX "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
void WebShowBh1750()
|
||||
void Bh1750Show(boolean json)
|
||||
{
|
||||
if (bh1750_type) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_ILLUMINANCE, mqtt_data, Bh1750ReadLux());
|
||||
uint16_t illuminance = Bh1750ReadLux();
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_ILLUMINANCE "\":%d}"), mqtt_data, bh1750_types, illuminance);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzSensor(DZ_ILLUMINANCE, illuminance);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_ILLUMINANCE, mqtt_data, illuminance);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -114,20 +109,22 @@ boolean Xsns10(byte function)
|
|||
{
|
||||
boolean result = false;
|
||||
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
Bh1750Detect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowBh1750();
|
||||
break;
|
||||
if (i2c_flg) {
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
Bh1750Detect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
Bh1750Show(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowBh1750();
|
||||
break;
|
||||
case FUNC_XSNS_WEB:
|
||||
Bh1750Show(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ uint16_t Veml6070ReadUv()
|
|||
return uvi;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
boolean Veml6070Detect()
|
||||
{
|
||||
if (veml6070_type) {
|
||||
|
@ -75,35 +77,28 @@ boolean Veml6070Detect()
|
|||
return success;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean MqttShowVeml6070()
|
||||
{
|
||||
if (!veml6070_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t uv = Veml6070ReadUv();
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_UV_LEVEL "\":%d}"), mqtt_data, veml6070_types, uv);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzSensor(DZ_ILLUMINANCE, uv);
|
||||
#endif // USE_DOMOTICZ
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_SNS_ULTRAVIOLET[] PROGMEM =
|
||||
"%s{s}VEML6070 " D_UV_LEVEL "{m}%d{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
void WebShowVeml6070()
|
||||
void Veml6070Show(boolean json)
|
||||
{
|
||||
if (veml6070_type) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_ULTRAVIOLET, mqtt_data, Veml6070ReadUv());
|
||||
uint16_t uvlevel = Veml6070ReadUv();
|
||||
|
||||
if (json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_UV_LEVEL "\":%d}"), mqtt_data, veml6070_types, uvlevel);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzSensor(DZ_ILLUMINANCE, uvlevel);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_ULTRAVIOLET, mqtt_data, uvlevel);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -115,20 +110,22 @@ boolean Xsns11(byte function)
|
|||
{
|
||||
boolean result = false;
|
||||
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
Veml6070Detect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
result = MqttShowVeml6070();
|
||||
break;
|
||||
if (i2c_flg) {
|
||||
switch (function) {
|
||||
// case FUNC_XSNS_INIT:
|
||||
// break;
|
||||
case FUNC_XSNS_PREP:
|
||||
Veml6070Detect();
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
Veml6070Show(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_XSNS_WEB:
|
||||
WebShowVeml6070();
|
||||
break;
|
||||
case FUNC_XSNS_WEB:
|
||||
Veml6070Show(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -19,91 +19,89 @@
|
|||
|
||||
void XSnsInit()
|
||||
{
|
||||
byte x;
|
||||
|
||||
for (x = 0; x < XSNS_MAX; x++) {
|
||||
xsns_func_ptr[x] = NULL;
|
||||
for (byte i = 0; i < XSNS_MAX; i++) {
|
||||
xsns_func_ptr[i] = NULL;
|
||||
}
|
||||
x = 0;
|
||||
xsns_present = 0;
|
||||
|
||||
#ifdef XSNS_01
|
||||
xsns_func_ptr[x++] = &Xsns01;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns01;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_02
|
||||
xsns_func_ptr[x++] = &Xsns02;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns02;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_03
|
||||
xsns_func_ptr[x++] = &Xsns03;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns03;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_04
|
||||
xsns_func_ptr[x++] = &Xsns04;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns04;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_05
|
||||
xsns_func_ptr[x++] = &Xsns05;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns05;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_06
|
||||
xsns_func_ptr[x++] = &Xsns06;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns06;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_07
|
||||
xsns_func_ptr[x++] = &Xsns07;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns07;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_08
|
||||
xsns_func_ptr[x++] = &Xsns08;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns08;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_09
|
||||
xsns_func_ptr[x++] = &Xsns09;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns09;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_10
|
||||
xsns_func_ptr[x++] = &Xsns10;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns10;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_11
|
||||
xsns_func_ptr[x++] = &Xsns11;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns11;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_12
|
||||
xsns_func_ptr[x++] = &Xsns12;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns12;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_13
|
||||
xsns_func_ptr[x++] = &Xsns13;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns13;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_14
|
||||
xsns_func_ptr[x++] = &Xsns14;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns14;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_15
|
||||
xsns_func_ptr[x++] = &Xsns15;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns15;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_16
|
||||
xsns_func_ptr[x++] = &Xsns16;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns16;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_17
|
||||
xsns_func_ptr[x++] = &Xsns17;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns17;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_18
|
||||
xsns_func_ptr[x++] = &Xsns18;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns18;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_19
|
||||
xsns_func_ptr[x++] = &Xsns19;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns19;
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_20
|
||||
xsns_func_ptr[x++] = &Xsns20;
|
||||
xsns_func_ptr[xsns_present++] = &Xsns20;
|
||||
#endif
|
||||
|
||||
XsnsCall(FUNC_XSNS_INIT);
|
||||
|
@ -120,20 +118,12 @@ boolean XsnsCall(byte Function)
|
|||
switch (Function) {
|
||||
case FUNC_XSNS_INIT:
|
||||
case FUNC_XSNS_PREP:
|
||||
case FUNC_XSNS_WEB:
|
||||
for (byte x = 0; x < XSNS_MAX; x++) {
|
||||
if (xsns_func_ptr[x]) {
|
||||
xsns_func_ptr[x](Function);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FUNC_XSNS_JSON:
|
||||
for (byte x = 0; x < XSNS_MAX; x++) {
|
||||
if (xsns_func_ptr[x]) {
|
||||
if (xsns_func_ptr[x](Function)) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
case FUNC_XSNS_WEB:
|
||||
for (byte x = 0; x < xsns_present; x++) {
|
||||
// if (xsns_func_ptr[x]) {
|
||||
xsns_func_ptr[x](Function);
|
||||
// }
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue