Browse Source

Split configuration file

fastled
Xose Pérez 8 years ago
parent
commit
9e96e0f21a
7 changed files with 149 additions and 104 deletions
  1. +5
    -0
      code/src/config/all.h
  2. +0
    -0
      code/src/config/debug.h
  3. +10
    -100
      code/src/config/general.h
  4. +76
    -0
      code/src/config/hardware.h
  5. +56
    -0
      code/src/config/sensors.h
  6. +1
    -1
      code/src/config/version.h
  7. +1
    -3
      code/src/main.ino

+ 5
- 0
code/src/config/all.h View File

@ -0,0 +1,5 @@
#include "version.h"
#include "debug.h"
#include "general.h"
#include "hardware.h"
#include "sensors.h"

code/src/debug.h → code/src/config/debug.h View File


code/src/defaults.h → code/src/config/general.h View File

@ -1,72 +1,19 @@
//------------------------------------------------------------------------------
// SET BY PLATFORMIO
// GENERAL
//------------------------------------------------------------------------------
//#define DEBUG_PORT Serial
//#define ESPURNA
//#define SONOFF
//#define SLAMPHER
//#define S20
//#define NODEMCUV2
//#define ENABLE_FAUXMO 1
//#define ENABLE_NOFUSS 1
//#define ENABLE_EMON 1
//#define ENABLE_DHT 1
//#define ENABLE_RF 1
//#define ENABLE_POW 1
// -----------------------------------------------------------------------------
// HARDWARE
// -----------------------------------------------------------------------------
#define SERIAL_BAUDRATE 115200
#define BUTTON_PIN 0
#define RELAY_PIN 12
#ifdef ESPURNA
#define MANUFACTURER "TINKERMAN"
#define DEVICE "ESPURNA"
#define LED_PIN 13
#endif
#ifdef SONOFF
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF"
#define LED_PIN 13
#endif
#ifdef SONOFF_POW
#define ENABLE_POW 1
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_POW"
#define LED_PIN 13
#endif
#ifdef SLAMPHER
#define MANUFACTURER "ITEAD"
#define DEVICE "SLAMPHER"
#define LED_PIN 13
#endif
#ifdef S20
#define MANUFACTURER "ITEAD"
#define DEVICE "S20"
#define LED_PIN 13
#endif
#ifdef NODEMCUV2
#define MANUFACTURER "NODEMCU"
#define DEVICE "LOLIN"
#define LED_PIN 2
#endif
#define HOSTNAME DEVICE
#define BUFFER_SIZE 1024
#define HEARTBEAT_INTERVAL 300000
#define FS_VERSION_FILE "/fsversion"
//--------------------------------------------------------------------------------
// RELAY
//--------------------------------------------------------------------------------
// 0 means OFF, 1 ON and 2 whatever was before
#define RELAY_MODE 1
// -----------------------------------------------------------------------------
// WIFI & WEB
@ -113,45 +60,8 @@
#define NTP_DAY_LIGHT true
#define NTP_UPDATE_INTERVAL 1800
//--------------------------------------------------------------------------------
// DRIVERS
//--------------------------------------------------------------------------------
// 0 means OFF, 1 ON and 2 whatever was before
#define RELAY_MODE 1
#define RF_PIN 14
#define RF_CHANNEL 31
#define RF_DEVICE 1
#define DHT_PIN 14
#define DHT_UPDATE_INTERVAL 300000
#define DHT_TYPE DHT22
#define DHT_TIMING 11
#define DHT_TEMPERATURE_TOPIC "/temperature"
#define DHT_HUMIDITY_TOPIC "/humidity"
#define EMON_CURRENT_PIN 0
#define EMON_SAMPLES 1000
#define EMON_INTERVAL 10000
#define EMON_MEASUREMENTS 6
#define EMON_ADC_BITS 10
#define EMON_REFERENCE_VOLTAGE 1.0
#define EMON_CURRENT_PRECISION 1
#define EMON_CURRENT_OFFSET 0.25
#define EMON_MAINS_VOLTAGE 230
#define EMON_CURRENT_RATIO 180
#define EMON_POWER_TOPIC "/power"
#define POW_SEL_PIN 5
#define POW_CF1_PIN 13
#define POW_CF_PIN 14
#define POW_SEL_CURRENT HIGH
#define POW_CURRENT_R 0.001
#define POW_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
#define POW_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
#define POW_POWER_TOPIC "/power"
#define POW_UPDATE_INTERVAL 10000
#define POW_REPORT_EVERY 6
// -----------------------------------------------------------------------------
// FAUXO
// -----------------------------------------------------------------------------
#define FAUXMO_ENABLED 0

+ 76
- 0
code/src/config/hardware.h View File

