diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index 50d8fa19..24a35b8e 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -204,56 +204,60 @@ void welcome() { DEBUG_MSG_P(PSTR(" WEB")); #endif - DEBUG_MSG_P(PSTR("\n[INIT] SENSORS:")); + #if SENSOR_SUPPORT - #if ANALOG_SUPPORT - DEBUG_MSG_P(PSTR(" ANALOG")); - #endif - #if BMX280_SUPPORT - DEBUG_MSG_P(PSTR(" BMX280")); - #endif - #if DALLAS_SUPPORT - DEBUG_MSG_P(PSTR(" DALLAS")); - #endif - #if DHT_SUPPORT - DEBUG_MSG_P(PSTR(" DHTXX")); - #endif - #if DIGITAL_SUPPORT - DEBUG_MSG_P(PSTR(" DIGITAL")); - #endif - #if ECH1560_SUPPORT - DEBUG_MSG_P(PSTR(" ECH1560")); - #endif - #if EMON_ADC121_SUPPORT - DEBUG_MSG_P(PSTR(" EMON_ADC121")); - #endif - #if EMON_ADS1X15_SUPPORT - DEBUG_MSG_P(PSTR(" EMON_ADX1X15")); - #endif - #if EMON_ANALOG_SUPPORT - DEBUG_MSG_P(PSTR(" EMON_ANALOG")); - #endif - #if EVENTS_SUPPORT - DEBUG_MSG_P(PSTR(" EVENTS")); - #endif - #if HLW8012_SUPPORT - DEBUG_MSG_P(PSTR(" HLW8012")); - #endif - #if MHZ19_SUPPORT - DEBUG_MSG_P(PSTR(" MHZ19")); - #endif - #if PMSX003_SUPPORT - DEBUG_MSG_P(PSTR(" PMSX003")); - #endif - #if SHT3X_I2C_SUPPORT - DEBUG_MSG_P(PSTR(" SHT3X_I2C")); - #endif - #if SI7021_SUPPORT - DEBUG_MSG_P(PSTR(" SI7021")); - #endif - #if V9261F_SUPPORT - DEBUG_MSG_P(PSTR(" V9261F")); - #endif + DEBUG_MSG_P(PSTR("\n[INIT] SENSORS:")); + + #if ANALOG_SUPPORT + DEBUG_MSG_P(PSTR(" ANALOG")); + #endif + #if BMX280_SUPPORT + DEBUG_MSG_P(PSTR(" BMX280")); + #endif + #if DALLAS_SUPPORT + DEBUG_MSG_P(PSTR(" DALLAS")); + #endif + #if DHT_SUPPORT + DEBUG_MSG_P(PSTR(" DHTXX")); + #endif + #if DIGITAL_SUPPORT + DEBUG_MSG_P(PSTR(" DIGITAL")); + #endif + #if ECH1560_SUPPORT + DEBUG_MSG_P(PSTR(" ECH1560")); + #endif + #if EMON_ADC121_SUPPORT + DEBUG_MSG_P(PSTR(" EMON_ADC121")); + #endif + #if EMON_ADS1X15_SUPPORT + DEBUG_MSG_P(PSTR(" EMON_ADX1X15")); + #endif + #if EMON_ANALOG_SUPPORT + DEBUG_MSG_P(PSTR(" EMON_ANALOG")); + #endif + #if EVENTS_SUPPORT + DEBUG_MSG_P(PSTR(" EVENTS")); + #endif + #if HLW8012_SUPPORT + DEBUG_MSG_P(PSTR(" HLW8012")); + #endif + #if MHZ19_SUPPORT + DEBUG_MSG_P(PSTR(" MHZ19")); + #endif + #if PMSX003_SUPPORT + DEBUG_MSG_P(PSTR(" PMSX003")); + #endif + #if SHT3X_I2C_SUPPORT + DEBUG_MSG_P(PSTR(" SHT3X_I2C")); + #endif + #if SI7021_SUPPORT + DEBUG_MSG_P(PSTR(" SI7021")); + #endif + #if V9261F_SUPPORT + DEBUG_MSG_P(PSTR(" V9261F")); + #endif + + #endif // SENSOR_SUPPORT DEBUG_MSG_P(PSTR("\n\n")); diff --git a/code/espurna/filters/BaseFilter.h b/code/espurna/filters/BaseFilter.h index fb422c32..ac693bb8 100644 --- a/code/espurna/filters/BaseFilter.h +++ b/code/espurna/filters/BaseFilter.h @@ -3,6 +3,8 @@ // Copyright (C) 2017 by Xose Pérez // ----------------------------------------------------------------------------- +#if SENSOR_SUPPORT + #pragma once #include @@ -46,3 +48,5 @@ class BaseFilter { std::vector _data; }; + +#endif // SENSOR_SUPPORT diff --git a/code/espurna/filters/MaxFilter.h b/code/espurna/filters/MaxFilter.h index 683e58f6..4121787d 100644 --- a/code/espurna/filters/MaxFilter.h +++ b/code/espurna/filters/MaxFilter.h @@ -3,6 +3,8 @@ // Copyright (C) 2017 by Xose Pérez // ----------------------------------------------------------------------------- +#if SENSOR_SUPPORT + #pragma once #include @@ -17,3 +19,5 @@ class MaxFilter : public BaseFilter { } }; + +#endif // SENSOR_SUPPORT diff --git a/code/espurna/filters/MedianFilter.h b/code/espurna/filters/MedianFilter.h index 531252a4..06295c85 100644 --- a/code/espurna/filters/MedianFilter.h +++ b/code/espurna/filters/MedianFilter.h @@ -3,6 +3,8 @@ // Copyright (C) 2017 by Xose Pérez // ----------------------------------------------------------------------------- +#if SENSOR_SUPPORT + #pragma once #include "BaseFilter.h" @@ -58,3 +60,5 @@ class MedianFilter : public BaseFilter { } }; + +#endif // SENSOR_SUPPORT diff --git a/code/espurna/filters/MovingAverageFilter.h b/code/espurna/filters/MovingAverageFilter.h index 0c48eff9..ce00dea7 100644 --- a/code/espurna/filters/MovingAverageFilter.h +++ b/code/espurna/filters/MovingAverageFilter.h @@ -3,6 +3,8 @@ // Copyright (C) 2017 by Xose Pérez // ----------------------------------------------------------------------------- +#if SENSOR_SUPPORT + #pragma once #include @@ -26,7 +28,7 @@ class MovingAverageFilter : public BaseFilter { } _pointer++; - + } void reset() { @@ -58,3 +60,5 @@ class MovingAverageFilter : public BaseFilter { double _sum = 0; }; + +#endif // SENSOR_SUPPORT diff --git a/code/espurna/mdns.ino b/code/espurna/mdns.ino index 4c185674..1cdc689e 100644 --- a/code/espurna/mdns.ino +++ b/code/espurna/mdns.ino @@ -16,9 +16,9 @@ WiFiEventHandler _mdns_wifi_onAP; #if MQTT_SUPPORT void mdnsFindMQTT() { int count = MDNS.queryService("mqtt", "tcp"); - DEBUG_MSG_P("[MQTT] MQTT brokers found: %d\n", count); + DEBUG_MSG_P(PSTR("[MQTT] MQTT brokers found: %d\n"), count); for (int i=0; ipre(); if (!_sensors[i]->status()) { - DEBUG_MSG("[SENSOR] Error reading data from %s (error: %d)\n", + DEBUG_MSG_P(PSTR("[SENSOR] Error reading data from %s (error: %d)\n"), _sensors[i]->description().c_str(), _sensors[i]->error() ); @@ -454,8 +454,8 @@ void _magnitudesInit() { BaseSensor * sensor = _sensors[i]; - DEBUG_MSG("[SENSOR] %s\n", sensor->description().c_str()); - if (sensor->error() != 0) DEBUG_MSG("[SENSOR] -> ERROR %d\n", sensor->error()); + DEBUG_MSG_P(PSTR("[SENSOR] %s\n"), sensor->description().c_str()); + if (sensor->error() != 0) DEBUG_MSG_P(PSTR("[SENSOR] -> ERROR %d\n"), sensor->error()); for (unsigned char k=0; kcount(); k++) { @@ -479,7 +479,7 @@ void _magnitudesInit() { } _magnitudes.push_back(new_magnitude); - DEBUG_MSG("[SENSOR] -> %s:%d\n", _magnitudeTopic(type).c_str(), _counts[type]); + DEBUG_MSG_P(PSTR("[SENSOR] -> %s:%d\n"), _magnitudeTopic(type).c_str(), _counts[type]); _counts[type] = _counts[type] + 1; @@ -595,7 +595,7 @@ void sensorLoop() { #if SENSOR_DEBUG { dtostrf(current, 1-sizeof(buffer), decimals, buffer); - DEBUG_MSG("[SENSOR] %s - %s: %s%s\n", + DEBUG_MSG_P(PSTR("[SENSOR] %s - %s: %s%s\n"), magnitude.sensor->slot(magnitude.local).c_str(), _magnitudeTopic(magnitude.type).c_str(), buffer, diff --git a/code/espurna/sensors/BMX280Sensor.h b/code/espurna/sensors/BMX280Sensor.h index 840b45d6..29d5aa2f 100644 --- a/code/espurna/sensors/BMX280Sensor.h +++ b/code/espurna/sensors/BMX280Sensor.h @@ -248,4 +248,4 @@ class BMX280Sensor : public I2CSensor { unsigned char BMX280Sensor::addresses[2] = {0x76, 0x77}; -// SENSOR_SUPPORT && BMX280_SUPPORT +#endif // SENSOR_SUPPORT && BMX280_SUPPORT diff --git a/code/espurna/sensors/ECH1560Sensor.h b/code/espurna/sensors/ECH1560Sensor.h index 67a97ea3..c4b87cbc 100644 --- a/code/espurna/sensors/ECH1560Sensor.h +++ b/code/espurna/sensors/ECH1560Sensor.h @@ -311,7 +311,7 @@ void ECH1560Sensor::_attach(ECH1560Sensor * instance, unsigned char gpio, unsign _ech1560_sensor_instance[index] = instance; attachInterrupt(gpio, _ech1560_sensor_isr_list[index], mode); #if SENSOR_DEBUG - DEBUG_MSG("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, instance->description().c_str()); + DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt attached to %s\n"), gpio, instance->description().c_str()); #endif } @@ -321,7 +321,7 @@ void ECH1560Sensor::_detach(unsigned char gpio) { if (_ech1560_sensor_instance[index]) { detachInterrupt(gpio); #if SENSOR_DEBUG - DEBUG_MSG("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, _ech1560_sensor_instance[index]->description().c_str()); + DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt detached from %s\n"), gpio, _ech1560_sensor_instance[index]->description().c_str()); #endif _ech1560_sensor_instance[index] = NULL; } diff --git a/code/espurna/sensors/EventSensor.h b/code/espurna/sensors/EventSensor.h index 6af9270d..c593be04 100644 --- a/code/espurna/sensors/EventSensor.h +++ b/code/espurna/sensors/EventSensor.h @@ -185,7 +185,7 @@ void EventSensor::_attach(EventSensor * instance, unsigned char gpio, unsigned c _event_sensor_instance[index] = instance; attachInterrupt(gpio, _event_sensor_isr_list[index], mode); #if SENSOR_DEBUG - DEBUG_MSG("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, instance->description().c_str()); + DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt attached to %s\n"), gpio, instance->description().c_str()); #endif } @@ -195,7 +195,7 @@ void EventSensor::_detach(unsigned char gpio) { if (_event_sensor_instance[index]) { detachInterrupt(gpio); #if SENSOR_DEBUG - DEBUG_MSG("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, _event_sensor_instance[index]->description().c_str()); + DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt detached from %s\n"), gpio, _event_sensor_instance[index]->description().c_str()); #endif _event_sensor_instance[index] = NULL; } diff --git a/code/espurna/sensors/HLW8012Sensor.h b/code/espurna/sensors/HLW8012Sensor.h index 59bebc6c..5a45241c 100644 --- a/code/espurna/sensors/HLW8012Sensor.h +++ b/code/espurna/sensors/HLW8012Sensor.h @@ -295,7 +295,7 @@ void HLW8012Sensor::_attach(HLW8012Sensor * instance, unsigned char gpio, unsign _hlw8012_sensor_instance[index] = instance; attachInterrupt(gpio, _hlw8012_sensor_isr_list[index], mode); #if SENSOR_DEBUG - DEBUG_MSG("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, instance->description().c_str()); + DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt attached to %s\n"), gpio, instance->description().c_str()); #endif } @@ -305,7 +305,7 @@ void HLW8012Sensor::_detach(unsigned char gpio) { if (_hlw8012_sensor_instance[index]) { detachInterrupt(gpio); #if SENSOR_DEBUG - DEBUG_MSG("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, _hlw8012_sensor_instance[index]->description().c_str()); + DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt detached from %s\n"), gpio, _hlw8012_sensor_instance[index]->description().c_str()); #endif _hlw8012_sensor_instance[index] = NULL; } diff --git a/code/espurna/sensors/I2CSensor.h b/code/espurna/sensors/I2CSensor.h index 44057ee6..f4391d03 100644 --- a/code/espurna/sensors/I2CSensor.h +++ b/code/espurna/sensors/I2CSensor.h @@ -3,7 +3,7 @@ // Copyright (C) 2017 by Xose Pérez // ----------------------------------------------------------------------------- -#if SENSOR_SUPPORT && I2C_SUPPORT +#if SENSOR_SUPPORT && ( I2C_SUPPORT || EMON_ANALOG_SUPPORT ) #pragma once