Browse Source

Normal debug for sensors

fastled
Xose Pérez 6 years ago
parent
commit
7a2b4a7847
5 changed files with 9 additions and 7 deletions
  1. +3
    -1
      code/espurna/config/sensors.h
  2. +1
    -1
      code/espurna/sensor.ino
  3. +2
    -2
      code/espurna/sensors/BaseSensor.h
  4. +2
    -2
      code/espurna/sensors/EmonSensor.h
  5. +1
    -1
      code/espurna/sensors/EventSensor.h

+ 3
- 1
code/espurna/config/sensors.h View File

@ -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"


+ 1
- 1
code/espurna/sensor.ino View File

@ -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",


+ 2
- 2
code/espurna/sensors/BaseSensor.h View File

@ -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
}


+ 2
- 2
code/espurna/sensors/EmonSensor.h View File

@ -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);


+ 1
- 1
code/espurna/sensors/EventSensor.h View File

@ -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);
}


Loading…
Cancel
Save