5.9.0 20171030 * Rewrite code (partly) using Google C++ Style Guide (https://google.github.io/styleguide/cppguide.html) * Rewrite code by using command lookup tables and javascript (client side) web page expansions * Change HTML/CSS to enable nicer form field entry * Change default PWM assignments for H801 RGB(CW) led controller to support optional Color/Dimmer control * GPIO04 (W2) from GPIO_PWM2 to GPIO_USER to be user configurable for GPIO_PWM5 (second White - Warm if W1 is Cold) * GPIO12 (Blue) GPIO_PWM3 no change * GPIO13 (Green) from GPIO_PWM4 to GPIO_PWM2 * GPIO14 (W1) from GPIO_PWM1 to GPIO_USER to be user configurable for GPIO_PWM4 (first White - Cold or Warm) * GPIO15 (Red) from GPIO_PWM5 to GPIO_PWM1 * Change default PWM assignments for MagicHome RGB(W) led controller to support optional Color/Dimmer control * GPIO05 (Green) from GPIO_PWM4 to GPIO_PWM2 * GPIO12 (Blue) from GPIO_PWM5 to GPIO_PWM3 * GPIO13 (White) GPIO_USER to be user configurable for GPIO_PWM4 (White - Cold or Warm) * GPIO14 (Red) from GPIO_PWM3 to GPIO_PWM1 * Change default PWM assignment for Witty Cloud to support optional Color/Dimmer control (#976) * GPIO12 (Green) from GPIO_PWM4 to GPIO_PWM2 * GPIO13 (Blue) from GPIO_PWM5 to GPIO_PWM3 * GPIO15 (Red) from GPIO_PWM3 to GPIO_PWM1 * Change when another module is selected now all GPIO user configuration is removed * Change command name IRRemote to IRSend (#956) * Remove Arduino IDE version too low warning as it interferes with platformio.ini platform = espressif8266_stage * Fix command FullTopic entry when using serial or console interface * Fix possible UDP syslog blocking * Fix minimum TelePeriod of 10 seconds set by web page * Fix command GPIOx JSON response (#897) * Fix inverted relay power on state (#909) * Fix compile error when DOMOTICZ_UPDATE_TIMER is not defined (#930) * Fix alignment of web page items in some browsers (#935) * Fix setting all saved power settings to Off when SetOption0 (SaveState) = 0 (#955) * Fix timezone range from -12/12 to -13/13 (#968) * Fix Southern Hemisphere TIME_STD/TIME_DST (#968) * Fix TLS MQTT SSL fingerprint test (#970, #808) * Fix virtual relay status message used with Color/Dimmer control (#989) * Fix command IRSend and IRHvac case sensitive parameter regression introduced with version 5.8.0 (#993) * Fix pressure calculation for some BMP versions regression introduced with version 5.8.0i (#974) * Fix Domoticz Dimmer set to same level not powering on (#945) * Fix Blocked Loop when erasing large flash using command reset 2 (#1002) * Fix relay power control when light power control is also configured as regression from 5.8.0 (#1016) * Fix Mqtt server mDNS lookup only when MqttHost name is empty (#1026) * Add debug information to MQTT subscribe * Add translations to I2Cscan * Add translation to BH1750 unit lx * Add light scheme options (Color cycle Up, Down, Random) and moving WS2812 schemes up by 3 * Add Domoticz counter sensor to IrReceive representing Received IR Protocol and Data * Add option 0 to MqttHost to allow empty Mqtt host name * Add support for Arilux AL-LC01 RGB Led controller (#370) * Add esp8266 de-blocking to PubSubClient library (#790) * Add Domoticz sensors for Voltage and Current (#903) * Add platformio OTA upload support (#928, #934) * Add warning to webpage when USE_MINIMAL is selected (#929) * Add smoother movement of hour hand in WS2812 led clock (#936) * Add support for Magic Home RGBW and some Arilux Led controllers (#940) * Add command SetOption15 0 (default) for command PWM control or SetOption15 1 for commands Color/Dimmer control to PWM RGB(CW) leds (#941) * Add Domoticz counter sensor to Sonoff Bridge representing Received RF code (#943) * Add support for Luani HVIO board (https://luani.de/projekte/esp8266-hvio/) (#953) * Add PWM initialization after restart (#955) * Add IR Receiver support. Disable in user_config.h (#956) * Add support for inverted PWM (#960) * Add Sea level pressure calculation and Provide command Altitude (#974) * Add support for up to 8 relays (#995) * Add commands RfSync, RfLow, RfHigh, RfHost and RfCode to allow sending custom RF codes (#1001) * Add retain to ENERGY messages controlled by command SensorRetain (#1013) * Add commands Color2, Color3, Color4, Width2, Width3, Width4 and SetOption16 to set Ws2812 Clock parameters (#1019) * Add German language file (#1022) * Add support for connecting to MQTT brokers without userid and/or password (#1023) * Add support for esp8266 core v2.4.0-rc2 (#1024) * Add commands PwmRange 1,255..1023 and PwmFrequency 1,100..4000 (#1025) * Add Polish language file (#1044, #1047) * Add support for KMC 70011 Power Monitoring Smart Plug (#1045) * Add support for VEML6070 I2C Ultra Violet level sensor (#1053) * Add light turn Off Fade (#925) * Add IrSend command option Panasonic as IrSend {"Protocol":"Panasonic", "Bits":16388, "Data":<Panasonic data>} * where 16388 is 0x4004 hexadecimal (#1014) * Add retry counter to DHT11/21/22 sensors (#1082)
116 lines
6.6 KiB
C
116 lines
6.6 KiB
C
/*
|
|
sonoff.h - Master header file for Sonoff-Tasmota
|
|
|
|
Copyright (C) 2017 Theo Arends
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef _SONOFF_H_
|
|
#define _SONOFF_H_
|
|
|
|
/*********************************************************************************************\
|
|
* Power Type
|
|
\*********************************************************************************************/
|
|
|
|
typedef unsigned long power_t; // Power (Relay) type
|
|
#define POWER_MASK 0xffffffffUL // Power (Relay) full mask
|
|
|
|
/*********************************************************************************************\
|
|
* Defines
|
|
\*********************************************************************************************/
|
|
|
|
// Changes to the following MAX_ defines will impact settings layout
|
|
#define MAX_RELAYS 8 // Max number of relays
|
|
#define MAX_LEDS 4 // Max number of leds
|
|
#define MAX_KEYS 4 // Max number of keys or buttons
|
|
#define MAX_SWITCHES 4 // Max number of switches
|
|
#define MAX_PWMS 5 // Max number of PWM channels
|
|
#define MAX_COUNTERS 4 // Max number of counter sensors
|
|
#define MAX_PULSETIMERS 8 // Max number of supported pulse timers
|
|
#define MAX_FRIENDLYNAMES 4 // Max number of Friendly names
|
|
#define MAX_DOMOTICZ_IDX 4 // Max number of Domoticz device, key and switch indices
|
|
|
|
#define MODULE SONOFF_BASIC // [Module] Select default model
|
|
|
|
#define MQTT_TOKEN_PREFIX "%prefix%" // To be substituted by mqtt_prefix[x]
|
|
#define MQTT_TOKEN_TOPIC "%topic%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
|
|
|
|
#define WIFI_HOSTNAME "%s-%04d" // Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
|
|
|
|
#define CONFIG_FILE_SIGN 0xA5 // Configuration file signature
|
|
#define CONFIG_FILE_XOR 0x5A // Configuration file xor (0 = No Xor)
|
|
|
|
#define HLW_PREF_PULSE 12530 // was 4975us = 201Hz = 1000W
|
|
#define HLW_UREF_PULSE 1950 // was 1666us = 600Hz = 220V
|
|
#define HLW_IREF_PULSE 3500 // was 1666us = 600Hz = 4.545A
|
|
|
|
#define MQTT_RETRY_SECS 10 // Minimum seconds to retry MQTT connection
|
|
#define APP_POWER 0 // Default saved power state Off
|
|
#define WS2812_MAX_LEDS 512 // Max number of LEDs
|
|
|
|
#define PWM_RANGE 1023 // 255..1023 needs to be devisible by 256
|
|
//#define PWM_FREQ 1000 // 100..1000 Hz led refresh
|
|
//#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value)
|
|
#define PWM_FREQ 880 // 100..1000 Hz led refresh (BN-SZ01 value)
|
|
|
|
#define MAX_POWER_HOLD 10 // Time in SECONDS to allow max agreed power (Pow)
|
|
#define MAX_POWER_WINDOW 30 // Time in SECONDS to disable allow max agreed power (Pow)
|
|
#define SAFE_POWER_HOLD 10 // Time in SECONDS to allow max unit safe power (Pow)
|
|
#define SAFE_POWER_WINDOW 30 // Time in MINUTES to disable allow max unit safe power (Pow)
|
|
#define MAX_POWER_RETRY 5 // Retry count allowing agreed power limit overflow (Pow)
|
|
|
|
#define STATES 20 // State loops per second
|
|
#define SYSLOG_TIMER 600 // Seconds to restore syslog_level
|
|
#define SERIALLOG_TIMER 600 // Seconds to disable SerialLog
|
|
#define OTA_ATTEMPTS 10 // Number of times to try fetching the new firmware
|
|
|
|
#define INPUT_BUFFER_SIZE 250 // Max number of characters in (serial) command buffer
|
|
#define CMDSZ 24 // Max number of characters in command
|
|
#define TOPSZ 100 // Max number of characters in topic string
|
|
#ifdef USE_MQTT_TLS
|
|
#define MAX_LOG_LINES 10 // Max number of lines in weblog
|
|
#else
|
|
#define MAX_LOG_LINES 20 // Max number of lines in weblog
|
|
#endif
|
|
#define MAX_BACKLOG 16 // Max number of commands in backlog (chk backlog_index and backlog_pointer code)
|
|
#define MIN_BACKLOG_DELAY 2 // Minimal backlog delay in 0.1 seconds
|
|
|
|
#define APP_BAUDRATE 115200 // Default serial baudrate
|
|
#define MAX_STATUS 11 // Max number of status lines
|
|
|
|
/*********************************************************************************************\
|
|
* Enumeration
|
|
\*********************************************************************************************/
|
|
|
|
enum WeekInMonthOptions {Last, First, Second, Third, Fourth};
|
|
enum DayOfTheWeekOptions {Sun=1, Mon, Tue, Wed, Thu, Fri, Sat};
|
|
enum MonthNamesOptions {Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
|
|
enum HemisphereOptions {North, South};
|
|
enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
|
|
enum WifiConfigOptions {WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, MAX_WIFI_OPTION};
|
|
enum SwitchModeOptions {TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON, PUSHBUTTON_INV, PUSHBUTTONHOLD, PUSHBUTTONHOLD_INV, MAX_SWITCH_OPTION};
|
|
enum LedStateOptions {LED_OFF, LED_POWER, LED_MQTTSUB, LED_POWER_MQTTSUB, LED_MQTTPUB, LED_POWER_MQTTPUB, LED_MQTT, LED_POWER_MQTT, MAX_LED_OPTION};
|
|
enum EmulationOptions {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX};
|
|
enum ButtonStates {PRESSED, NOT_PRESSED};
|
|
enum SettingsParmaIndex {P_HOLD_TIME, P_MAX_POWER_RETRY, P_MAX_PARAM8};
|
|
enum Ws2812ClockIndex {WS_SECOND, WS_MINUTE, WS_HOUR};
|
|
enum Ws2812Color {WS_RED, WS_GREEN, WS_BLUE};
|
|
enum LightTypes {LT_BASIC, LT_PWM1, LT_PWM2, LT_PWM3, LT_PWM4, LT_PWM5, LT_PWM6, LT_PWM7, LT_NU8, LT_NU9, LT_NU10, LT_WS2812, LT_RGBW, LT_RGBWC};
|
|
enum LichtSubtypes {LST_NONE, LST_SINGLE, LST_COLDWARM, LST_RGB, LST_RGBW, LST_RGBWC};
|
|
enum LichtSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX};
|
|
|
|
const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, 0x2E, 0x1A, 0x00 };
|
|
|
|
#endif // _SONOFF_H_
|