Fix compilation when webserver disabled

This commit is contained in:
Theo Arends 2023-10-06 12:17:37 +02:00
parent 21ac018d70
commit 74bcbd898e
8 changed files with 28 additions and 5 deletions

View File

@ -454,6 +454,7 @@ void PIDShowValues(void) {
ResponseAppend_P(PSTR("}")); ResponseAppend_P(PSTR("}"));
} }
#ifdef USE_WEBSERVER
void PIDShowValuesWeb(void) { void PIDShowValuesWeb(void) {
#define D_PID_DISPLAY_NAME "PID Controller" #define D_PID_DISPLAY_NAME "PID Controller"
@ -485,6 +486,7 @@ void PIDShowValuesWeb(void) {
WSContentSend_PD(HTTP_PID_POWER_FORMAT, D_PID_POWER, 0, &f_buf); WSContentSend_PD(HTTP_PID_POWER_FORMAT, D_PID_POWER, 0, &f_buf);
} }
} }
#endif // USE_WEBSERVER
void PIDRun(void) { void PIDRun(void) {
double power = Pid.pid.tick(Pid.current_time_secs); double power = Pid.pid.tick(Pid.current_time_secs);
@ -537,9 +539,11 @@ bool Xdrv49(uint32_t function) {
case FUNC_JSON_APPEND: case FUNC_JSON_APPEND:
PIDShowValues(); PIDShowValues();
break; break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR: case FUNC_WEB_SENSOR:
PIDShowValuesWeb(); PIDShowValuesWeb();
break; break;
#endif // USE_WEBSERVER
} }
return result; return result;
} }

View File

@ -708,7 +708,9 @@ extern "C" {
if (top == 2 && be_isstring(vm, 2)) { if (top == 2 && be_isstring(vm, 2)) {
const char *msg = be_tostring(vm, 2); const char *msg = be_tostring(vm, 2);
be_pop(vm, top); // avoid Error be_top is non zero message be_pop(vm, top); // avoid Error be_top is non zero message
#ifdef USE_WEBSERVER
WSContentSend_P(PSTR("%s"), msg); WSContentSend_P(PSTR("%s"), msg);
#endif // USE_WEBSERVER
be_return_nil(vm); // Return nil when something goes wrong be_return_nil(vm); // Return nil when something goes wrong
} }
be_raise(vm, kTypeError, nullptr); be_raise(vm, kTypeError, nullptr);
@ -721,7 +723,9 @@ extern "C" {
if (top == 2 && be_isstring(vm, 2)) { if (top == 2 && be_isstring(vm, 2)) {
const char *msg = be_tostring(vm, 2); const char *msg = be_tostring(vm, 2);
be_pop(vm, top); // avoid Error be_top is non zero message be_pop(vm, top); // avoid Error be_top is non zero message
#ifdef USE_WEBSERVER
WSContentSend_PD(PSTR("%s"), msg); WSContentSend_PD(PSTR("%s"), msg);
#endif // USE_WEBSERVER
be_return_nil(vm); // Return nil when something goes wrong be_return_nil(vm); // Return nil when something goes wrong
} }
be_raise(vm, kTypeError, nullptr); be_raise(vm, kTypeError, nullptr);

View File

@ -678,6 +678,7 @@ void MESHshow(bool json) {
} }
} else { } else {
#ifdef ESP32 //web UI only on the the broker = ESP32 #ifdef ESP32 //web UI only on the the broker = ESP32
#ifdef USE_WEBSERVER
if (ROLE_BROKER == MESH.role) { if (ROLE_BROKER == MESH.role) {
// WSContentSend_PD(PSTR("TAS-MESH:<br>")); // WSContentSend_PD(PSTR("TAS-MESH:<br>"));
WSContentSend_PD(PSTR("<b>Broker MAC</b> %s<br>"), WiFi.softAPmacAddress().c_str()); WSContentSend_PD(PSTR("<b>Broker MAC</b> %s<br>"), WiFi.softAPmacAddress().c_str());
@ -718,6 +719,7 @@ void MESHshow(bool json) {
idx++; idx++;
} }
} }
#endif // USE_WEBSERVER
#endif // ESP32 #endif // ESP32
} }
} }