@ -0,0 +1,76 @@
// -----------------------------------------------------------------------------
// NODEMCUv2 development board
// -----------------------------------------------------------------------------
#if defined(NODEMCUV2)
#define MANUFACTURER "NODEMCU"
#define DEVICE "LOLIN"
#define BUTTON_PIN 0
#define RELAY_PIN 12
#define LED_PIN 2
// -----------------------------------------------------------------------------
// Itead Studio boards
// -----------------------------------------------------------------------------
#elif defined(SONOFF)
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF"
#define BUTTON_PIN 0
#define RELAY_PIN 12
#define LED_PIN 13
#elif defined(SONOFF_TH)
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_TH"
#define BUTTON_PIN 0
#define RELAY_PIN 12
#define LED_PIN 13
#elif defined(SONOFF_POW)
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_POW"
#define BUTTON_PIN 0
#define RELAY_PIN 12
#define LED_PIN 15
#define ENABLE_POW 1
#elif defined(SLAMPHER)
#define MANUFACTURER "ITEAD"
#define DEVICE "SLAMPHER"
#define BUTTON_PIN 0
#define RELAY_PIN 12
#define LED_PIN 13
#elif defined(S20)
#define MANUFACTURER "ITEAD"
#define DEVICE "S20"
#define BUTTON_PIN 0
#define RELAY_PIN 12
#define LED_PIN 13
// -----------------------------------------------------------------------------
// ESPurna board (still beta)
// -----------------------------------------------------------------------------
#elif defined(ESPURNA)
#define MANUFACTURER "TINKERMAN"
#define DEVICE "ESPURNA"
#define BUTTON_PIN 0
#define RELAY_PIN 12
#define LED_PIN 13
// -----------------------------------------------------------------------------
// Unknown hardware
// -----------------------------------------------------------------------------
#else
#error "UNSUPPORTED HARDWARE!"
#endif

+ 56
- 0
code/src/config/sensors.h View File

@ -0,0 +1,56 @@
//--------------------------------------------------------------------------------
// Custom RF module
// Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
// Enable support by passing ENABLE_RF=1 build flag
//--------------------------------------------------------------------------------
#define RF_PIN 14
#define RF_CHANNEL 31
#define RF_DEVICE 1
//--------------------------------------------------------------------------------
// DHTXX temperature/humidity sensor
// Enable support by passing ENABLE_DHT=1 build flag
//--------------------------------------------------------------------------------
#define DHT_PIN 14
#define DHT_UPDATE_INTERVAL 300000
#define DHT_TYPE DHT22
#define DHT_TIMING 11
#define DHT_TEMPERATURE_TOPIC "/temperature"
#define DHT_HUMIDITY_TOPIC "/humidity"
//--------------------------------------------------------------------------------
// Custom current sensor
// Check http://tinkerman.cat/your-laundry-is-done/
// Enable support by passing ENABLE_EMON=1 build flag
//--------------------------------------------------------------------------------
#define EMON_CURRENT_PIN 0
#define EMON_SAMPLES 1000
#define EMON_INTERVAL 10000
#define EMON_MEASUREMENTS 6
#define EMON_ADC_BITS 10
#define EMON_REFERENCE_VOLTAGE 1.0
#define EMON_CURRENT_PRECISION 1
#define EMON_CURRENT_OFFSET 0.25
#define EMON_MAINS_VOLTAGE 230
#define EMON_CURRENT_RATIO 180
#define EMON_POWER_TOPIC "/power"
//--------------------------------------------------------------------------------
// HLW8012 power sensor (Sonoff POW)
// Enable support by passing ENABLE_POW=1 build flag
// Enabled by default when selecting SONOFF_POW hardware
//--------------------------------------------------------------------------------
#define POW_SEL_PIN 5
#define POW_CF1_PIN 13
#define POW_CF_PIN 14
#define POW_SEL_CURRENT HIGH
#define POW_CURRENT_R 0.001
#define POW_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
#define POW_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
#define POW_POWER_TOPIC "/power"
#define POW_UPDATE_INTERVAL 10000
#define POW_REPORT_EVERY 6

code/src/version.h → code/src/config/version.h View File

@ -1,4 +1,4 @@
#define APP_NAME "Espurna"
#define APP_VERSION "1.0.2"
#define APP_VERSION "1.0.3"
#define APP_AUTHOR "xose.perez@gmail.com"
#define APP_WEBSITE "http://tinkerman.cat"

+ 1
- 3
code/src/main.ino View File

@ -19,9 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Arduino.h>
#include "defaults.h"
#include "version.h"
#include "debug.h"
#include "config/all.h"
// -----------------------------------------------------------------------------
// PROTOTYPES


Loading…
Cancel
Save