Mirror of espurna firmware for wireless switches and more
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

436 lines
20 KiB

providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
5 years ago
5 years ago
  1. //------------------------------------------------------------------------------
  2. // Type definitions
  3. // Do not touch this definitions
  4. //------------------------------------------------------------------------------
  5. #pragma once
  6. // -----------------------------------------------------------------------------
  7. // GPIO
  8. // -----------------------------------------------------------------------------
  9. #define GPIO_TYPE_NONE GpioType::None
  10. #define GPIO_TYPE_HARDWARE GpioType::Hardware
  11. #define GPIO_TYPE_MCP23S08 GpioType::Mcp23s08
  12. //------------------------------------------------------------------------------
  13. // BUTTONS
  14. //------------------------------------------------------------------------------
  15. #define BUTTON_ACTION_NONE ButtonAction::None
  16. #define BUTTON_ACTION_TOGGLE ButtonAction::Toggle
  17. #define BUTTON_ACTION_ON ButtonAction::On
  18. #define BUTTON_ACTION_OFF ButtonAction::Off
  19. #define BUTTON_ACTION_AP ButtonAction::AccessPoint
  20. #define BUTTON_ACTION_RESET ButtonAction::Reset
  21. #define BUTTON_ACTION_PULSE ButtonAction::Pulse
  22. #define BUTTON_ACTION_FACTORY ButtonAction::FactoryReset
  23. #define BUTTON_ACTION_WPS ButtonAction::Wps
  24. #define BUTTON_ACTION_SMART_CONFIG ButtonAction::SmartConfig
  25. #define BUTTON_ACTION_DIM_UP ButtonAction::BrightnessIncrease
  26. #define BUTTON_ACTION_DIM_DOWN ButtonAction::BrightnessDecrease
  27. #define BUTTON_ACTION_DISPLAY_ON ButtonAction::DisplayOn
  28. #define BUTTON_ACTION_CUSTOM ButtonAction::Custom
  29. #define BUTTON_ACTION_FAN_LOW ButtonAction::FanLow
  30. #define BUTTON_ACTION_FAN_MEDIUM ButtonAction::FanMedium
  31. #define BUTTON_ACTION_FAN_HIGH ButtonAction::FanHigh
  32. // Deprecated: legacy mapping, changed to action from above
  33. #define BUTTON_MODE_NONE BUTTON_ACTION_NONE
  34. #define BUTTON_MODE_TOGGLE BUTTON_ACTION_TOGGLE
  35. #define BUTTON_MODE_ON BUTTON_ACTION_ON
  36. #define BUTTON_MODE_OFF BUTTON_ACTION_OFF
  37. #define BUTTON_MODE_AP BUTTON_ACTION_AP
  38. #define BUTTON_MODE_RESET BUTTON_ACTION_RESET
  39. #define BUTTON_MODE_PULSE BUTTON_ACTION_PULSE
  40. #define BUTTON_MODE_FACTORY BUTTON_ACTION_FACTORY
  41. #define BUTTON_MODE_WPS BUTTON_ACTION_WPS
  42. #define BUTTON_MODE_SMART_CONFIG BUTTON_ACTION_SMART_CONFIG
  43. #define BUTTON_MODE_DIM_UP BUTTON_ACTION_DIM_UP
  44. #define BUTTON_MODE_DIM_DOWN BUTTON_ACTION_DIM_DOWN
  45. #define BUTTON_MODE_DISPLAY_ON BUTTON_ACTION_DISPLAY_ON
  46. // compat definitions for DebounceEvent
  47. #define BUTTON_PUSHBUTTON ButtonMask::Pushbutton
  48. #define BUTTON_SWITCH ButtonMask::Switch
  49. #define BUTTON_DEFAULT_LOW ButtonMask::DefaultLow
  50. #define BUTTON_DEFAULT_HIGH ButtonMask::DefaultHigh
  51. #define BUTTON_DEFAULT_BOOT ButtonMask::DefaultBoot
  52. #define BUTTON_SET_PULLUP ButtonMask::SetPullup
  53. #define BUTTON_SET_PULLDOWN ButtonMask::SetPulldown
  54. // configure where do we get the button events
  55. #define BUTTON_PROVIDER_NONE ButtonProvider::None
  56. #define BUTTON_PROVIDER_DUMMY ButtonProvider::Dummy
  57. #define BUTTON_PROVIDER_GPIO ButtonProvider::Gpio
  58. #define BUTTON_PROVIDER_ANALOG ButtonProvider::Analog
  59. #define BUTTON_PROVIDER_LIGHTFOX ButtonProvider::Lightfox
  60. //------------------------------------------------------------------------------
  61. // ENCODER
  62. //------------------------------------------------------------------------------
  63. #define ENCODER_MODE_CHANNEL 0
  64. #define ENCODER_MODE_RATIO 1
  65. //------------------------------------------------------------------------------
  66. // RELAY
  67. //------------------------------------------------------------------------------
  68. #define RELAY_NONE 0x99
  69. #define RELAY_BOOT_OFF RelayBoot::Off
  70. #define RELAY_BOOT_ON RelayBoot::On
  71. #define RELAY_BOOT_SAME RelayBoot::Same
  72. #define RELAY_BOOT_TOGGLE RelayBoot::Toggle
  73. #define RELAY_BOOT_LOCKED_OFF RelayBoot::LockedOff
  74. #define RELAY_BOOT_LOCKED_ON RelayBoot::LockedOn
  75. #define RELAY_TYPE_NORMAL RelayType::Normal
  76. #define RELAY_TYPE_INVERSE RelayType::Inverse
  77. #define RELAY_TYPE_LATCHED RelayType::Latched
  78. #define RELAY_TYPE_LATCHED_INVERSE RelayType::LatchedInverse
  79. #define RELAY_SYNC_ANY RelaySync::None
  80. #define RELAY_SYNC_NONE_OR_ONE RelaySync::ZeroOrOne
  81. #define RELAY_SYNC_ONE RelaySync::JustOne
  82. #define RELAY_SYNC_SAME RelaySync::All
  83. #define RELAY_SYNC_FIRST RelaySync::First
  84. #define RELAY_PULSE_NONE Mode::None
  85. #define RELAY_PULSE_OFF Mode::Off
  86. #define RELAY_PULSE_ON Mode::On
  87. #define RELAY_PROVIDER_NONE RelayProvider::None
  88. #define RELAY_PROVIDER_DUMMY RelayProvider::Dummy
  89. #define RELAY_PROVIDER_GPIO RelayProvider::Gpio
  90. #define RELAY_PROVIDER_DUAL RelayProvider::Dual
  91. #define RELAY_PROVIDER_STM RelayProvider::Stm
  92. #define RELAY_PROVIDER_LIGHT_STATE RelayProvider::LightState
  93. #define RELAY_PROVIDER_FAN RelayProvider::Fan
  94. #define RELAY_PROVIDER_LIGHTFOX RelayProvider::Lightfox
  95. #define RELAY_PROVIDER_TUYA RelayProvider::Tuya
  96. #define RFB_PROVIDER_RCSWITCH 0
  97. #define RFB_PROVIDER_EFM8BB1 1
  98. #define RELAY_MQTT_TOPIC_NORMAL RelayMqttTopicMode::Normal
  99. #define RELAY_MQTT_TOPIC_INVERSE RelayMqttTopicMode::Inverse
  100. #define RELAY_MQTT_TOPIC_RECEIVE_ONLY RelayMqttTopicMode::ReceiveOnly
  101. #define RELAY_MQTT_DISCONNECT_NONE PayloadStatus::Unknown
  102. #define RELAY_MQTT_DISCONNECT_ON PayloadStatus::On
  103. #define RELAY_MQTT_DISCONNECT_OFF PayloadStatus::Off
  104. #define RELAY_MQTT_DISCONNECT_TOGGLE PayloadStatus::Toggle
  105. #define RELAY_LOCK_DISABLED RelayLock::None
  106. #define RELAY_LOCK_NONE RelayLock::None
  107. #define RELAY_LOCK_OFF RelayLock::Off
  108. #define RELAY_LOCK_ON RelayLock::On
  109. //------------------------------------------------------------------------------
  110. // UDP SYSLOG
  111. //------------------------------------------------------------------------------
  112. // Priority codes:
  113. #define SYSLOG_EMERG 0 /* system is unusable */
  114. #define SYSLOG_ALERT 1 /* action must be taken immediately */
  115. #define SYSLOG_CRIT 2 /* critical conditions */
  116. #define SYSLOG_ERR 3 /* error conditions */
  117. #define SYSLOG_WARNING 4 /* warning conditions */
  118. #define SYSLOG_NOTICE 5 /* normal but significant condition */
  119. #define SYSLOG_INFO 6 /* informational */
  120. #define SYSLOG_DEBUG 7 /* debug-level messages */
  121. // Facility codes:
  122. #define SYSLOG_KERN (0<<3) /* kernel messages */
  123. #define SYSLOG_USER (1<<3) /* random user-level messages */
  124. #define SYSLOG_MAIL (2<<3) /* mail system */
  125. #define SYSLOG_DAEMON (3<<3) /* system daemons */
  126. #define SYSLOG_AUTH (4<<3) /* security/authorization messages */
  127. #define SYSLOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
  128. #define SYSLOG_LPR (6<<3) /* line printer subsystem */
  129. #define SYSLOG_NEWS (7<<3) /* network news subsystem */
  130. #define SYSLOG_UUCP (8<<3) /* UUCP subsystem */
  131. #define SYSLOG_CRON (9<<3) /* clock daemon */
  132. #define SYSLOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
  133. #define SYSLOG_FTP (11<<3) /* ftp daemon */
  134. #define SYSLOG_LOCAL0 (16<<3) /* reserved for local use */
  135. #define SYSLOG_LOCAL1 (17<<3) /* reserved for local use */
  136. #define SYSLOG_LOCAL2 (18<<3) /* reserved for local use */
  137. #define SYSLOG_LOCAL3 (19<<3) /* reserved for local use */
  138. #define SYSLOG_LOCAL4 (20<<3) /* reserved for local use */
  139. #define SYSLOG_LOCAL5 (21<<3) /* reserved for local use */
  140. #define SYSLOG_LOCAL6 (22<<3) /* reserved for local use */
  141. #define SYSLOG_LOCAL7 (23<<3) /* reserved for local use */
  142. //------------------------------------------------------------------------------
  143. // Heartbeat
  144. //------------------------------------------------------------------------------
  145. #define HEARTBEAT_NONE espurna::heartbeat::Mode::None
  146. #define HEARTBEAT_ONCE espurna::heartbeat::Mode::Once
  147. #define HEARTBEAT_REPEAT espurna::heartbeat::Mode::Repeat
  148. //------------------------------------------------------------------------------
  149. // MQTT
  150. //------------------------------------------------------------------------------
  151. // Internal MQTT events
  152. #define MQTT_CONNECT_EVENT 0
  153. #define MQTT_DISCONNECT_EVENT 1
  154. #define MQTT_MESSAGE_EVENT 2
  155. // MQTT_LIBRARY
  156. #define MQTT_LIBRARY_ASYNCMQTTCLIENT 0
  157. #define MQTT_LIBRARY_ARDUINOMQTT 1
  158. #define MQTT_LIBRARY_PUBSUBCLIENT 2
  159. //------------------------------------------------------------------------------
  160. // LED
  161. //------------------------------------------------------------------------------
  162. #define LED_MODE_MANUAL LedMode::Manual // LED will be managed manually (OFF by default)
  163. #define LED_MODE_WIFI LedMode::WiFi // LED will blink according to the WIFI status
  164. #define LED_MODE_FOLLOW LedMode::Relay // LED will follow state of linked LED#_RELAY relay ID
  165. #define LED_MODE_FOLLOW_INVERSE LedMode::RelayInverse // LED will follow the opposite state of linked LED#_RELAY relay ID
  166. #define LED_MODE_FINDME LedMode::FindMe // LED will be ON if all relays are OFF
  167. #define LED_MODE_FINDME_WIFI LedMode::FindMeWiFi // A mixture between WIFI and FINDME
  168. #define LED_MODE_ON LedMode::On // LED always ON
  169. #define LED_MODE_OFF LedMode::Off // LED always OFF
  170. #define LED_MODE_RELAY LedMode::Relays // If any relay is ON, LED will be ON, otherwise OFF
  171. #define LED_MODE_RELAY_WIFI LedMode::RelaysWiFi // A mixture between WIFI and RELAY, the reverse of MIXED
  172. // -----------------------------------------------------------------------------
  173. // UI
  174. // -----------------------------------------------------------------------------
  175. #define UI_TAG_INPUT 0
  176. #define UI_TAG_CHECKBOX 1
  177. #define UI_TAG_SELECT 2
  178. #define WEB_MODE_NORMAL 0
  179. #define WEB_MODE_PASSWORD 1
  180. // -----------------------------------------------------------------------------
  181. // LIGHT
  182. // -----------------------------------------------------------------------------
  183. // Available light providers
  184. #define LIGHT_PROVIDER_NONE 0
  185. #define LIGHT_PROVIDER_MY92XX 1 // works with MY9291 and MY9231
  186. #define LIGHT_PROVIDER_DIMMER 2
  187. #define LIGHT_PROVIDER_CUSTOM 3
  188. // -----------------------------------------------------------------------------
  189. // SCHEDULER
  190. // -----------------------------------------------------------------------------
  191. #define SCHEDULER_TYPE_NONE scheduler::Type::None
  192. #define SCHEDULER_TYPE_RELAY scheduler::Type::Relay
  193. #define SCHEDULER_TYPE_CHANNEL scheduler::Type::Channel
  194. #define SCHEDULER_TYPE_CURTAIN scheduler::Type::Curtain
  195. // -----------------------------------------------------------------------------
  196. // IR
  197. // -----------------------------------------------------------------------------
  198. #define IR_BUTTON_ACTION_NONE 0
  199. #define IR_BUTTON_ACTION_RGB 1
  200. #define IR_BUTTON_ACTION_HSV 2
  201. #define IR_BUTTON_ACTION_BRIGHTER 3
  202. #define IR_BUTTON_ACTION_STATE 4
  203. #define IR_BUTTON_ACTION_EFFECT 5
  204. #define IR_BUTTON_ACTION_TOGGLE 6
  205. #define IR_BUTTON_MODE_NONE IR_BUTTON_ACTION_NONE
  206. #define IR_BUTTON_MODE_RGB IR_BUTTON_ACTION_RGB
  207. #define IR_BUTTON_MODE_HSV IR_BUTTON_ACTION_HSV
  208. #define IR_BUTTON_MODE_BRIGHTER IR_BUTTON_ACTION_BRIGHTER
  209. #define IR_BUTTON_MODE_STATE IR_BUTTON_ACTION_STATE
  210. #define IR_BUTTON_MODE_EFFECT IR_BUTTON_ACTION_EFFECT
  211. #define IR_BUTTON_MODE_TOGGLE IR_BUTTON_ACTION_TOGGLE
  212. #define LIGHT_EFFECT_SOLID 0
  213. #define LIGHT_EFFECT_FLASH 1
  214. #define LIGHT_EFFECT_STROBE 2
  215. #define LIGHT_EFFECT_FADE 3
  216. #define LIGHT_EFFECT_SMOOTH 4
  217. //------------------------------------------------------------------------------
  218. // PWM
  219. //------------------------------------------------------------------------------
  220. #define PWM_PROVIDER_NONE 0
  221. #define PWM_PROVIDER_GENERIC 1
  222. #define PWM_PROVIDER_ARDUINO 2
  223. //------------------------------------------------------------------------------
  224. // ENVIRONMENTAL
  225. //------------------------------------------------------------------------------
  226. // American Society of Heating, Refrigerating and Air-Conditioning Engineers suggests a range of 45% - 55% humidity to manage health effects and illnesses.
  227. // Comfortable: 30% - 60%
  228. // Recommended: 45% - 55%
  229. // High : 55% - 80%
  230. #define HUMIDITY_NORMAL 0 // > %30
  231. #define HUMIDITY_COMFORTABLE 1 // > %45
  232. #define HUMIDITY_DRY 2 // < %30
  233. #define HUMIDITY_WET 3 // > %70
  234. // United States Environmental Protection Agency - UV Index Scale
  235. // One UV Index unit is equivalent to 25 milliWatts per square meter.
  236. #define UV_INDEX_LOW 0 // 0 to 2 means low danger from the sun's UV rays for the average person.
  237. #define UV_INDEX_MODERATE 1 // 3 to 5 means moderate risk of harm from unprotected sun exposure.
  238. #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.
  239. #define UV_INDEX_VERY_HIGH 3 // 8 to 10 means very high risk of harm from unprotected sun exposure.
  240. // Take extra precautions because unprotected skin and eyes will be damaged and can burn quickly.
  241. #define UV_INDEX_EXTREME 4 // 11 or more means extreme risk of harm from unprotected sun exposure.
  242. // Take all precautions because unprotected skin and eyes can burn in minutes.
  243. //--------------------------------------------------------------------------------
  244. // Sensor ID
  245. // These should remain over time, do not modify them, only add new ones at the end
  246. //--------------------------------------------------------------------------------
  247. #define SENSOR_DHTXX_ID 1
  248. #define SENSOR_DALLAS_ID 2
  249. #define SENSOR_EMON_ANALOG_ID 3
  250. #define SENSOR_EMON_ADC121_ID 4
  251. #define SENSOR_EMON_ADS1X15_ID 5
  252. #define SENSOR_HLW8012_ID 6
  253. #define SENSOR_V9261F_ID 7
  254. #define SENSOR_ECH1560_ID 8
  255. #define SENSOR_ANALOG_ID 9
  256. #define SENSOR_DIGITAL_ID 10
  257. #define SENSOR_EVENTS_ID 11
  258. #define SENSOR_PMSX003_ID 12
  259. #define SENSOR_BMX280_ID 13
  260. #define SENSOR_MHZ19_ID 14
  261. #define SENSOR_SI7021_ID 15
  262. #define SENSOR_SHT3X_I2C_ID 16
  263. #define SENSOR_BH1750_ID 17
  264. #define SENSOR_PZEM004T_ID 18
  265. #define SENSOR_AM2320_ID 19
  266. #define SENSOR_GUVAS12SD_ID 20
  267. #define SENSOR_CSE7766_ID 21
  268. #define SENSOR_TMP3X_ID 22
  269. #define SENSOR_SONAR_ID 23
  270. #define SENSOR_SENSEAIR_ID 24
  271. #define SENSOR_GEIGER_ID 25
  272. #define SENSOR_NTC_ID 26
  273. #define SENSOR_SDS011_ID 27
  274. #define SENSOR_MICS2710_ID 28
  275. #define SENSOR_MICS5525_ID 29
  276. #define SENSOR_PULSEMETER_ID 30
  277. #define SENSOR_VEML6075_ID 31
  278. #define SENSOR_VL53L1X_ID 32
  279. #define SENSOR_EZOPH_ID 33
  280. #define SENSOR_BMP180_ID 34
  281. #define SENSOR_MAX6675_ID 35
  282. #define SENSOR_LDR_ID 36
  283. #define SENSOR_ADE7953_ID 37
  284. #define SENSOR_T6613_ID 38
  285. #define SENSOR_SI1145_ID 39
  286. #define SENSOR_HDC1080_ID 40
  287. #define SENSOR_PZEM004TV30_ID 41
  288. #define SENSOR_BME680_ID 42
  289. #define SENSOR_SM300D2_ID 43
  290. #define SENSOR_PM1006_ID 44
  291. #define SENSOR_INA219_ID 45
  292. //--------------------------------------------------------------------------------
  293. // Magnitudes
  294. // These should remain over time, do not modify their values, only add new ones at the end
  295. //--------------------------------------------------------------------------------
  296. #define MAGNITUDE_NONE 0
  297. #define MAGNITUDE_TEMPERATURE 1
  298. #define MAGNITUDE_HUMIDITY 2
  299. #define MAGNITUDE_PRESSURE 3
  300. #define MAGNITUDE_CURRENT 4
  301. #define MAGNITUDE_VOLTAGE 5
  302. #define MAGNITUDE_POWER_ACTIVE 6
  303. #define MAGNITUDE_POWER_APPARENT 7
  304. #define MAGNITUDE_POWER_REACTIVE 8
  305. #define MAGNITUDE_POWER_FACTOR 9
  306. #define MAGNITUDE_ENERGY 10
  307. #define MAGNITUDE_ENERGY_DELTA 11
  308. #define MAGNITUDE_ANALOG 12
  309. #define MAGNITUDE_DIGITAL 13
  310. #define MAGNITUDE_EVENT 14
  311. #define MAGNITUDE_PM1DOT0 15
  312. #define MAGNITUDE_PM2DOT5 16
  313. #define MAGNITUDE_PM10 17
  314. #define MAGNITUDE_CO2 18
  315. #define MAGNITUDE_LUX 19
  316. #define MAGNITUDE_UVA 20
  317. #define MAGNITUDE_UVB 21
  318. #define MAGNITUDE_UVI 22
  319. #define MAGNITUDE_DISTANCE 23
  320. #define MAGNITUDE_HCHO 24
  321. #define MAGNITUDE_GEIGER_CPM 25
  322. #define MAGNITUDE_GEIGER_SIEVERT 26
  323. #define MAGNITUDE_COUNT 27
  324. #define MAGNITUDE_NO2 28
  325. #define MAGNITUDE_CO 29
  326. #define MAGNITUDE_RESISTANCE 30
  327. #define MAGNITUDE_PH 31
  328. #define MAGNITUDE_FREQUENCY 32
  329. #define MAGNITUDE_IAQ 33
  330. #define MAGNITUDE_IAQ_ACCURACY 34
  331. #define MAGNITUDE_IAQ_STATIC 35
  332. #define MAGNITUDE_VOC 36
  333. #define MAGNITUDE_TVOC 37
  334. #define MAGNITUDE_CH2O 38
  335. #define MAGNITUDE_MAX 39
  336. // TODO: backwards compatible sensor integer values. should probably allow custom messsages
  337. // (even with the increased flash arequirements)
  338. #define SENSOR_ERROR_OK 0 // No error
  339. #define SENSOR_ERROR_OUT_OF_RANGE 1 // Result out of sensor range
  340. #define SENSOR_ERROR_WARM_UP 2 // Sensor is warming-up
  341. #define SENSOR_ERROR_TIMEOUT 3 // Response from sensor timed out
  342. #define SENSOR_ERROR_UNKNOWN_ID 4 // Sensor did not report a known ID
  343. #define SENSOR_ERROR_CRC 5 // Sensor data corrupted
  344. #define SENSOR_ERROR_I2C 6 // Wrong or locked I2C address
  345. #define SENSOR_ERROR_GPIO_USED 7 // The GPIO is already in use
  346. #define SENSOR_ERROR_CALIBRATION 8 // Calibration error or Not calibrated
  347. #define SENSOR_ERROR_OVERFLOW 9 // Value overflow
  348. #define SENSOR_ERROR_NOT_READY 10 // Device is not ready / available / disconnected
  349. #define SENSOR_ERROR_CONFIG 11 // Configuration values were invalid
  350. #define SENSOR_ERROR_SUPPORT 12 // Not supported
  351. #define SENSOR_ERROR_OTHER 99 // Any other error
  352. #define SENSOR_ERROR_MAX 13
  353. //------------------------------------------------------------------------------
  354. // OTA Client (not related to the Web OTA support)
  355. //------------------------------------------------------------------------------
  356. #define OTA_CLIENT_NONE 0
  357. #define OTA_CLIENT_ASYNCTCP 1
  358. #define OTA_CLIENT_HTTPUPDATE 2
  359. //------------------------------------------------------------------------------
  360. // Secure Client
  361. //------------------------------------------------------------------------------
  362. #define SECURE_CLIENT_NONE 0
  363. #define SECURE_CLIENT_AXTLS 1
  364. #define SECURE_CLIENT_BEARSSL 2
  365. #define SECURE_CLIENT_CHECK_NONE 0 // !!! INSECURE CONNECTION !!!
  366. #define SECURE_CLIENT_CHECK_FINGERPRINT 1 // legacy fingerprint validation
  367. #define SECURE_CLIENT_CHECK_CA 2 // set trust anchor from PROGMEM CA certificate
  368. //------------------------------------------------------------------------------
  369. // WiFi
  370. //------------------------------------------------------------------------------
  371. #define WIFI_SLEEP_MODE_NONE NONE_SLEEP_T
  372. #define WIFI_SLEEP_MODE_MODEM MODEM_SLEEP_T
  373. #define WIFI_SLEEP_MODE_LIGHT LIGHT_SLEEP_T