View File

@ -237,11 +237,13 @@ void TTGO_WebShow(uint32_t json) {
ResponseAppend_P(PSTR(",\"BMAX\":%d,\"BMAY\":%d,\"BMAZ\":%d"),acc.x,acc.y,acc.z); ResponseAppend_P(PSTR(",\"BMAX\":%d,\"BMAY\":%d,\"BMAZ\":%d"),acc.x,acc.y,acc.z);
#endif #endif
ResponseJsonEnd(); ResponseJsonEnd();
#ifdef USE_WEBSERVER
} else { } else {
WSContentSend_PD(HTTP_TTGO,vstring,cstring,bvstring,bcstring,ttgo_adc.per,tstring); WSContentSend_PD(HTTP_TTGO,vstring,cstring,bvstring,bcstring,ttgo_adc.per,tstring);
#ifdef USE_BMA423 #ifdef USE_BMA423
WSContentSend_PD(HTTP_TTGO_BMA,acc.x,acc.y,acc.z); WSContentSend_PD(HTTP_TTGO_BMA,acc.x,acc.y,acc.z);
#endif // USE_BMA423 #endif // USE_BMA423
#endif // USE_WEBSERVER
} }
} }

View File

@ -167,7 +167,7 @@ uint8_t MCP230xx_readGPIO(uint8_t port) {
void MCP230xx_ApplySettings(void) void MCP230xx_ApplySettings(void)
{ {
#ifdef USE_MCP230xx_OUTPUT #ifdef USE_MCP230xx_OUTPUT
TasmotaGlobal.devices_present -= mcp230xx_outpincount; UpdateDevicesPresent(-mcp230xx_outpincount);
mcp230xx_outpincount = 0; mcp230xx_outpincount = 0;
for (uint32_t idx = 0; idx < mcp230xx_pincount; idx++) { for (uint32_t idx = 0; idx < mcp230xx_pincount; idx++) {
if (Settings->mcp230xx_config[idx].pinmode >= 5) { if (Settings->mcp230xx_config[idx].pinmode >= 5) {
@ -176,7 +176,7 @@ void MCP230xx_ApplySettings(void)
} }
int_millis[idx]=millis(); int_millis[idx]=millis();
} }
TasmotaGlobal.devices_present += mcp230xx_outpincount; UpdateDevicesPresent(mcp230xx_outpincount);
#endif // USE_MCP230xx_OUTPUT #endif // USE_MCP230xx_OUTPUT
uint8_t int_en = 0; uint8_t int_en = 0;
uint8_t reg_portpins[mcp230xx_type]; uint8_t reg_portpins[mcp230xx_type];
@ -793,6 +793,7 @@ bool MCP230xx_Command(void)
return serviced; return serviced;
} }
#ifdef USE_WEBSERVER
#ifdef USE_MCP230xx_OUTPUT #ifdef USE_MCP230xx_OUTPUT
#ifdef USE_MCP230xx_DISPLAYOUTPUT #ifdef USE_MCP230xx_DISPLAYOUTPUT
@ -815,8 +816,9 @@ void MCP230xx_UpdateWebData(void)
} }
} }
#endif // USE_MCP230xx_DISPLAYOUTPUT #endif // USE_MCP230xx_DISPLAYOUTPUT
#endif // USE_MCP230xx_OUTPUT #endif // USE_MCP230xx_OUTPUT
#endif // USE_WEBSERVER
/* /*
#ifdef USE_MCP230xx_OUTPUT #ifdef USE_MCP230xx_OUTPUT

View File

@ -2375,9 +2375,11 @@ void SML_Show(boolean json) {
tpowstr[i] = *mp++; tpowstr[i] = *mp++;
} }
tpowstr[i] = 0; tpowstr[i] = 0;
#ifdef USE_WEBSERVER
// export html // export html
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s{s}%s{e}", b_mqtt_data,tpowstr); //snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s{s}%s{e}", b_mqtt_data,tpowstr);
WSContentSend_PD(PSTR("{s}%s{e}"), tpowstr); WSContentSend_PD(PSTR("{s}%s{e}"), tpowstr);
#endif // USE_WEBSERVER
// rewind, to ensure strchr // rewind, to ensure strchr
mp--; mp--;
mp = strchr(mp, '|'); mp = strchr(mp, '|');
@ -2491,11 +2493,12 @@ void SML_Show(boolean json) {
} }
} }
} }
#ifdef USE_WEBSERVER
} else { } else {
// web ui export // web ui export
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s{s}%s %s: {m}%s %s{e}", b_mqtt_data,meter_desc[mindex].prefix,name,tpowstr,unit); //snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s{s}%s %s: {m}%s %s{e}", b_mqtt_data,meter_desc[mindex].prefix,name,tpowstr,unit);
if (strcmp(name, "*")) WSContentSend_PD(PSTR("{s}%s %s {m}%s %s{e}"), sml_globs.mp[mindex].prefix, name,tpowstr, unit); if (strcmp(name, "*")) WSContentSend_PD(PSTR("{s}%s %s {m}%s %s{e}"), sml_globs.mp[mindex].prefix, name,tpowstr, unit);
#endif // USE_WEBSERVER
} }
} }
} }
@ -2512,8 +2515,10 @@ void SML_Show(boolean json) {
if (!nojson) { if (!nojson) {
ResponseAppend_P(PSTR("}")); ResponseAppend_P(PSTR("}"));
} }
#ifdef USE_WEBSERVER
} else { } else {
//WSContentSend_PD(PSTR("%s"),b_mqtt_data); //WSContentSend_PD(PSTR("%s"),b_mqtt_data);
#endif // USE_WEBSERVER
} }

View File

@ -43,10 +43,12 @@ struct EZOHUM : public EZOStruct {
virtual void Show(bool json, const char *name) virtual void Show(bool json, const char *name)
{ {
if (isnan(temperature)) { if (isnan(temperature)) {
#ifdef USE_WEBSERVER
char parameter[FLOATSZ]; char parameter[FLOATSZ];
dtostrfd(humidity, Settings->flag2.humidity_resolution, parameter); dtostrfd(humidity, Settings->flag2.humidity_resolution, parameter);
WSContentSend_PD(HTTP_SNS_HUM, name, parameter); WSContentSend_PD(HTTP_SNS_HUM, name, parameter);
#endif // USE_WEBSERVER
} else { } else {
TempHumDewShow(json, (0 == TasmotaGlobal.tele_period), name, temperature, humidity); TempHumDewShow(json, (0 == TasmotaGlobal.tele_period), name, temperature, humidity);
} }

View File

@ -60,6 +60,7 @@ void MPU_Show(uint32_t json) {
mpu_sensor.mpu_model, mpu_sensor.mpu_model,
mpu_sensor.ax, mpu_sensor.ay, mpu_sensor.az, mpu_sensor.ax, mpu_sensor.ay, mpu_sensor.az,
mpu_sensor.gyx, mpu_sensor.gyy, mpu_sensor.gyz); mpu_sensor.gyx, mpu_sensor.gyy, mpu_sensor.gyz);
#ifdef USE_WEBSERVER
} else { } else {
float ax = mpu_sensor.ax / 1000.0f; float ax = mpu_sensor.ax / 1000.0f;
float ay = mpu_sensor.ay / 1000.0f; float ay = mpu_sensor.ay / 1000.0f;
@ -67,6 +68,7 @@ void MPU_Show(uint32_t json) {
WSContentSend_PD(HTTP_MPU6686, mpu_sensor.mpu_model, &ax, mpu_sensor.mpu_model, &ay, mpu_sensor.mpu_model, &az, WSContentSend_PD(HTTP_MPU6686, mpu_sensor.mpu_model, &ax, mpu_sensor.mpu_model, &ay, mpu_sensor.mpu_model, &az,
mpu_sensor.mpu_model, mpu_sensor.gyx, mpu_sensor.mpu_model, mpu_sensor.gyy, mpu_sensor.mpu_model, mpu_sensor.gyz); mpu_sensor.mpu_model, mpu_sensor.gyx, mpu_sensor.mpu_model, mpu_sensor.gyy, mpu_sensor.mpu_model, mpu_sensor.gyz);
#endif // USE_WEBSERVER
} }
} }