diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 51a02848e..e03763981 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -3,6 +3,7 @@ * Add checkbox to GUI password field enabling visibility during password entry only (#5934) * Add using heap when more than 199 IRSend values need to be send. May need increase of define MQTT_MAX_PACKET_SIZE too (#5950) * Fix channel command for dual dimmers (#5940) + * Add define USE_COUNTER to my_user_config.h to save space in sonoff-basic.bin and sonoff-minimal.bin * * 6.5.0.15 20190606 * Change pubsubclient MQTT_KEEPALIVE from 10 to 30 seconds in preparation of AWS IoT support diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 0bd4ba548..a8e54db3a 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -302,6 +302,9 @@ // #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem) // #define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code) +// -- Counter input ----------------------- +#define USE_COUNTER // Enable inputs as counter (+0k8 code) + // -- Internal Analog input ----------------------- //#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index fe8c2cc4a..c0d928091 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -32,6 +32,7 @@ #define CODE_IMAGE 0 +#define USE_LIGHT // Enable light control #define USE_DHT // Default DHT11 sensor needs no external library #define USE_ENERGY_SENSOR // Use energy sensors (+14k code) #define USE_HLW8012 // Use energy sensor for Sonoff Pow and WolfBlitz @@ -245,7 +246,8 @@ enum LightSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MA enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_MODULE_INIT, FUNC_PRE_INIT, FUNC_INIT, FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_100_MSECOND, FUNC_EVERY_200_MSECOND, FUNC_EVERY_250_MSECOND, FUNC_EVERY_SECOND, - FUNC_PREP_BEFORE_TELEPERIOD, FUNC_JSON_APPEND, FUNC_WEB_SENSOR, FUNC_SAVE_BEFORE_RESTART, FUNC_COMMAND, FUNC_COMMAND_SENSOR, FUNC_COMMAND_DRIVER, + FUNC_SAVE_AT_MIDNIGHT, FUNC_SAVE_BEFORE_RESTART, + FUNC_PREP_BEFORE_TELEPERIOD, FUNC_JSON_APPEND, FUNC_WEB_SENSOR, FUNC_COMMAND, FUNC_COMMAND_SENSOR, FUNC_COMMAND_DRIVER, FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA, FUNC_SET_POWER, FUNC_SET_DEVICE_POWER, FUNC_SHOW_SENSOR, FUNC_ENERGY_EVERY_SECOND, diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index ef3992714..ba2dd72f3 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -850,9 +850,11 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) if ((payload >= param_low) && (payload <= param_high)) { Settings.param[pindex] = payload; switch (pindex) { - case P_RGB_REMAP: +#ifdef USE_LIGHT + case P_RGB_REMAP: LightUpdateColorMapping(); break; +#endif #if defined(USE_IR_REMOTE) && defined(USE_IR_RECEIVE) case P_IR_UNKNOW_THRESHOLD: IrReceiveUpdateThreshold(); @@ -1937,15 +1939,19 @@ void MqttShowState(void) GetTextIndexed(stemp1, sizeof(stemp1), Settings.flag3.sleep_normal, kSleepMode), sleep, loop_load_avg); for (uint8_t i = 0; i < devices_present; i++) { +#ifdef USE_LIGHT if (i == light_device -1) { LightState(1); } else { +#endif ResponseAppend_P(PSTR(",\"%s\":\"%s\""), GetPowerDevice(stemp1, i +1, sizeof(stemp1), Settings.flag.device_index_enable), GetStateText(bitRead(power, i))); if (SONOFF_IFAN02 == my_module_type) { ResponseAppend_P(PSTR(",\"" D_CMND_FANSPEED "\":%d"), GetFanspeed()); break; } +#ifdef USE_LIGHT } +#endif } if (pwm_present) { @@ -2249,7 +2255,9 @@ void Every250mSeconds(void) } break; case 1: // Every x.25 second - if (MidnightNow()) { CounterSaveState(); } + if (MidnightNow()) { + XsnsCall(FUNC_SAVE_AT_MIDNIGHT); + } if (save_data_counter && (backlog_pointer == backlog_index)) { save_data_counter--; if (save_data_counter <= 0) { @@ -2637,11 +2645,13 @@ void GpioInit(void) devices_present = 1; light_type = LT_BASIC; // Use basic PWM control if SetOption15 = 0 +#ifdef USE_LIGHT if (Settings.flag.pwm_control) { for (uint8_t i = 0; i < MAX_PWMS; i++) { if (pin[GPIO_PWM1 +i] < 99) { light_type++; } // Use Dimmer/Color control for all PWM as SetOption15 = 1 } } +#endif // USE_LIGHT if (SONOFF_BRIDGE == my_module_type) { Settings.flag.mqtt_serial = 0; @@ -2669,6 +2679,7 @@ void GpioInit(void) devices_present = 0; baudrate = 19200; } +#ifdef USE_LIGHT else if (SONOFF_BN == my_module_type) { // PWM Single color led (White) light_type = LT_PWM1; } @@ -2681,6 +2692,7 @@ void GpioInit(void) else if (SONOFF_B1 == my_module_type) { // RGBWC led light_type = LT_RGBWC; } +#endif // USE_LIGHT else { if (!light_type) { devices_present = 0; } for (uint8_t i = 0; i < MAX_RELAYS; i++) { @@ -2722,6 +2734,7 @@ void GpioInit(void) RotaryInit(); #endif +#ifdef USE_LIGHT #ifdef USE_WS2812 if (!light_type && (pin[GPIO_WS2812] < 99)) { // RGB led devices_present++; @@ -2733,7 +2746,8 @@ void GpioInit(void) light_type += 3; light_type |= LT_SM16716; } -#endif // ifdef USE_SM16716 +#endif // USE_SM16716 +#endif // USE_LIGHT if (!light_type) { for (uint8_t i = 0; i < MAX_PWMS; i++) { // Basic PWM control only if (pin[GPIO_PWM1 +i] < 99) { diff --git a/sonoff/sonoff_post.h b/sonoff/sonoff_post.h index fdfcbbeae..caec3fd8e 100644 --- a/sonoff/sonoff_post.h +++ b/sonoff/sonoff_post.h @@ -46,13 +46,6 @@ void KNX_CB_Action(message_t const &msg, void *arg); * Default global defines \*********************************************************************************************/ -// #ifdef USE_MQTT_AWS_IOT -// #include -// #ifndef ARDUINO_ESP8266_RELEASE_2_5_2 -// #error "USE_MQTT_AWS_IOT is only supported on core version 2.5.2" -// #endif -// #endif - #ifdef USE_EMULATION_HUE #define USE_EMULATION #endif @@ -63,7 +56,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #define USE_MQTT_TLS #endif -#if defined(USE_MQTT_TLS) || defined(USE_MQTT_AWS_IOT) +#ifdef USE_MQTT_TLS const uint16_t WEB_LOG_SIZE = 2000; // Max number of characters in weblog #else const uint16_t WEB_LOG_SIZE = 4000; // Max number of characters in weblog @@ -87,25 +80,27 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef CODE_IMAGE #define CODE_IMAGE 3 +#define USE_COUNTER // Enable counters #undef USE_ADC_VCC // Add Analog input on selected devices #define USE_DS18x20 // For more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code) //#define USE_DS18x20_LEGACY // For more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code) + #define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram) #define USE_SHT // Add I2C emulating code for SHT1X sensor (+1k4 code) -#define USE_SHT3X // Add I2C code for SHT3x sensor (+0k6 code) #define USE_HTU // Add I2C code for HTU21/SI7013/SI7020/SI7021 sensor (+1k5 code) -#define USE_LM75AD // Add I2C code for LM75AD sensor (+0k5 code) #define USE_BMP // Add I2C code for BMP085/BMP180/BMP280/BME280 sensor (+4k code) #define USE_BME680 // Add additional support for BME680 sensor using Bosch BME680 library (+4k code) -#define USE_SGP30 // Add I2C code for SGP30 sensor (+1k1 code) #define USE_BH1750 // Add I2C code for BH1750 sensor (+0k5 code) #define USE_VEML6070 // Add I2C code for VEML6070 sensor (+0k5 code) -#define USE_TSL2561 // Add I2C code for TSL2561 sensor using library Adafruit TSL2561 Arduino (+1k2 code) -//#define USE_SI1145 // Add I2C code for SI1145/46/47 sensor (+1k code) #define USE_ADS1115 // Add I2C code for ADS1115 16 bit A/D converter based on Adafruit ADS1x15 library (no library needed) (+0k7 code) //#define USE_ADS1115_I2CDEV // Add I2C code for ADS1115 16 bit A/D converter using library i2cdevlib-Core and i2cdevlib-ADS1115 (+2k code) #define USE_INA219 // Add I2C code for INA219 Low voltage and current sensor (+1k code) +#define USE_SHT3X // Add I2C code for SHT3x sensor (+0k6 code) +#define USE_TSL2561 // Add I2C code for TSL2561 sensor using library Adafruit TSL2561 Arduino (+1k2 code) #define USE_MGS // Add I2C code for Xadow and Grove Mutichannel Gas sensor using library Multichannel_Gas_Sensor (+10k code) +#define USE_SGP30 // Add I2C code for SGP30 sensor (+1k1 code) +//#define USE_SI1145 // Add I2C code for SI1145/46/47 sensor (+1k code) +#define USE_LM75AD // Add I2C code for LM75AD sensor (+0k5 code) //#define USE_APDS9960 // Add I2C code for APDS9960 Proximity Sensor. Disables SHT and VEML6070 (+4k7 code) //#define USE_MCP230xx // Enable MCP23008/MCP23017 - Must define I2C Address in #define USE_MCP230xx_ADDR below - range 0x20 - 0x27 (+4k7 code) // #define USE_MCP230xx_ADDR 0x20 // Enable MCP23008/MCP23017 I2C Address to use (Must be within range 0x20 through 0x27 - set according to your wired setup) @@ -121,6 +116,11 @@ void KNX_CB_Action(message_t const &msg, void *arg); //#define USE_MGC3130 // Enable MGC3130 Electric Field Effect Sensor (I2C address 0x42) (+2k7 code, 0k3 mem) //#define USE_MAX44009 // Enable MAX44009 Ambient Light sensor (I2C addresses 0x4A and 0x4B) (+0k8 code) #define USE_SCD30 // Enable Sensiron SCd30 CO2 sensor (I2C address 0x61) (+3k3 code) +//#define USE_SPS30 // Enable Sensiron SPS30 particle sensor (I2C address 0x69) (+1.7 code) +#define USE_ADE7953 // Enable ADE7953 Energy monitor as used on Shelly 2.5 (I2C address 0x38) (+1k5) +//#define USE_VL53L0X // Enable VL53L0x time of flight sensor (I2C address 0x29) (+4k code) +//#define USE_MLX90614 // Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code) + #define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code) #define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code) #ifndef CO2_LOW @@ -141,7 +141,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #define TUYA_DIMMER_ID 0 // Default dimmer Id #endif #define USE_PS_16_DZ // Add support for PS-16-DZ Dimmer -//#define USE_AZ7798 // Add support for AZ-Instrument 7798 CO2 datalogger +//#define USE_AZ7798 // Add support for AZ-Instrument 7798 CO2 datalogger #define USE_PN532_HSU // Add support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem) #define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code) #define USE_PZEM_AC // Add support for PZEM014,016 Energy monitor (+1k1 code) @@ -167,6 +167,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #define USE_RF_SENSOR // Add support for RF sensor receiver (434MHz or 868MHz) (+0k8 code) // #define USE_THEO_V2 // Add support for decoding Theo V2 sensors as documented on https://sidweb.nl using 434MHz RF sensor receiver (+1k4 code) #define USE_ALECTO_V2 // Add support for decoding Alecto V2 sensors like ACH2010, WS3000 and DKW2012 using 868MHz RF sensor receiver (+1k7 code) +#define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_HRE // Add support for Badger HR-E Water Meter (+1k4 code) #endif // FIRMWARE_SENSORS @@ -180,6 +181,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef CODE_IMAGE #define CODE_IMAGE 2 +#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices #ifndef USE_WPS #define USE_WPS // Add support for WPS as initial wifi configuration tool (+33k code, 1k mem (5k mem with core v2.4.2+)) #endif @@ -195,6 +197,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef USE_TIMERS_WEB // Disable support for timer webpage #undef USE_SUNRISE // Disable support for Sunrise and sunset tools #undef USE_RULES // Disable support for rules +#undef USE_COUNTER // Disable counters #undef USE_I2C // Disable all I2C sensors #undef USE_SPI // Disable all SPI devices #undef USE_MHZ19 // Disable support for MH-Z19 CO2 sensor @@ -225,6 +228,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef USE_TX20_WIND_SENSOR // Disable support for La Crosse TX20 anemometer #undef USE_RC_SWITCH // Disable support for RF transceiver using library RcSwitch #undef USE_RF_SENSOR // Disable support for RF sensor receiver (434MHz or 868MHz) (+0k8 code) +#undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_HRE // Disable support for Badger HR-E Water Meter (+1k4 code) #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code @@ -304,6 +308,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef APP_SLEEP #define APP_SLEEP 1 // Default to sleep = 1 for FIRMWARE_BASIC +#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices //#undef USE_ENERGY_SENSOR // Disable energy sensors #undef USE_ARDUINO_OTA // Disable support for Arduino OTA #undef USE_WPS // Disable support for WPS as initial wifi configuration tool @@ -320,6 +325,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); //#undef USE_TIMERS_WEB // Disable support for timer webpage //#undef USE_SUNRISE // Disable support for Sunrise and sunset tools //#undef USE_RULES // Disable support for rules +#undef USE_COUNTER // Disable counters #undef USE_DHT // Disable internal DHT sensor #undef USE_DS18x20 // Disable DS18x20 sensor #undef USE_DS18x20_LEGACY // Disable DS18x20 sensor @@ -355,6 +361,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef USE_TX20_WIND_SENSOR // Disable support for La Crosse TX20 anemometer #undef USE_RC_SWITCH // Disable support for RF transceiver using library RcSwitch #undef USE_RF_SENSOR // Disable support for RF sensor receiver (434MHz or 868MHz) (+0k8 code) +#undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_HRE // Disable support for Badger HR-E Water Meter (+1k4 code) #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code @@ -370,6 +377,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef CODE_IMAGE #define CODE_IMAGE 1 +#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices #undef USE_ENERGY_SENSOR // Disable energy sensors #undef USE_ARDUINO_OTA // Disable support for Arduino OTA #undef USE_WPS // Disable support for WPS as initial wifi configuration tool @@ -386,6 +394,9 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef USE_TIMERS_WEB // Disable support for timer webpage #undef USE_SUNRISE // Disable support for Sunrise and sunset tools #undef USE_RULES // Disable support for rules +#undef USE_SCRIPT // Disable support for script +#undef USE_LIGHT // Disable support for lights +#undef USE_COUNTER // Disable counters #undef USE_DHT // Disable internal DHT sensor #undef USE_DS18x20 // Disable DS18x20 sensor #undef USE_DS18x20_LEGACY // Disable DS18x20 sensor @@ -421,6 +432,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef USE_TX20_WIND_SENSOR // Disable support for La Crosse TX20 anemometer #undef USE_RC_SWITCH // Disable support for RF transceiver using library RcSwitch #undef USE_RF_SENSOR // Disable support for RF sensor receiver (434MHz or 868MHz) (+0k8 code) +#undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_HRE // Disable support for Badger HR-E Water Meter (+1k4 code) #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 2cf4404f6..12687f58e 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -465,6 +465,7 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_PWM4_INV, GPIO_PWM5, // RGBCW Warm White GPIO_PWM5_INV, +#ifdef USE_COUNTER GPIO_CNTR1, // Counters GPIO_CNTR1_NP, GPIO_CNTR2, @@ -473,6 +474,7 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_CNTR3_NP, GPIO_CNTR4, GPIO_CNTR4_NP, +#endif GPIO_TXD, // Serial interface GPIO_RXD, // Serial interface #ifdef USE_I2C @@ -497,7 +499,7 @@ const uint8_t kGpioNiceList[] PROGMEM = { #if defined(USE_DS18B20) || defined(USE_DS18x20) || defined(USE_DS18x20_LEGACY) GPIO_DSB, // Single wire DS18B20 or DS18S20 #endif -#ifdef USE_WS2812 +#if defined(USE_LIGHT) && defined(USE_WS2812) GPIO_WS2812, // WS2812 Led string #endif #ifdef USE_IR_REMOTE @@ -588,7 +590,7 @@ const uint8_t kGpioNiceList[] PROGMEM = { #ifdef USE_MP3_PLAYER GPIO_MP3_DFR562, // RB-DFR-562, DFPlayer Mini MP3 Player Serial interface #endif -#ifdef USE_TUYA_DIMMER +#if defined(USE_LIGHT) && defined(USE_TUYA_DIMMER) GPIO_TUYA_TX, // Tuya Serial interface GPIO_TUYA_RX, // Tuya Serial interface #endif @@ -609,13 +611,15 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_MAX31855CLK, // MAX31855 Serial interface GPIO_MAX31855DO, // MAX31855 Serial interface #endif +#ifdef USE_LIGHT GPIO_DI, // my92x1 PWM input GPIO_DCKI, // my92x1 CLK input #ifdef USE_SM16716 GPIO_SM16716_CLK, // SM16716 CLOCK GPIO_SM16716_DAT, // SM16716 DATA GPIO_SM16716_SEL, // SM16716 SELECT -#endif // USE_SM16716 +#endif // USE_SM16716 +#endif // USE_LIGHT #ifdef ROTARY_V1 GPIO_ROT1A, // Rotary switch1 A Pin GPIO_ROT1B, // Rotary switch1 B Pin diff --git a/sonoff/support_button.ino b/sonoff/support_button.ino index 3343a54c2..5b4c895a5 100644 --- a/sonoff/support_button.ino +++ b/sonoff/support_button.ino @@ -228,9 +228,11 @@ void ButtonHandler(void) } } } +#ifdef USE_LIGHT if ((MI_DESK_LAMP == my_module_type) && (button_index == 0) && (rotary_changed) && (light_power)) { rotary_changed = 0; // Color temp changed, no need to turn of the light } else { +#endif if (single_press && SendKey(0, button_index + multipress[button_index], POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set // Success } else { @@ -247,7 +249,9 @@ void ButtonHandler(void) } } } +#ifdef USE_LIGHT } +#endif multipress[button_index] = 0; } } diff --git a/sonoff/support_features.ino b/sonoff/support_features.ino index 9ae3df3b2..1a551ceaf 100644 --- a/sonoff/support_features.ino +++ b/sonoff/support_features.ino @@ -23,11 +23,13 @@ void GetFeatures(void) { - feature_drv1 = 0x00000000; // xdrv_01_mqtt.ino, xdrv_01_light.ino, xdrv_04_snfbridge.ino + feature_drv1 = 0x00000000; // xdrv_02_mqtt.ino, xdrv_04_light.ino, xdrv_06_snfbridge.ino // feature_drv1 |= 0x00000001; -// feature_drv1 |= 0x00000002; +#ifdef USE_LIGHT + feature_drv1 |= 0x00000002; // sonoff.ino, xdrv_04_light.ino +#endif #ifdef USE_I2C feature_drv1 |= 0x00000004; // sonoff.ino #endif @@ -41,33 +43,33 @@ void GetFeatures(void) feature_drv1 |= 0x00000020; // sonoff.ino #endif #ifdef USE_MQTT_TLS - feature_drv1 |= 0x00000040; // sonoff.ino + feature_drv1 |= 0x00000040; // xdrv_02_mqtt.ino #endif #ifdef USE_WEBSERVER - feature_drv1 |= 0x00000080; // xdrv_02_webserver.ino + feature_drv1 |= 0x00000080; // xdrv_01_webserver.ino #endif #ifdef WEBSERVER_ADVERTISE - feature_drv1 |= 0x00000100; // xdrv_02_webserver.ino + feature_drv1 |= 0x00000100; // xdrv_01_webserver.ino #endif #ifdef USE_EMULATION_HUE feature_drv1 |= 0x00000200; // xdrv_20_hue.ino #endif #if (MQTT_LIBRARY_TYPE == MQTT_PUBSUBCLIENT) - feature_drv1 |= 0x00000400; // xdrv_01_mqtt.ino + feature_drv1 |= 0x00000400; // xdrv_02_mqtt.ino #endif #if (MQTT_LIBRARY_TYPE == MQTT_TASMOTAMQTT) -// feature_drv1 |= 0x00000800; // xdrv_01_mqtt.ino +// feature_drv1 |= 0x00000800; // xdrv_02_mqtt.ino #endif #if (MQTT_LIBRARY_TYPE == MQTT_ESPMQTTARDUINO) // Obsolete since 6.2.1.11 -// feature_drv1 |= 0x00001000; // xdrv_01_mqtt.ino +// feature_drv1 |= 0x00001000; // xdrv_02_mqtt.ino #endif #ifdef MQTT_HOST_DISCOVERY - feature_drv1 |= 0x00002000; // xdrv_01_mqtt.ino + feature_drv1 |= 0x00002000; // xdrv_02_mqtt.ino #endif #ifdef USE_ARILUX_RF feature_drv1 |= 0x00004000; // xdrv_04_light.ino #endif -#ifdef USE_WS2812 +#if defined(USE_LIGHT) && defined(USE_WS2812) feature_drv1 |= 0x00008000; // xdrv_04_light.ino #endif #ifdef USE_WS2812_DMA @@ -116,7 +118,7 @@ void GetFeatures(void) feature_drv1 |= 0x40000000; // support.ino #endif #if (MQTT_LIBRARY_TYPE == MQTT_ARDUINOMQTT) -// feature_drv1 |= 0x80000000; // xdrv_01_mqtt.ino +// feature_drv1 |= 0x80000000; // xdrv_02_mqtt.ino #endif /*********************************************************************************************/ @@ -168,16 +170,16 @@ void GetFeatures(void) #ifdef USE_PCA9685 feature_drv2 |= 0x00004000; // xdrv_15_pca9685.ino #endif -#ifdef USE_TUYA_DIMMER +#if defined(USE_LIGHT) && defined(USE_TUYA_DIMMER) feature_drv2 |= 0x00008000; // xdrv_16_tuyadimmer.ino #endif #ifdef USE_RC_SWITCH feature_drv2 |= 0x00010000; // xdrv_17_rcswitch.ino #endif -#ifdef USE_ARMTRONIX_DIMMERS +#if defined(USE_LIGHT) && defined(USE_ARMTRONIX_DIMMERS) feature_drv2 |= 0x00020000; // xdrv_18_armtronixdimmer.ino #endif -#ifdef USE_SM16716 +#if defined(USE_LIGHT) && defined(USE_SM16716) feature_drv2 |= 0x00040000; // xdrv_04_light.ino #endif #ifdef USE_SCRIPT @@ -222,10 +224,11 @@ void GetFeatures(void) feature_sns1 = 0x00000000; // xsns_01_counter.ino, xsns_04_snfsc.ino -// feature_sns1 |= 0x00000001; - +#ifdef USE_COUNTER + feature_sns1 |= 0x00000001; // xsns_01_counter.ino +#endif #ifdef USE_ADC_VCC - feature_sns1 |= 0x00000002; // support.ino (ADC) + feature_sns1 |= 0x00000002; // xsns_02_analog.ino #endif #ifdef USE_ENERGY_SENSOR feature_sns1 |= 0x00000004; // xdrv_03_energy.ino diff --git a/sonoff/support_rotary.ino b/sonoff/support_rotary.ino index 64a7bc738..71b5e6fe3 100644 --- a/sonoff/support_rotary.ino +++ b/sonoff/support_rotary.ino @@ -17,7 +17,7 @@ along with this program. If not, see . */ - +#ifdef USE_LIGHT /*********************************************************************************************\ * Rotary support \*********************************************************************************************/ @@ -155,3 +155,4 @@ void RotaryLoop(void) } #endif // ROTARY_V1 +#endif // USE_LIGHT diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index a8b37fe0c..6beda6c25 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -930,6 +930,7 @@ void HandleRoot(void) WSContentSend_P(PSTR("
")); if (devices_present) { +#ifdef USE_LIGHT if (light_type) { if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) { WSContentSend_P(HTTP_MSG_SLIDER1, LightGetColorTemp()); @@ -938,6 +939,7 @@ void HandleRoot(void) WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer); } } +#endif WSContentSend_P(HTTP_TABLE100); WSContentSend_P(PSTR("")); if (SONOFF_IFAN02 == my_module_type) { diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index 82da14baa..f74f37fdd 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifdef USE_LIGHT /*********************************************************************************************\ * PWM, WS2812, Sonoff B1, AiLight, Sonoff Led and BN-SZ01, H801, MagicHome and Arilux * @@ -2332,3 +2333,5 @@ bool Xdrv04(uint8_t function) } return result; } + +#endif // USE_LIGHT diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index 286d901fe..f979f06d7 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifdef USE_LIGHT #ifdef USE_TUYA_DIMMER #define XDRV_16 16 @@ -434,3 +435,4 @@ bool Xdrv16(uint8_t function) } #endif // USE_TUYA_DIMMER +#endif // USE_LIGHT diff --git a/sonoff/xdrv_18_armtronix_dimmers.ino b/sonoff/xdrv_18_armtronix_dimmers.ino index 79645bdf9..16176539a 100644 --- a/sonoff/xdrv_18_armtronix_dimmers.ino +++ b/sonoff/xdrv_18_armtronix_dimmers.ino @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifdef USE_LIGHT #ifdef USE_ARMTRONIX_DIMMERS /*********************************************************************************************\ * This code can be used for Armtronix dimmers. @@ -196,3 +197,4 @@ bool Xdrv18(uint8_t function) } #endif // USE_ARMTRONIX_DIMMERS +#endif // USE_LIGHT diff --git a/sonoff/xdrv_19_ps16dz_dimmer.ino b/sonoff/xdrv_19_ps16dz_dimmer.ino index bcca6b0be..0b7861cbc 100644 --- a/sonoff/xdrv_19_ps16dz_dimmer.ino +++ b/sonoff/xdrv_19_ps16dz_dimmer.ino @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifdef USE_LIGHT #ifdef USE_PS_16_DZ #define XDRV_19 19 @@ -244,3 +245,4 @@ bool Xdrv19(uint8_t function) } #endif // USE_PS_16_DZ +#endif // USE_LIGHT diff --git a/sonoff/xdrv_20_hue.ino b/sonoff/xdrv_20_hue.ino index 7d7934106..0041cb1a3 100644 --- a/sonoff/xdrv_20_hue.ino +++ b/sonoff/xdrv_20_hue.ino @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if defined(USE_WEBSERVER) && defined(USE_EMULATION) && defined(USE_EMULATION_HUE) +#if defined(USE_WEBSERVER) && defined(USE_EMULATION) && defined(USE_EMULATION_HUE) && defined(USE_LIGHT) /*********************************************************************************************\ * Philips Hue bridge emulation * diff --git a/sonoff/xplg_ws2812.ino b/sonoff/xplg_ws2812.ino index 39aa3865f..7908289c5 100644 --- a/sonoff/xplg_ws2812.ino +++ b/sonoff/xplg_ws2812.ino @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifdef USE_LIGHT #ifdef USE_WS2812 /*********************************************************************************************\ * WS2812 RGB / RGBW Leds using NeopixelBus library @@ -394,3 +395,4 @@ void Ws2812ShowScheme(uint8_t scheme) } #endif // USE_WS2812 +#endif // USE_LIGHT diff --git a/sonoff/xsns_01_counter.ino b/sonoff/xsns_01_counter.ino index 84b1c29ea..62b35d1ac 100644 --- a/sonoff/xsns_01_counter.ino +++ b/sonoff/xsns_01_counter.ino @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifdef USE_COUNTER /*********************************************************************************************\ * Counter sensors (water meters, electricity meters etc.) \*********************************************************************************************/ @@ -165,8 +166,11 @@ bool Xsns01(uint8_t function) break; #endif // USE_WEBSERVER case FUNC_SAVE_BEFORE_RESTART: + case FUNC_SAVE_AT_MIDNIGHT: CounterSaveState(); break; } return result; } + +#endif // USE_COUNTER diff --git a/sonoff/xsns_46_MLX90614.ino b/sonoff/xsns_46_MLX90614.ino index 5065c4d1a..a70b8538f 100644 --- a/sonoff/xsns_46_MLX90614.ino +++ b/sonoff/xsns_46_MLX90614.ino @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifdef USE_I2C #ifdef USE_MLX90614 #define XSNS_46 46 @@ -139,3 +140,4 @@ bool Xsns46(byte function) } #endif // USE_MLX90614 +#endif // USE_I2C