From 7a2b4a78475e34ee05e40c296681891f18fcfc3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 20 Dec 2017 14:12:56 +0100 Subject: [PATCH] Normal debug for sensors --- code/espurna/config/sensors.h | 4 +++- code/espurna/sensor.ino | 2 +- code/espurna/sensors/BaseSensor.h | 4 ++-- code/espurna/sensors/EmonSensor.h | 4 ++-- code/espurna/sensors/EventSensor.h | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index 6de54b25..9c094b26 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -2,7 +2,7 @@ // SENSORS // ----------------------------------------------------------------------------- -#define SENSOR_DEBUG 0 // Debug sensors (always to 0 in prod) +#define SENSOR_DEBUG 0 // Debug sensors #define SENSOR_READ_INTERVAL 6000 // Read data from sensors every 6 seconds #define SENSOR_REPORT_EVERY 10 // Report every this many readings @@ -295,6 +295,8 @@ // Embarrasing... unsigned char i2cFindFirst(size_t size, unsigned char * addresses); +void debugSend(const char * format, ...); +void debugSend_P(PGM_P format, ...); #include "sensors/BaseSensor.h" diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index aa9aafd9..4e7419d6 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -437,7 +437,7 @@ void sensorLoop() { _magnitudes[i].current = current; // Debug - #if true + #if SENSOR_DEBUG { dtostrf(current, 1-sizeof(buffer), decimals, buffer); DEBUG_MSG("[SENSOR] %s - %s: %s%s\n", diff --git a/code/espurna/sensors/BaseSensor.h b/code/espurna/sensors/BaseSensor.h index 2790edd4..abb7c514 100644 --- a/code/espurna/sensors/BaseSensor.h +++ b/code/espurna/sensors/BaseSensor.h @@ -96,14 +96,14 @@ class BaseSensor { // Interrupt attach callback void attached(unsigned char gpio) { #if SENSOR_DEBUG - Serial.printf("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, name().c_str()); + DEBUG_MSG("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, name().c_str()); #endif } // Interrupt detach callback void detached(unsigned char gpio) { #if SENSOR_DEBUG - Serial.printf("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, name().c_str()); + DEBUG_MSG("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, name().c_str()); #endif } diff --git a/code/espurna/sensors/EmonSensor.h b/code/espurna/sensors/EmonSensor.h index a77c3e99..05ac28af 100644 --- a/code/espurna/sensors/EmonSensor.h +++ b/code/espurna/sensors/EmonSensor.h @@ -67,8 +67,8 @@ class EmonSensor : public BaseSensor { } #if SENSOR_DEBUG - Serial.print("[EMON] Current ratio: "); Serial.println(ratio); - Serial.print("[EMON] Ref. Voltage: "); Serial.println(ref); + Serial.print("[EMON] Current ratio: "); Serial.println(_current_ratio); + Serial.print("[EMON] Ref. Voltage: "); Serial.println(_reference); Serial.print("[EMON] ADC Counts: "); Serial.println(_adc_counts); Serial.print("[EMON] Current factor: "); Serial.println(_current_factor); Serial.print("[EMON] Multiplier: "); Serial.println(_multiplier); diff --git a/code/espurna/sensors/EventSensor.h b/code/espurna/sensors/EventSensor.h index b4d588d2..8a14aa86 100644 --- a/code/espurna/sensors/EventSensor.h +++ b/code/espurna/sensors/EventSensor.h @@ -51,7 +51,7 @@ class EventSensor : public BaseSensor { // Descriptive name of the sensor String name() { char buffer[20]; - snprintf(buffer, sizeof(buffer), "EVENT @ GPIO%d", _gpio); + snprintf(buffer, sizeof(buffer), "INTERRUPT @ GPIO%d", _gpio); return String(buffer); }