From 69cbb056a3c486d70101cd31e50034852855d7e1 Mon Sep 17 00:00:00 2001 From: Lazar Obradovic Date: Thu, 5 Apr 2018 16:29:01 +0800 Subject: [PATCH] isolate PROGMEM Isolated dependencies sensors dependencies enums, macros and prototypes. I2C dependencies moved to actual sensor files. definitelly redefine --- code/espurna/config/all.h | 3 + code/espurna/config/defaults.h | 8 - code/espurna/config/dependencies.h | 76 +++++++++ code/espurna/config/general.h | 192 +-------------------- code/espurna/config/progmem.h | 97 +++++++++++ code/espurna/config/prototypes.h | 17 ++ code/espurna/config/sensors.h | 205 +---------------------- code/espurna/config/types.h | 231 ++++++++++++++++++++++++++ code/espurna/sensors/AM2320Sensor.h | 3 + code/espurna/sensors/BH1750Sensor.h | 3 + code/espurna/sensors/BMX280Sensor.h | 3 + code/espurna/sensors/EmonSensor.h | 4 + code/espurna/sensors/SHT3XI2CSensor.h | 4 + code/espurna/sensors/SI7021Sensor.h | 5 + 14 files changed, 451 insertions(+), 400 deletions(-) create mode 100644 code/espurna/config/dependencies.h create mode 100644 code/espurna/config/progmem.h create mode 100644 code/espurna/config/types.h diff --git a/code/espurna/config/all.h b/code/espurna/config/all.h index dfa31e3f..3581bb66 100644 --- a/code/espurna/config/all.h +++ b/code/espurna/config/all.h @@ -24,12 +24,15 @@ #endif #include "version.h" +#include "types.h" #include "arduino.h" #include "hardware.h" #include "defaults.h" #include "general.h" #include "prototypes.h" #include "sensors.h" +#include "progmem.h" +#include "dependencies.h" #ifdef USE_CORE_VERSION_H #include "core_version.h" diff --git a/code/espurna/config/defaults.h b/code/espurna/config/defaults.h index 86e25993..8a5a37f2 100644 --- a/code/espurna/config/defaults.h +++ b/code/espurna/config/defaults.h @@ -404,14 +404,6 @@ #define HOSTNAME "" #endif -// Needed for ESP8285 boards under Windows using PlatformIO (?) -#ifndef BUTTON_PUSHBUTTON -#define BUTTON_PUSHBUTTON 0 -#define BUTTON_SWITCH 1 -#define BUTTON_DEFAULT_HIGH 2 -#define BUTTON_SET_PULLUP 4 -#endif - // Relay providers #ifndef RELAY_PROVIDER #define RELAY_PROVIDER RELAY_PROVIDER_RELAY diff --git a/code/espurna/config/dependencies.h b/code/espurna/config/dependencies.h new file mode 100644 index 00000000..f88b6c77 --- /dev/null +++ b/code/espurna/config/dependencies.h @@ -0,0 +1,76 @@ +#ifndef DEPENDENCIES_H +#define DEPENDENCIES_H + +//------------------------------------------------------------------------------ +// Do not change this file unless you know what you are doing +// Configuration settings are in the settings.h file +//------------------------------------------------------------------------------ + + +#if DEBUG_TELNET_SUPPORT +#undef TELNET_SUPPORT +#define TELNET_SUPPORT 1 +#endif + +#ifndef DEBUG_WEB_SUPPORT +#define DEBUG_WEB_SUPPORT WEB_SUPPORT // Enable web debug log if web is enabled too +#endif + +#if DEBUG_WEB_SUPPORT +#undef WEB_SUPPORT +#define WEB_SUPPORT 1 // Chicken and egg :) +#endif + +#if WEB_SUPPORT == 0 +#undef SSDP_SUPPORT +#define SSDP_SUPPORT 0 // SSDP support requires web support +#endif + +#if UART_MQTT_SUPPORT +#define MQTT_SUPPORT 1 +#undef TERMINAL_SUPPORT +#define TERMINAL_SUPPORT 0 +#undef DEBUG_SERIAL_SUPPORT +#define DEBUG_SERIAL_SUPPORT 0 +#endif + +#if DOMOTICZ_SUPPORT +#undef MQTT_SUPPORT +#define MQTT_SUPPORT 1 // If Domoticz enabled enable MQTT +#endif + +#if HOMEASSISTANT_SUPPORT +#undef MQTT_SUPPORT +#define MQTT_SUPPORT 1 // If Home Assistant enabled enable MQTT +#endif + +#ifndef ASYNC_TCP_SSL_ENABLED +#if THINGSPEAK_USE_SSL && THINGSPEAK_USE_ASYNC +#undef THINGSPEAK_SUPPORT // Thingspeak in ASYNC mode requires ASYNC_TCP_SSL_ENABLED +#endif +#endif + +#if SCHEDULER_SUPPORT +#undef NTP_SUPPORT +#define NTP_SUPPORT 1 // Scheduler needs NTP +#endif + +//------------------------------------------------------------------------------ +// Sensors +//------------------------------------------------------------------------------ + + +#if ANALOG_SUPPORT +#undef ADC_VCC_ENABLED +#define ADC_VCC_ENABLED 0 +#endif + +#if EMON_ANALOG_SUPPORT +#undef ADC_VCC_ENABLED +#define ADC_VCC_ENABLED 0 +#endif + +// I2C dependencies moved to actual sensor files. + +//------------------------------------------------------------------------------ +#endif // DEPENDENCIES_H diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 3da0ba83..05889d89 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -12,9 +12,6 @@ #define USE_PASSWORD 1 // Insecurity caution! Disabling this will disable password querying completely. #define LOOP_DELAY_TIME 10 // Delay for this millis in the main loop [0-250] -#define ARRAYINIT(type, name, ...) \ - type name[] = {__VA_ARGS__}; - //------------------------------------------------------------------------------ // TELNET //------------------------------------------------------------------------------ @@ -75,33 +72,15 @@ // To receive the message son the destination computer use nc: // nc -ul 8113 -#ifndef DEBUG_UDP_SUPPORT -#define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log -#endif -#define DEBUG_UDP_IP IPAddress(192, 168, 1, 100) -#define DEBUG_UDP_PORT 8113 - -//------------------------------------------------------------------------------ - #ifndef DEBUG_TELNET_SUPPORT #define DEBUG_TELNET_SUPPORT TELNET_SUPPORT // Enable telnet debug log if telnet is enabled too #endif -#if DEBUG_TELNET_SUPPORT -#undef TELNET_SUPPORT -#define TELNET_SUPPORT 1 -#endif - -//------------------------------------------------------------------------------ - -#ifndef DEBUG_WEB_SUPPORT -#define DEBUG_WEB_SUPPORT WEB_SUPPORT // Enable web debug log if web is enabled too -#endif - -#if DEBUG_WEB_SUPPORT -#undef WEB_SUPPORT -#define WEB_SUPPORT 1 // Chicken and egg :) +#ifndef DEBUG_UDP_SUPPORT +#define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log #endif +#define DEBUG_UDP_IP IPAddress(192, 168, 1, 100) +#define DEBUG_UDP_PORT 8113 #define DEBUG_WEB_ENABLED 1 // Enable debug output by default @@ -110,16 +89,6 @@ // General debug options and macros #define DEBUG_SUPPORT DEBUG_SERIAL_SUPPORT || DEBUG_UDP_SUPPORT || DEBUG_TELNET_SUPPORT -#if DEBUG_SUPPORT - #define DEBUG_MSG(...) debugSend(__VA_ARGS__) - #define DEBUG_MSG_P(...) debugSend_P(__VA_ARGS__) -#endif - -#ifndef DEBUG_MSG - #define DEBUG_MSG(...) - #define DEBUG_MSG_P(...) -#endif - //------------------------------------------------------------------------------ // TERMINAL //------------------------------------------------------------------------------ @@ -190,40 +159,6 @@ #define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms) #define LOADAVG_REPORT 1 // Should we report Load average over MQTT? -//------------------------------------------------------------------------------ -// RESET -//------------------------------------------------------------------------------ - -#define CUSTOM_RESET_HARDWARE 1 // Reset from hardware button -#define CUSTOM_RESET_WEB 2 // Reset from web interface -#define CUSTOM_RESET_TERMINAL 3 // Reset from terminal -#define CUSTOM_RESET_MQTT 4 // Reset via MQTT -#define CUSTOM_RESET_RPC 5 // Reset via RPC (HTTP) -#define CUSTOM_RESET_OTA 6 // Reset after successful OTA update -#define CUSTOM_RESET_HTTP 7 // Reset via HTTP GET -#define CUSTOM_RESET_NOFUSS 8 // Reset after successful NOFUSS update -#define CUSTOM_RESET_UPGRADE 9 // Reset after update from web interface -#define CUSTOM_RESET_FACTORY 10 // Factory reset from terminal - -#define CUSTOM_RESET_MAX 10 - -PROGMEM const char custom_reset_hardware[] = "Hardware button"; -PROGMEM const char custom_reset_web[] = "Reboot from web interface"; -PROGMEM const char custom_reset_terminal[] = "Reboot from terminal"; -PROGMEM const char custom_reset_mqtt[] = "Reboot from MQTT"; -PROGMEM const char custom_reset_rpc[] = "Reboot from RPC"; -PROGMEM const char custom_reset_ota[] = "Reboot after successful OTA update"; -PROGMEM const char custom_reset_http[] = "Reboot from HTTP"; -PROGMEM const char custom_reset_nofuss[] = "Reboot after successful NoFUSS update"; -PROGMEM const char custom_reset_upgrade[] = "Reboot after successful web update"; -PROGMEM const char custom_reset_factory[] = "Factory reset"; -PROGMEM const char* const custom_reset_string[] = { - custom_reset_hardware, custom_reset_web, custom_reset_terminal, - custom_reset_mqtt, custom_reset_rpc, custom_reset_ota, - custom_reset_http, custom_reset_nofuss, custom_reset_upgrade, - custom_reset_factory -}; - //------------------------------------------------------------------------------ // BUTTON //------------------------------------------------------------------------------ @@ -244,52 +179,10 @@ PROGMEM const char* const custom_reset_string[] = { #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click #endif -#define BUTTON_EVENT_NONE 0 -#define BUTTON_EVENT_PRESSED 1 -#define BUTTON_EVENT_RELEASED 2 -#define BUTTON_EVENT_CLICK 2 -#define BUTTON_EVENT_DBLCLICK 3 -#define BUTTON_EVENT_LNGCLICK 4 -#define BUTTON_EVENT_LNGLNGCLICK 5 - -#define BUTTON_MODE_NONE 0 -#define BUTTON_MODE_TOGGLE 1 -#define BUTTON_MODE_ON 2 -#define BUTTON_MODE_OFF 3 -#define BUTTON_MODE_AP 4 -#define BUTTON_MODE_RESET 5 -#define BUTTON_MODE_PULSE 6 -#define BUTTON_MODE_FACTORY 7 - //------------------------------------------------------------------------------ // RELAY //------------------------------------------------------------------------------ -#define RELAY_BOOT_OFF 0 -#define RELAY_BOOT_ON 1 -#define RELAY_BOOT_SAME 2 -#define RELAY_BOOT_TOGGLE 3 - -#define RELAY_TYPE_NORMAL 0 -#define RELAY_TYPE_INVERSE 1 -#define RELAY_TYPE_LATCHED 2 -#define RELAY_TYPE_LATCHED_INVERSE 3 - -#define RELAY_SYNC_ANY 0 -#define RELAY_SYNC_NONE_OR_ONE 1 -#define RELAY_SYNC_ONE 2 -#define RELAY_SYNC_SAME 3 - -#define RELAY_PULSE_NONE 0 -#define RELAY_PULSE_OFF 1 -#define RELAY_PULSE_ON 2 - -#define RELAY_PROVIDER_RELAY 0 -#define RELAY_PROVIDER_DUAL 1 -#define RELAY_PROVIDER_LIGHT 2 -#define RELAY_PROVIDER_RFBRIDGE 3 -#define RELAY_PROVIDER_STM 4 - // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before #define RELAY_BOOT_MODE RELAY_BOOT_OFF @@ -314,20 +207,6 @@ PROGMEM const char* const custom_reset_string[] = { // Do not save relay state after these many milliseconds #define RELAY_SAVE_DELAY 1000 -//------------------------------------------------------------------------------ -// LED -//------------------------------------------------------------------------------ - -#define LED_MODE_MQTT 0 // LED will be managed from MQTT (OFF by default) -#define LED_MODE_WIFI 1 // LED will blink according to the WIFI status -#define LED_MODE_FOLLOW 2 // LED will follow state of linked relay (check RELAY#_LED) -#define LED_MODE_FOLLOW_INVERSE 3 // LED will follow the opposite state of linked relay (check RELAY#_LED) -#define LED_MODE_FINDME 4 // LED will be ON if all relays are OFF -#define LED_MODE_FINDME_WIFI 5 // A mixture between WIFI and FINDME -#define LED_MODE_ON 6 // LED always ON -#define LED_MODE_OFF 7 // LED always OFF -#define LED_MODE_RELAY 8 // If any relay is ON, LED will be ON, otherwise OFF -#define LED_MODE_RELAY_WIFI 9 // A mixture between WIFI and RELAY, the reverse of MIXED // ----------------------------------------------------------------------------- // WIFI @@ -425,14 +304,6 @@ PROGMEM const char* const custom_reset_string[] = { #define API_BUFFER_SIZE 15 // Size of the buffer for HTTP GET API responses #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time) -// ----------------------------------------------------------------------------- -// UI -// ----------------------------------------------------------------------------- - -#define UI_TAG_INPUT 0 -#define UI_TAG_CHECKBOX 1 -#define UI_TAG_SELECT 2 - // ----------------------------------------------------------------------------- // MDNS / LLMNR / NETBIOS / SSDP // ----------------------------------------------------------------------------- @@ -463,10 +334,6 @@ PROGMEM const char* const custom_reset_string[] = { //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1" #endif -#if WEB_SUPPORT == 0 -#undef SSDP_SUPPORT -#define SSDP_SUPPORT 0 // SSDP support requires web support -#endif // ----------------------------------------------------------------------------- // SPIFFS @@ -510,14 +377,6 @@ PROGMEM const char* const custom_reset_string[] = { #define UART_MQTT_BAUDRATE 115200 // Serial speed #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size -#if UART_MQTT_SUPPORT -#define MQTT_SUPPORT 1 -#undef TERMINAL_SUPPORT -#define TERMINAL_SUPPORT 0 -#undef DEBUG_SERIAL_SUPPORT -#define DEBUG_SERIAL_SUPPORT 0 -#endif - // ----------------------------------------------------------------------------- // MQTT // ----------------------------------------------------------------------------- @@ -674,11 +533,6 @@ PROGMEM const char* const custom_reset_string[] = { // LIGHT // ----------------------------------------------------------------------------- -// Available light providers (do not change) -#define LIGHT_PROVIDER_NONE 0 -#define LIGHT_PROVIDER_MY92XX 1 // works with MY9291 and MY9231 -#define LIGHT_PROVIDER_DIMMER 2 - // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels. // They have to be defined for each device in the hardware.h file. // If 3 or more channels first 3 will be considered RGB. @@ -738,11 +592,6 @@ PROGMEM const char* const custom_reset_string[] = { #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb) #endif -#if DOMOTICZ_SUPPORT -#undef MQTT_SUPPORT -#define MQTT_SUPPORT 1 // If Domoticz enabled enable MQTT -#endif - #define DOMOTICZ_ENABLED 0 // Disable domoticz by default #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic @@ -755,11 +604,6 @@ PROGMEM const char* const custom_reset_string[] = { #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb) #endif -#if HOMEASSISTANT_SUPPORT -#undef MQTT_SUPPORT -#define MQTT_SUPPORT 1 // If Home Assistant enabled enable MQTT -#endif - #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix @@ -807,28 +651,14 @@ PROGMEM const char* const custom_reset_string[] = { #define THINGSPEAK_URL "/update" #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis) -#ifndef ASYNC_TCP_SSL_ENABLED -#if THINGSPEAK_USE_SSL && THINGSPEAK_USE_ASYNC -#undef THINGSPEAK_SUPPORT // Thingspeak in ASYNC mode requires ASYNC_TCP_SSL_ENABLED -#endif -#endif - // ----------------------------------------------------------------------------- // SCHEDULER // ----------------------------------------------------------------------------- -#define SCHEDULER_TYPE_SWITCH 1 -#define SCHEDULER_TYPE_DIM 2 - #ifndef SCHEDULER_SUPPORT #define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb) #endif -#if SCHEDULER_SUPPORT -#undef NTP_SUPPORT -#define NTP_SUPPORT 1 // Scheduler needs NTP -#endif - #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed // ----------------------------------------------------------------------------- @@ -891,20 +721,6 @@ PROGMEM const char* const custom_reset_string[] = { #define IR_BUTTON_SET 1 // IR button set to use (see below) #endif -// IR Button modes -#define IR_BUTTON_MODE_NONE 0 -#define IR_BUTTON_MODE_RGB 1 -#define IR_BUTTON_MODE_HSV 2 -#define IR_BUTTON_MODE_BRIGHTER 3 -#define IR_BUTTON_MODE_STATE 4 -#define IR_BUTTON_MODE_EFFECT 5 - -#define LIGHT_EFFECT_SOLID 0 -#define LIGHT_EFFECT_FLASH 1 -#define LIGHT_EFFECT_STROBE 2 -#define LIGHT_EFFECT_FADE 3 -#define LIGHT_EFFECT_SMOOTH 4 - //Remote Buttons SET 1 (for the original Remote shipped with the controller) #if IR_SUPPORT #if IR_BUTTON_SET == 1 diff --git a/code/espurna/config/progmem.h b/code/espurna/config/progmem.h new file mode 100644 index 00000000..12c6a24e --- /dev/null +++ b/code/espurna/config/progmem.h @@ -0,0 +1,97 @@ +//-------------------------------------------------------------------------------- +// General PROGMEM definitions +//-------------------------------------------------------------------------------- + + +PROGMEM const char custom_reset_hardware[] = "Hardware button"; +PROGMEM const char custom_reset_web[] = "Reboot from web interface"; +PROGMEM const char custom_reset_terminal[] = "Reboot from terminal"; +PROGMEM const char custom_reset_mqtt[] = "Reboot from MQTT"; +PROGMEM const char custom_reset_rpc[] = "Reboot from RPC"; +PROGMEM const char custom_reset_ota[] = "Reboot after successful OTA update"; +PROGMEM const char custom_reset_http[] = "Reboot from HTTP"; +PROGMEM const char custom_reset_nofuss[] = "Reboot after successful NoFUSS update"; +PROGMEM const char custom_reset_upgrade[] = "Reboot after successful web update"; +PROGMEM const char custom_reset_factory[] = "Factory reset"; +PROGMEM const char* const custom_reset_string[] = { + custom_reset_hardware, custom_reset_web, custom_reset_terminal, + custom_reset_mqtt, custom_reset_rpc, custom_reset_ota, + custom_reset_http, custom_reset_nofuss, custom_reset_upgrade, + custom_reset_factory +}; + +#if SENSOR_SUPPORT + +PROGMEM const unsigned char magnitude_decimals[] = { + 0, + 1, 0, 2, + 3, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0 +}; + +PROGMEM const char magnitude_unknown_topic[] = "unknown"; +PROGMEM const char magnitude_temperature_topic[] = "temperature"; +PROGMEM const char magnitude_humidity_topic[] = "humidity"; +PROGMEM const char magnitude_pressure_topic[] = "pressure"; +PROGMEM const char magnitude_current_topic[] = "current"; +PROGMEM const char magnitude_voltage_topic[] = "voltage"; +PROGMEM const char magnitude_active_power_topic[] = "power"; +PROGMEM const char magnitude_apparent_power_topic[] = "apparent"; +PROGMEM const char magnitude_reactive_power_topic[] = "reactive"; +PROGMEM const char magnitude_power_factor_topic[] = "factor"; +PROGMEM const char magnitude_energy_topic[] = "energy"; +PROGMEM const char magnitude_energy_delta_topic[] = "energy_delta"; +PROGMEM const char magnitude_analog_topic[] = "analog"; +PROGMEM const char magnitude_digital_topic[] = "digital"; +PROGMEM const char magnitude_events_topic[] = "events"; +PROGMEM const char magnitude_pm1dot0_topic[] = "pm1dot0"; +PROGMEM const char magnitude_pm2dot5_topic[] = "pm2dot5"; +PROGMEM const char magnitude_pm10_topic[] = "pm10"; +PROGMEM const char magnitude_co2_topic[] = "co2"; +PROGMEM const char magnitude_lux_topic[] = "lux"; +PROGMEM const char magnitude_uv_topic[] = "uv"; +PROGMEM const char magnitude_distance_topic[] = "distance"; + +PROGMEM const char* const magnitude_topics[] = { + magnitude_unknown_topic, magnitude_temperature_topic, magnitude_humidity_topic, + magnitude_pressure_topic, magnitude_current_topic, magnitude_voltage_topic, + magnitude_active_power_topic, magnitude_apparent_power_topic, magnitude_reactive_power_topic, + magnitude_power_factor_topic, magnitude_energy_topic, magnitude_energy_delta_topic, + magnitude_analog_topic, magnitude_digital_topic, magnitude_events_topic, + magnitude_pm1dot0_topic, magnitude_pm2dot5_topic, magnitude_pm10_topic, + magnitude_co2_topic, magnitude_lux_topic, magnitude_uv_topic, + magnitude_distance_topic +}; + +PROGMEM const char magnitude_empty[] = ""; +PROGMEM const char magnitude_celsius[] = "C"; +PROGMEM const char magnitude_fahrenheit[] = "F"; +PROGMEM const char magnitude_percentage[] = "%"; +PROGMEM const char magnitude_hectopascals[] = "hPa"; +PROGMEM const char magnitude_amperes[] = "A"; +PROGMEM const char magnitude_volts[] = "V"; +PROGMEM const char magnitude_watts[] = "W"; +PROGMEM const char magnitude_kw[] = "kW"; +PROGMEM const char magnitude_joules[] = "J"; +PROGMEM const char magnitude_kwh[] = "kWh"; +PROGMEM const char magnitude_ugm3[] = "µg/m3"; +PROGMEM const char magnitude_ppm[] = "ppm"; +PROGMEM const char magnitude_lux[] = "lux"; +PROGMEM const char magnitude_uv[] = "uv"; +PROGMEM const char magnitude_distance[] = "m"; + +PROGMEM const char* const magnitude_units[] = { + magnitude_empty, magnitude_celsius, magnitude_percentage, + magnitude_hectopascals, magnitude_amperes, magnitude_volts, + magnitude_watts, magnitude_watts, magnitude_watts, + magnitude_percentage, magnitude_joules, magnitude_joules, + magnitude_empty, magnitude_empty, magnitude_empty, + magnitude_ugm3, magnitude_ugm3, magnitude_ugm3, + magnitude_ppm, magnitude_lux, magnitude_uv, + magnitude_distance + +}; + +#endif diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h index eb010715..6351f205 100644 --- a/code/espurna/config/prototypes.h +++ b/code/espurna/config/prototypes.h @@ -116,3 +116,20 @@ template void domoticzSend(const char * key, T nvalue, const char * // ----------------------------------------------------------------------------- char * ltrim(char * s); void nice_delay(unsigned long ms); + +// ----------------------------------------------------------------------------- +// Macros +// ----------------------------------------------------------------------------- + +#define ARRAYINIT(type, name, ...) \ + type name[] = {__VA_ARGS__}; + +#if DEBUG_SUPPORT + #define DEBUG_MSG(...) debugSend(__VA_ARGS__) + #define DEBUG_MSG_P(...) debugSend_P(__VA_ARGS__) +#endif + +#ifndef DEBUG_MSG + #define DEBUG_MSG(...) + #define DEBUG_MSG_P(...) +#endif diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index ce9d128f..a7d6fb55 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -36,40 +36,9 @@ #define HUMIDITY_MIN_CHANGE 0 // Minimum humidity change to report #endif -// American Society of Heating, Refrigerating and Air-Conditioning Engineers suggests a range of 45% - 55% humidity to manage health effects and illnesses. -// Comfortable: 30% - 60% -// Recommended: 45% - 55% -// High : 55% - 80% -#define HUMIDITY_NORMAL 0 // > %30 -#define HUMIDITY_COMFORTABLE 1 // > %45 -#define HUMIDITY_DRY 2 // < %30 -#define HUMIDITY_WET 3 // > %70 - -// United States Environmental Protection Agency - UV Index Scale -// One UV Index unit is equivalent to 25 milliWatts per square meter. -#define UV_INDEX_LOW 0 // 0 to 2 means low danger from the sun's UV rays for the average person. -#define UV_INDEX_MODERATE 1 // 3 to 5 means moderate risk of harm from unprotected sun exposure. -#define UV_INDEX_HIGH 2 // 6 to 7 means high risk of harm from unprotected sun exposure. Protection against skin and eye damage is needed. -#define UV_INDEX_VERY_HIGH 3 // 8 to 10 means very high risk of harm from unprotected sun exposure. - // Take extra precautions because unprotected skin and eyes will be damaged and can burn quickly. -#define UV_INDEX_EXTREME 4 // 11 or more means extreme risk of harm from unprotected sun exposure. - // Take all precautions because unprotected skin and eyes can burn in minutes. - #define SENSOR_PUBLISH_ADDRESSES 0 // Publish sensor addresses #define SENSOR_ADDRESS_TOPIC "address" // Topic to publish sensor addresses -//------------------------------------------------------------------------------ -// UNITS -//------------------------------------------------------------------------------ - -#define POWER_WATTS 0 -#define POWER_KILOWATTS 1 - -#define ENERGY_JOULES 0 -#define ENERGY_KWH 1 - -#define TMP_CELSIUS 0 -#define TMP_FAHRENHEIT 1 #ifndef SENSOR_TEMPERATURE_UNITS #define SENSOR_TEMPERATURE_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT) @@ -83,63 +52,6 @@ #define SENSOR_POWER_UNITS POWER_WATTS // Power units (POWER_WATTS | POWER_KILOWATTS) #endif -//-------------------------------------------------------------------------------- -// Sensor ID -// These should remain over time, do not modify them, only add new ones at the end -//-------------------------------------------------------------------------------- - -#define SENSOR_DHTXX_ID 0x01 -#define SENSOR_DALLAS_ID 0x02 -#define SENSOR_EMON_ANALOG_ID 0x03 -#define SENSOR_EMON_ADC121_ID 0x04 -#define SENSOR_EMON_ADS1X15_ID 0x05 -#define SENSOR_HLW8012_ID 0x06 -#define SENSOR_V9261F_ID 0x07 -#define SENSOR_ECH1560_ID 0x08 -#define SENSOR_ANALOG_ID 0x09 -#define SENSOR_DIGITAL_ID 0x10 -#define SENSOR_EVENTS_ID 0x11 -#define SENSOR_PMSX003_ID 0x12 -#define SENSOR_BMX280_ID 0x13 -#define SENSOR_MHZ19_ID 0x14 -#define SENSOR_SI7021_ID 0x15 -#define SENSOR_SHT3X_I2C_ID 0x16 -#define SENSOR_BH1750_ID 0x17 -#define SENSOR_PZEM004T_ID 0x18 -#define SENSOR_AM2320_ID 0x19 -#define SENSOR_GUVAS12SD_ID 0x20 -#define SENSOR_CSE7766_ID 0x21 -#define SENSOR_TMP3X_ID 0x22 -#define SENSOR_HCSR04_ID 0x23 - -//-------------------------------------------------------------------------------- -// Magnitudes -//-------------------------------------------------------------------------------- - -#define MAGNITUDE_NONE 0 -#define MAGNITUDE_TEMPERATURE 1 -#define MAGNITUDE_HUMIDITY 2 -#define MAGNITUDE_PRESSURE 3 -#define MAGNITUDE_CURRENT 4 -#define MAGNITUDE_VOLTAGE 5 -#define MAGNITUDE_POWER_ACTIVE 6 -#define MAGNITUDE_POWER_APPARENT 7 -#define MAGNITUDE_POWER_REACTIVE 8 -#define MAGNITUDE_POWER_FACTOR 9 -#define MAGNITUDE_ENERGY 10 -#define MAGNITUDE_ENERGY_DELTA 11 -#define MAGNITUDE_ANALOG 12 -#define MAGNITUDE_DIGITAL 13 -#define MAGNITUDE_EVENTS 14 -#define MAGNITUDE_PM1dot0 15 -#define MAGNITUDE_PM2dot5 16 -#define MAGNITUDE_PM10 17 -#define MAGNITUDE_CO2 18 -#define MAGNITUDE_LUX 19 -#define MAGNITUDE_UV 20 -#define MAGNITUDE_DISTANCE 21 - -#define MAGNITUDE_MAX 22 // ============================================================================= // Specific data for each sensor @@ -154,10 +66,6 @@ #define ANALOG_SUPPORT 0 #endif -#if ANALOG_SUPPORT -#undef ADC_VCC_ENABLED -#define ADC_VCC_ENABLED 0 -#endif //------------------------------------------------------------------------------ // BH1750 @@ -175,10 +83,6 @@ #define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE -#if BH1750_SUPPORT -#undef I2C_SUPPORT -#define I2C_SUPPORT 1 -#endif //------------------------------------------------------------------------------ // BME280/BMP280 @@ -202,11 +106,6 @@ #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) -#if BMX280_SUPPORT -#undef I2C_SUPPORT -#define I2C_SUPPORT 1 -#endif - //------------------------------------------------------------------------------ // Dallas OneWire temperature sensors // Enable support by passing DALLAS_SUPPORT=1 build flag @@ -331,11 +230,6 @@ #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 // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag @@ -350,11 +244,6 @@ #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8 -#if EMON_ADS1X15_SUPPORT -#undef I2C_SUPPORT -#define I2C_SUPPORT 1 -#endif - //------------------------------------------------------------------------------ // Energy Monitor based on interval analog GPIO // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag @@ -364,11 +253,6 @@ #define EMON_ANALOG_SUPPORT 0 // Do not build support by default #endif -#if EMON_ANALOG_SUPPORT -#undef ADC_VCC_ENABLED -#define ADC_VCC_ENABLED 0 -#endif - //------------------------------------------------------------------------------ // Counter sensor // Enable support by passing EVENTS_SUPPORT=1 build flag @@ -511,11 +395,6 @@ #define SHT3X_I2C_ADDRESS 0x00 // 0x00 means auto #endif -#if SHT3X_I2C_SUPPORT -#undef I2C_SUPPORT -#define I2C_SUPPORT 1 -#endif - //------------------------------------------------------------------------------ // SI7021 temperature & humidity sensor // Enable support by passing SI7021_SUPPORT=1 build flag @@ -529,11 +408,6 @@ #define SI7021_ADDRESS 0x00 // 0x00 means auto #endif -#if SI7021_SUPPORT -#undef I2C_SUPPORT -#define I2C_SUPPORT 1 -#endif - //------------------------------------------------------------------------------ // TMP3X analog temperature sensor // Enable support by passing TMP3X_SUPPORT=1 build flag @@ -591,11 +465,6 @@ #define AM2320_ADDRESS 0x00 // 0x00 means auto #endif -#if AM2320_SUPPORT -#undef I2C_SUPPORT -#define I2C_SUPPORT 1 -#endif - //------------------------------------------------------------------------------ // GUVAS12SD UV Sensor (analog) // Enable support by passing GUVAS12SD_SUPPORT=1 build flag @@ -610,7 +479,7 @@ #endif // ============================================================================= -// Sensor helpers configuration +// Sensor helpers configuration - can't move to dependencies.h // ============================================================================= #ifndef SENSOR_SUPPORT @@ -671,78 +540,6 @@ #if SENSOR_SUPPORT -PROGMEM const unsigned char magnitude_decimals[] = { - 0, - 1, 0, 2, - 3, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, - 2, 3 -}; - -PROGMEM const char magnitude_unknown_topic[] = "unknown"; -PROGMEM const char magnitude_temperature_topic[] = "temperature"; -PROGMEM const char magnitude_humidity_topic[] = "humidity"; -PROGMEM const char magnitude_pressure_topic[] = "pressure"; -PROGMEM const char magnitude_current_topic[] = "current"; -PROGMEM const char magnitude_voltage_topic[] = "voltage"; -PROGMEM const char magnitude_active_power_topic[] = "power"; -PROGMEM const char magnitude_apparent_power_topic[] = "apparent"; -PROGMEM const char magnitude_reactive_power_topic[] = "reactive"; -PROGMEM const char magnitude_power_factor_topic[] = "factor"; -PROGMEM const char magnitude_energy_topic[] = "energy"; -PROGMEM const char magnitude_energy_delta_topic[] = "energy_delta"; -PROGMEM const char magnitude_analog_topic[] = "analog"; -PROGMEM const char magnitude_digital_topic[] = "digital"; -PROGMEM const char magnitude_events_topic[] = "events"; -PROGMEM const char magnitude_pm1dot0_topic[] = "pm1dot0"; -PROGMEM const char magnitude_pm2dot5_topic[] = "pm2dot5"; -PROGMEM const char magnitude_pm10_topic[] = "pm10"; -PROGMEM const char magnitude_co2_topic[] = "co2"; -PROGMEM const char magnitude_lux_topic[] = "lux"; -PROGMEM const char magnitude_uv_topic[] = "uv"; -PROGMEM const char magnitude_distance_topic[] = "distance"; - -PROGMEM const char* const magnitude_topics[] = { - magnitude_unknown_topic, magnitude_temperature_topic, magnitude_humidity_topic, - magnitude_pressure_topic, magnitude_current_topic, magnitude_voltage_topic, - magnitude_active_power_topic, magnitude_apparent_power_topic, magnitude_reactive_power_topic, - magnitude_power_factor_topic, magnitude_energy_topic, magnitude_energy_delta_topic, - magnitude_analog_topic, magnitude_digital_topic, magnitude_events_topic, - magnitude_pm1dot0_topic, magnitude_pm2dot5_topic, magnitude_pm10_topic, - magnitude_co2_topic, magnitude_lux_topic, magnitude_uv_topic, - magnitude_distance_topic -}; - -PROGMEM const char magnitude_empty[] = ""; -PROGMEM const char magnitude_celsius[] = "C"; -PROGMEM const char magnitude_fahrenheit[] = "F"; -PROGMEM const char magnitude_percentage[] = "%"; -PROGMEM const char magnitude_hectopascals[] = "hPa"; -PROGMEM const char magnitude_amperes[] = "A"; -PROGMEM const char magnitude_volts[] = "V"; -PROGMEM const char magnitude_watts[] = "W"; -PROGMEM const char magnitude_kw[] = "kW"; -PROGMEM const char magnitude_joules[] = "J"; -PROGMEM const char magnitude_kwh[] = "kWh"; -PROGMEM const char magnitude_ugm3[] = "µg/m3"; -PROGMEM const char magnitude_ppm[] = "ppm"; -PROGMEM const char magnitude_lux[] = "lux"; -PROGMEM const char magnitude_uv[] = "uv"; -PROGMEM const char magnitude_distance[] = "m"; - -PROGMEM const char* const magnitude_units[] = { - magnitude_empty, magnitude_celsius, magnitude_percentage, - magnitude_hectopascals, magnitude_amperes, magnitude_volts, - magnitude_watts, magnitude_watts, magnitude_watts, - magnitude_percentage, magnitude_joules, magnitude_joules, - magnitude_empty, magnitude_empty, magnitude_empty, - magnitude_ugm3, magnitude_ugm3, magnitude_ugm3, - magnitude_ppm, magnitude_lux, magnitude_uv, - magnitude_distance -}; - #include "../sensors/BaseSensor.h" #if AM2320_SUPPORT diff --git a/code/espurna/config/types.h b/code/espurna/config/types.h new file mode 100644 index 00000000..eabbff0d --- /dev/null +++ b/code/espurna/config/types.h @@ -0,0 +1,231 @@ +//------------------------------------------------------------------------------ +// Type definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// BUTTONS +//------------------------------------------------------------------------------ +#define BUTTON_EVENT_NONE 0 +#define BUTTON_EVENT_PRESSED 1 +#define BUTTON_EVENT_RELEASED 2 +#define BUTTON_EVENT_CLICK 2 +#define BUTTON_EVENT_DBLCLICK 3 +#define BUTTON_EVENT_LNGCLICK 4 +#define BUTTON_EVENT_LNGLNGCLICK 5 + +#define BUTTON_MODE_NONE 0 +#define BUTTON_MODE_TOGGLE 1 +#define BUTTON_MODE_ON 2 +#define BUTTON_MODE_OFF 3 +#define BUTTON_MODE_AP 4 +#define BUTTON_MODE_RESET 5 +#define BUTTON_MODE_PULSE 6 +#define BUTTON_MODE_FACTORY 7 + +// Needed for ESP8285 boards under Windows using PlatformIO (?) +#ifndef BUTTON_PUSHBUTTON +#define BUTTON_PUSHBUTTON 0 +#define BUTTON_SWITCH 1 +#define BUTTON_DEFAULT_HIGH 2 +#define BUTTON_SET_PULLUP 4 +#endif + +//------------------------------------------------------------------------------ +// RELAY +//------------------------------------------------------------------------------ + +#define RELAY_BOOT_OFF 0 +#define RELAY_BOOT_ON 1 +#define RELAY_BOOT_SAME 2 +#define RELAY_BOOT_TOGGLE 3 + +#define RELAY_TYPE_NORMAL 0 +#define RELAY_TYPE_INVERSE 1 +#define RELAY_TYPE_LATCHED 2 +#define RELAY_TYPE_LATCHED_INVERSE 3 + +#define RELAY_SYNC_ANY 0 +#define RELAY_SYNC_NONE_OR_ONE 1 +#define RELAY_SYNC_ONE 2 +#define RELAY_SYNC_SAME 3 + +#define RELAY_PULSE_NONE 0 +#define RELAY_PULSE_OFF 1 +#define RELAY_PULSE_ON 2 + +#define RELAY_PROVIDER_RELAY 0 +#define RELAY_PROVIDER_DUAL 1 +#define RELAY_PROVIDER_LIGHT 2 +#define RELAY_PROVIDER_RFBRIDGE 3 +#define RELAY_PROVIDER_STM 4 + +//------------------------------------------------------------------------------ +// LED +//------------------------------------------------------------------------------ + +#define LED_MODE_MQTT 0 // LED will be managed from MQTT (OFF by default) +#define LED_MODE_WIFI 1 // LED will blink according to the WIFI status +#define LED_MODE_FOLLOW 2 // LED will follow state of linked relay (check RELAY#_LED) +#define LED_MODE_FOLLOW_INVERSE 3 // LED will follow the opposite state of linked relay (check RELAY#_LED) +#define LED_MODE_FINDME 4 // LED will be ON if all relays are OFF +#define LED_MODE_FINDME_WIFI 5 // A mixture between WIFI and FINDME +#define LED_MODE_ON 6 // LED always ON +#define LED_MODE_OFF 7 // LED always OFF +#define LED_MODE_RELAY 8 // If any relay is ON, LED will be ON, otherwise OFF +#define LED_MODE_RELAY_WIFI 9 // A mixture between WIFI and RELAY, the reverse of MIXED + +// ----------------------------------------------------------------------------- +// UI +// ----------------------------------------------------------------------------- + +#define UI_TAG_INPUT 0 +#define UI_TAG_CHECKBOX 1 +#define UI_TAG_SELECT 2 + +// ----------------------------------------------------------------------------- +// LIGHT +// ----------------------------------------------------------------------------- + +// Available light providers (do not change) +#define LIGHT_PROVIDER_NONE 0 +#define LIGHT_PROVIDER_MY92XX 1 // works with MY9291 and MY9231 +#define LIGHT_PROVIDER_DIMMER 2 + +// ----------------------------------------------------------------------------- +// SCHEDULER +// ----------------------------------------------------------------------------- + +#define SCHEDULER_TYPE_SWITCH 1 +#define SCHEDULER_TYPE_DIM 2 + +// ----------------------------------------------------------------------------- +// IR +// ----------------------------------------------------------------------------- + +// IR Button modes +#define IR_BUTTON_MODE_NONE 0 +#define IR_BUTTON_MODE_RGB 1 +#define IR_BUTTON_MODE_HSV 2 +#define IR_BUTTON_MODE_BRIGHTER 3 +#define IR_BUTTON_MODE_STATE 4 +#define IR_BUTTON_MODE_EFFECT 5 + +#define LIGHT_EFFECT_SOLID 0 +#define LIGHT_EFFECT_FLASH 1 +#define LIGHT_EFFECT_STROBE 2 +#define LIGHT_EFFECT_FADE 3 +#define LIGHT_EFFECT_SMOOTH 4 + + +//------------------------------------------------------------------------------ +// RESET +//------------------------------------------------------------------------------ + +#define CUSTOM_RESET_HARDWARE 1 // Reset from hardware button +#define CUSTOM_RESET_WEB 2 // Reset from web interface +#define CUSTOM_RESET_TERMINAL 3 // Reset from terminal +#define CUSTOM_RESET_MQTT 4 // Reset via MQTT +#define CUSTOM_RESET_RPC 5 // Reset via RPC (HTTP) +#define CUSTOM_RESET_OTA 6 // Reset after successful OTA update +#define CUSTOM_RESET_HTTP 7 // Reset via HTTP GET +#define CUSTOM_RESET_NOFUSS 8 // Reset after successful NOFUSS update +#define CUSTOM_RESET_UPGRADE 9 // Reset after update from web interface +#define CUSTOM_RESET_FACTORY 10 // Factory reset from terminal + +#define CUSTOM_RESET_MAX 10 + +//------------------------------------------------------------------------------ +// ENVIRONMENTAL +//------------------------------------------------------------------------------ + +// American Society of Heating, Refrigerating and Air-Conditioning Engineers suggests a range of 45% - 55% humidity to manage health effects and illnesses. +// Comfortable: 30% - 60% +// Recommended: 45% - 55% +// High : 55% - 80% +#define HUMIDITY_NORMAL 0 // > %30 +#define HUMIDITY_COMFORTABLE 1 // > %45 +#define HUMIDITY_DRY 2 // < %30 +#define HUMIDITY_WET 3 // > %70 + +// United States Environmental Protection Agency - UV Index Scale +// One UV Index unit is equivalent to 25 milliWatts per square meter. +#define UV_INDEX_LOW 0 // 0 to 2 means low danger from the sun's UV rays for the average person. +#define UV_INDEX_MODERATE 1 // 3 to 5 means moderate risk of harm from unprotected sun exposure. +#define UV_INDEX_HIGH 2 // 6 to 7 means high risk of harm from unprotected sun exposure. Protection against skin and eye damage is needed. +#define UV_INDEX_VERY_HIGH 3 // 8 to 10 means very high risk of harm from unprotected sun exposure. + // Take extra precautions because unprotected skin and eyes will be damaged and can burn quickly. +#define UV_INDEX_EXTREME 4 // 11 or more means extreme risk of harm from unprotected sun exposure. + // Take all precautions because unprotected skin and eyes can burn in minutes. + +//------------------------------------------------------------------------------ +// UNITS +//------------------------------------------------------------------------------ + +#define POWER_WATTS 0 +#define POWER_KILOWATTS 1 + +#define ENERGY_JOULES 0 +#define ENERGY_KWH 1 + +#define TMP_CELSIUS 0 +#define TMP_FAHRENHEIT 1 + + +//-------------------------------------------------------------------------------- +// Sensor ID +// These should remain over time, do not modify them, only add new ones at the end +//-------------------------------------------------------------------------------- + +#define SENSOR_DHTXX_ID 0x01 +#define SENSOR_DALLAS_ID 0x02 +#define SENSOR_EMON_ANALOG_ID 0x03 +#define SENSOR_EMON_ADC121_ID 0x04 +#define SENSOR_EMON_ADS1X15_ID 0x05 +#define SENSOR_HLW8012_ID 0x06 +#define SENSOR_V9261F_ID 0x07 +#define SENSOR_ECH1560_ID 0x08 +#define SENSOR_ANALOG_ID 0x09 +#define SENSOR_DIGITAL_ID 0x10 +#define SENSOR_EVENTS_ID 0x11 +#define SENSOR_PMSX003_ID 0x12 +#define SENSOR_BMX280_ID 0x13 +#define SENSOR_MHZ19_ID 0x14 +#define SENSOR_SI7021_ID 0x15 +#define SENSOR_SHT3X_I2C_ID 0x16 +#define SENSOR_BH1750_ID 0x17 +#define SENSOR_PZEM004T_ID 0x18 +#define SENSOR_AM2320_ID 0x19 +#define SENSOR_GUVAS12SD_ID 0x20 +#define SENSOR_CSE7766_ID 0x21 +#define SENSOR_TMP3X_ID 0x22 +#define SENSOR_HCSR04_ID 0x23 + + +//-------------------------------------------------------------------------------- +// Magnitudes +//-------------------------------------------------------------------------------- + +#define MAGNITUDE_NONE 0 +#define MAGNITUDE_TEMPERATURE 1 +#define MAGNITUDE_HUMIDITY 2 +#define MAGNITUDE_PRESSURE 3 +#define MAGNITUDE_CURRENT 4 +#define MAGNITUDE_VOLTAGE 5 +#define MAGNITUDE_POWER_ACTIVE 6 +#define MAGNITUDE_POWER_APPARENT 7 +#define MAGNITUDE_POWER_REACTIVE 8 +#define MAGNITUDE_POWER_FACTOR 9 +#define MAGNITUDE_ENERGY 10 +#define MAGNITUDE_ENERGY_DELTA 11 +#define MAGNITUDE_ANALOG 12 +#define MAGNITUDE_DIGITAL 13 +#define MAGNITUDE_EVENTS 14 +#define MAGNITUDE_PM1dot0 15 +#define MAGNITUDE_PM2dot5 16 +#define MAGNITUDE_PM10 17 +#define MAGNITUDE_CO2 18 +#define MAGNITUDE_LUX 19 +#define MAGNITUDE_UV 20 +#define MAGNITUDE_DISTANCE 21 + +#define MAGNITUDE_MAX 22 diff --git a/code/espurna/sensors/AM2320Sensor.h b/code/espurna/sensors/AM2320Sensor.h index be97de1b..656be183 100644 --- a/code/espurna/sensors/AM2320Sensor.h +++ b/code/espurna/sensors/AM2320Sensor.h @@ -7,6 +7,9 @@ #pragma once +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 // Explicitly request I2C support. + #include "Arduino.h" #include "I2CSensor.h" diff --git a/code/espurna/sensors/BH1750Sensor.h b/code/espurna/sensors/BH1750Sensor.h index 9cc2b87d..20e56868 100644 --- a/code/espurna/sensors/BH1750Sensor.h +++ b/code/espurna/sensors/BH1750Sensor.h @@ -7,6 +7,9 @@ #pragma once +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 // Explicitly request I2C support. + #include "Arduino.h" #include "I2CSensor.h" diff --git a/code/espurna/sensors/BMX280Sensor.h b/code/espurna/sensors/BMX280Sensor.h index 68914be2..ad9a3ec2 100644 --- a/code/espurna/sensors/BMX280Sensor.h +++ b/code/espurna/sensors/BMX280Sensor.h @@ -7,6 +7,9 @@ #pragma once +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 // Explicitly request I2C support. + #include "Arduino.h" #include "I2CSensor.h" diff --git a/code/espurna/sensors/EmonSensor.h b/code/espurna/sensors/EmonSensor.h index 4cd05eb1..4dd14c10 100644 --- a/code/espurna/sensors/EmonSensor.h +++ b/code/espurna/sensors/EmonSensor.h @@ -7,6 +7,10 @@ #pragma once +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 // Explicitly request I2C support. + + #include "Arduino.h" #include "I2CSensor.h" diff --git a/code/espurna/sensors/SHT3XI2CSensor.h b/code/espurna/sensors/SHT3XI2CSensor.h index 46ea2cc3..21234097 100644 --- a/code/espurna/sensors/SHT3XI2CSensor.h +++ b/code/espurna/sensors/SHT3XI2CSensor.h @@ -7,6 +7,10 @@ #pragma once +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 // Explicitly request I2C support. + + #include "Arduino.h" #include "I2CSensor.h" diff --git a/code/espurna/sensors/SI7021Sensor.h b/code/espurna/sensors/SI7021Sensor.h index 991f082b..9e778aaa 100644 --- a/code/espurna/sensors/SI7021Sensor.h +++ b/code/espurna/sensors/SI7021Sensor.h @@ -7,6 +7,11 @@ #pragma once +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 // Explicitly request I2C support. + + + #include "Arduino.h" #include "I2CSensor.h"