Browse Source

ONly add support for I2C if required, set all I2C sensors to auto-discover

fastled
Xose Pérez 6 years ago
parent
commit
0459e8ee19
4 changed files with 58 additions and 36 deletions
  1. +1
    -1
      code/espurna/config/all.h
  2. +0
    -22
      code/espurna/config/general.h
  3. +11
    -4
      code/espurna/config/prototypes.h
  4. +46
    -9
      code/espurna/config/sensors.h

+ 1
- 1
code/espurna/config/all.h View File

@ -1,9 +1,9 @@
#include "version.h" #include "version.h"
#include "arduino.h" #include "arduino.h"
#include "hardware.h" #include "hardware.h"
#include "prototypes.h"
#include "general.h" #include "general.h"
#include "sensors.h" #include "sensors.h"
#include "prototypes.h"
#ifdef USE_CORE_VERSION_H #ifdef USE_CORE_VERSION_H
#include "core_version.h" #include "core_version.h"


+ 0
- 22
code/espurna/config/general.h View File

@ -659,28 +659,6 @@ PROGMEM const char* const custom_reset_string[] = {
#endif #endif
// -----------------------------------------------------------------------------
// I2C
// -----------------------------------------------------------------------------
#ifndef I2C_SUPPORT
#define I2C_SUPPORT 1 // I2C enabled (1.98Kb)
#endif
#define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire
#ifndef I2C_SDA_PIN
#define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4)
#endif
#ifndef I2C_SCL_PIN
#define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14)
#endif
#define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time
#define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency
#define I2C_CLEAR_BUS 0 // Clear I2C bus at boot
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// DOMOTICZ // DOMOTICZ
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 11
- 4
code/espurna/config/prototypes.h View File

@ -48,21 +48,28 @@ template<typename T> bool setSetting(const String& key, unsigned int index, T va
template<typename T> String getSetting(const String& key, T defaultValue); template<typename T> String getSetting(const String& key, T defaultValue);
template<typename T> String getSetting(const String& key, unsigned int index, T defaultValue); template<typename T> String getSetting(const String& key, unsigned int index, T defaultValue);
// -----------------------------------------------------------------------------
// I2C
// -----------------------------------------------------------------------------
unsigned char i2cFindFirst(size_t size, unsigned char * addresses);
// -----------------------------------------------------------------------------
// Debug
// -----------------------------------------------------------------------------
void debugSend(const char * format, ...);
void debugSend_P(PGM_P format, ...);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Domoticz // Domoticz
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if DOMOTICZ_SUPPORT
template<typename T> void domoticzSend(const char * key, T value); template<typename T> void domoticzSend(const char * key, T value);
template<typename T> void domoticzSend(const char * key, T nvalue, const char * svalue); template<typename T> void domoticzSend(const char * key, T nvalue, const char * svalue);
#endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// InfluxDB // InfluxDB
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if INFLUXDB_SUPPORT
template<typename T> bool idbSend(const char * topic, T payload); template<typename T> bool idbSend(const char * topic, T payload);
template<typename T> bool idbSend(const char * topic, unsigned char id, T payload); template<typename T> bool idbSend(const char * topic, unsigned char id, T payload);
#endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Light // Light


+ 46
- 9
code/espurna/config/sensors.h View File

@ -97,7 +97,7 @@
#endif #endif
#ifndef BMX280_ADDRESS #ifndef BMX280_ADDRESS
#define BMX280_ADDRESS 0
#define BMX280_ADDRESS 0x00 // 0x00 means auto
#endif #endif
#define BMX280_MODE 1 // 1 for forced mode, 3 for normal mode #define BMX280_MODE 1 // 1 for forced mode, 3 for normal mode
@ -105,6 +105,11 @@
#define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280) #define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280)
#define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude) #define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude)
#if BMX280_SUPPORT
#undef I2C_SUPPORT
#define I2C_SUPPORT 1
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Dallas OneWire temperature sensors // Dallas OneWire temperature sensors
// Enable support by passing DALLAS_SUPPORT=1 build flag // Enable support by passing DALLAS_SUPPORT=1 build flag
@ -185,7 +190,12 @@
#define EMON_ADC121_SUPPORT 0 // Do not build support by default #define EMON_ADC121_SUPPORT 0 // Do not build support by default
#endif #endif
#define EMON_ADC121_I2C_ADDRESS 0x50 // I2C address of the ADC121
#define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto
#if EMON_ADC121_SUPPORT
#undef I2C_SUPPORT
#define I2C_SUPPORT 1
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Energy Monitor based on ADS1X15 // Energy Monitor based on ADS1X15
@ -196,11 +206,16 @@
#define EMON_ADS1X15_SUPPORT 0 // Do not build support by default #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
#endif #endif
#define EMON_ADS1X15_I2C_ADDRESS 0x48 // I2C address of the ADS1115
#define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto
#define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115 #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115
#define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V
#define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A4=8 #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A4=8
#if EMON_ADS1X15_SUPPORT
#undef I2C_SUPPORT
#define I2C_SUPPORT 1
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Energy Monitor based on interval analog GPIO // Energy Monitor based on interval analog GPIO
// Enable support by passing EMON_ANALOG_SUPPORT=1 build flag // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
@ -272,9 +287,36 @@
#endif #endif
#ifndef SI7021_ADDRESS #ifndef SI7021_ADDRESS
#define SI7021_ADDRESS 0x40
#define SI7021_ADDRESS 0x00 // 0x00 means auto
#endif
#if SI7021_SUPPORT
#undef I2C_SUPPORT
#define I2C_SUPPORT 1
#endif #endif
// -----------------------------------------------------------------------------
// I2C
// -----------------------------------------------------------------------------
#ifndef I2C_SUPPORT
#define I2C_SUPPORT 0 // I2C enabled (1.98Kb)
#endif
#define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire
#ifndef I2C_SDA_PIN
#define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4)
#endif
#ifndef I2C_SCL_PIN
#define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14)
#endif
#define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time
#define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency
#define I2C_CLEAR_BUS 0 // Clear I2C bus at boot
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Internal power monitor // Internal power monitor
// Enable support by passing ADC_VCC_ENABLED=1 build flag // Enable support by passing ADC_VCC_ENABLED=1 build flag
@ -293,11 +335,6 @@
// Class loading // Class loading
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 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" #include "sensors/BaseSensor.h"
#if ANALOG_SUPPORT #if ANALOG_SUPPORT


Loading…
Cancel
Save