Fork of the espurna firmware for `mhsw` switches
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.

421 lines
14 KiB

  1. // -----------------------------------------------------------------------------
  2. // Configuration HELP
  3. // -----------------------------------------------------------------------------
  4. //
  5. // MANUFACTURER: Name of the manufacturer of the board ("string")
  6. // DEVICE: Name of the device ("string")
  7. // BUTTON#_PIN: GPIO for the n-th button (1-based, up to 4 buttons)
  8. // BUTTON#_RELAY: Relay number that will be bind to the n-th button (1-based)
  9. // BUTTON#_MODE: A mask of options (BUTTON_PUSHBUTTON and BUTTON_SWITCH cannot be together)
  10. // - BUTTON_PUSHBUTTON: button event is fired when released
  11. // - BUTTON_SWITCH: button event is fired when pressed or released
  12. // - BUTTON_DEFAULT_HIGH: there is a pull up in place
  13. // - BUTTON_SET_PULLUP: set pullup by software
  14. // RELAY#_PIN: GPIO for the n-th relay (1-based, up to 4 relays)
  15. // RELAY#_PIN_INVERSE: Relay has inversed logic (closed or ON when pulled down)
  16. // RELAY#_LED: LED number that will be bind to the n-th relay (1-based)
  17. // LED#_PIN: GPIO for the n-th LED (1-based, up to 4 LEDs)
  18. // LED#_PIN_INVERSE: LED has inversed logic (lit when pulled down)
  19. // WIFI_LED: LED number that will used for WIFI notifications (1-based, defaults to 1)
  20. // -----------------------------------------------------------------------------
  21. // Development boards
  22. // -----------------------------------------------------------------------------
  23. #if defined(NODEMCUV2)
  24. #define MANUFACTURER "NODEMCU"
  25. #define DEVICE "LOLIN"
  26. #define BUTTON1_PIN 0
  27. #define BUTTON1_RELAY 1
  28. #define BUTTON1_LNGCLICK BUTTON_MODE_PULSE
  29. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  30. #define RELAY1_PIN 12
  31. #define RELAY1_PIN_INVERSE 0
  32. #define LED1_PIN 2
  33. #define LED1_PIN_INVERSE 1
  34. #elif defined(D1_RELAYSHIELD)
  35. #define MANUFACTURER "WEMOS"
  36. #define DEVICE "D1_MINI"
  37. #define RELAY1_PIN 5
  38. #define RELAY1_PIN_INVERSE 0
  39. #define LED1_PIN 2
  40. #define LED1_PIN_INVERSE 1
  41. // -----------------------------------------------------------------------------
  42. // Itead Studio boards
  43. // -----------------------------------------------------------------------------
  44. #elif defined(SONOFF)
  45. #define MANUFACTURER "ITEAD"
  46. #define DEVICE "SONOFF"
  47. #define BUTTON1_PIN 0
  48. #define BUTTON1_RELAY 1
  49. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  50. #define RELAY1_PIN 12
  51. #define RELAY1_PIN_INVERSE 0
  52. #define LED1_PIN 13
  53. #define LED1_PIN_INVERSE 1
  54. #elif defined(SONOFF_TH)
  55. #define MANUFACTURER "ITEAD"
  56. #define DEVICE "SONOFF_TH"
  57. #define BUTTON1_PIN 0
  58. #define BUTTON1_RELAY 1
  59. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  60. #define RELAY1_PIN 12
  61. #define RELAY1_PIN_INVERSE 0
  62. #define LED1_PIN 13
  63. #define LED1_PIN_INVERSE 1
  64. #elif defined(SONOFF_SV)
  65. #define MANUFACTURER "ITEAD"
  66. #define DEVICE "SONOFF_SV"
  67. #define BUTTON1_PIN 0
  68. #define BUTTON1_RELAY 1
  69. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  70. #define RELAY1_PIN 12
  71. #define RELAY1_PIN_INVERSE 0
  72. #define LED1_PIN 13
  73. #define LED1_PIN_INVERSE 1
  74. #elif defined(SLAMPHER)
  75. #define MANUFACTURER "ITEAD"
  76. #define DEVICE "SLAMPHER"
  77. #define BUTTON1_PIN 0
  78. #define BUTTON1_RELAY 1
  79. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  80. #define RELAY1_PIN 12
  81. #define RELAY1_PIN_INVERSE 0
  82. #define LED1_PIN 13
  83. #define LED1_PIN_INVERSE 1
  84. #elif defined(S20)
  85. #define MANUFACTURER "ITEAD"
  86. #define DEVICE "S20"
  87. #define BUTTON1_PIN 0
  88. #define BUTTON1_RELAY 1
  89. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  90. #define RELAY1_PIN 12
  91. #define RELAY1_PIN_INVERSE 0
  92. #define LED1_PIN 13
  93. #define LED1_PIN_INVERSE 1
  94. #elif defined(SONOFF_TOUCH)
  95. #define MANUFACTURER "ITEAD"
  96. #define DEVICE "SONOFF_TOUCH"
  97. #define BUTTON1_PIN 0
  98. #define BUTTON1_RELAY 1
  99. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  100. #define RELAY1_PIN 12
  101. #define RELAY1_PIN_INVERSE 0
  102. #define LED1_PIN 13
  103. #define LED1_PIN_INVERSE 1
  104. #elif defined(SONOFF_POW)
  105. #define MANUFACTURER "ITEAD"
  106. #define DEVICE "SONOFF_POW"
  107. #define BUTTON1_PIN 0
  108. #define BUTTON1_RELAY 1
  109. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  110. #define RELAY1_PIN 12
  111. #define RELAY1_PIN_INVERSE 0
  112. #define LED1_PIN 15
  113. #define LED1_PIN_INVERSE 0
  114. #define ENABLE_POW 1
  115. #elif defined(SONOFF_DUAL)
  116. #define MANUFACTURER "ITEAD"
  117. #define DEVICE "SONOFF_DUAL"
  118. #define BUTTON3_RELAY 1
  119. #define LED1_PIN 13
  120. #define LED1_PIN_INVERSE 1
  121. #undef SERIAL_BAUDRATE
  122. #define SERIAL_BAUDRATE 19230
  123. #undef RELAY_PROVIDER
  124. #define RELAY_PROVIDER RELAY_PROVIDER_DUAL
  125. #elif defined(SONOFF_4CH)
  126. #define MANUFACTURER "ITEAD"
  127. #define DEVICE "SONOFF_4CH"
  128. #define BUTTON1_PIN 0
  129. #define BUTTON1_RELAY 1
  130. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  131. #define BUTTON2_PIN 9
  132. #define BUTTON2_RELAY 2
  133. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  134. #define BUTTON3_PIN 10
  135. #define BUTTON3_RELAY 3
  136. #define BUTTON3_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  137. #define BUTTON4_PIN 14
  138. #define BUTTON4_RELAY 4
  139. #define BUTTON4_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  140. #define RELAY1_PIN 12
  141. #define RELAY1_PIN_INVERSE 0
  142. #define RELAY2_PIN 5
  143. #define RELAY2_PIN_INVERSE 0
  144. #define RELAY3_PIN 4
  145. #define RELAY3_PIN_INVERSE 0
  146. #define RELAY4_PIN 15
  147. #define RELAY4_PIN_INVERSE 0
  148. #define LED1_PIN 13
  149. #define LED1_PIN_INVERSE 1
  150. #elif defined(ITEAD_1CH_INCHING)
  151. // The inching functionality is managed by a misterious IC in the board.
  152. // You cannot control the inching button and functionality from the ESP8266
  153. // Besides, enabling the inching functionality using the hardware button
  154. // will result in the relay switching on and off continuously.
  155. // Fortunately the unkown IC keeps memory of the hardware inching status
  156. // so you can just disable it and forget. The inching LED must be lit.
  157. // You can still use the pulse options from the web interface
  158. // without problem.
  159. #define MANUFACTURER "ITEAD"
  160. #define DEVICE "1CH_INCHING"
  161. #define BUTTON1_PIN 0
  162. #define BUTTON1_RELAY 1
  163. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  164. #define RELAY1_PIN 12
  165. #define RELAY1_PIN_INVERSE 0
  166. #define LED1_PIN 13
  167. #define LED1_PIN_INVERSE 1
  168. #elif defined(ITEAD_MOTOR)
  169. #define MANUFACTURER "ITEAD"
  170. #define DEVICE "MOTOR"
  171. #define BUTTON1_PIN 0
  172. #define BUTTON1_RELAY 1
  173. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  174. #define RELAY1_PIN 12
  175. #define RELAY1_PIN_INVERSE 0
  176. #define LED1_PIN 13
  177. #define LED1_PIN_INVERSE 1
  178. // -----------------------------------------------------------------------------
  179. // Electrodragon boards
  180. // -----------------------------------------------------------------------------
  181. #elif defined(ESP_RELAY_BOARD)
  182. #define MANUFACTURER "ELECTRODRAGON"
  183. #define DEVICE "ESP_RELAY_BOARD"
  184. #define BUTTON1_PIN 0
  185. #define BUTTON1_RELAY 1
  186. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  187. #define BUTTON2_PIN 2
  188. #define BUTTON2_RELAY 2
  189. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  190. #define RELAY1_PIN 12
  191. #define RELAY1_PIN_INVERSE 0
  192. #define RELAY2_PIN 13
  193. #define RELAY2_PIN_INVERSE 0
  194. #define LED1_PIN 16
  195. #define LED1_PIN_INVERSE 0
  196. // -----------------------------------------------------------------------------
  197. // WorkChoice ecoPlug
  198. // -----------------------------------------------------------------------------
  199. #elif defined(ECOPLUG)
  200. #define MANUFACTURER "WORKCHOICE"
  201. #define DEVICE "ECOPLUG"
  202. #define BUTTON1_PIN 13
  203. #define BUTTON1_RELAY 1
  204. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  205. #define RELAY1_PIN 15
  206. #define RELAY1_PIN_INVERSE 0
  207. #define LED1_PIN 2
  208. #define LED1_PIN_INVERSE 0
  209. // -----------------------------------------------------------------------------
  210. // AI Thinker
  211. // -----------------------------------------------------------------------------
  212. #elif defined(AI_LIGHT)
  213. #define MANUFACTURER "AI THINKER"
  214. #define DEVICE "AI LIGHT"
  215. #undef RELAY_PROVIDER
  216. #define RELAY_PROVIDER RELAY_PROVIDER_MY9291
  217. // -----------------------------------------------------------------------------
  218. // Jan Goedeke Wifi Relay
  219. // https://github.com/JanGoe/esp8266-wifi-relay
  220. // -----------------------------------------------------------------------------
  221. #elif defined(WIFI_RELAY_NC)
  222. #define MANUFACTURER "JAN_GOEDEKE"
  223. #define DEVICE "WIFI_RELAY_NC"
  224. #define BUTTON1_PIN 12
  225. #define BUTTON1_RELAY 1
  226. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  227. #define BUTTON2_PIN 13
  228. #define BUTTON2_RELAY 2
  229. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  230. #define RELAY1_PIN 2
  231. #define RELAY1_PIN_INVERSE 1
  232. #define RELAY2_PIN 14
  233. #define RELAY2_PIN_INVERSE 1
  234. #elif defined(WIFI_RELAY_NO)
  235. #define MANUFACTURER "JAN_GOEDEKE"
  236. #define DEVICE "WIFI_RELAY_NO"
  237. #define BUTTON1_PIN 12
  238. #define BUTTON1_RELAY 1
  239. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  240. #define BUTTON2_PIN 13
  241. #define BUTTON2_RELAY 2
  242. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  243. #define RELAY1_PIN 2
  244. #define RELAY1_PIN_INVERSE 0
  245. #define RELAY2_PIN 14
  246. #define RELAY2_PIN_INVERSE 0
  247. // -----------------------------------------------------------------------------
  248. // Jorge García Wifi+Relays Board Kit
  249. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  250. // https://github.com/jorgegarciadev/wifikit
  251. // -----------------------------------------------------------------------------
  252. #elif defined(WIFI_RELAYS_BOARD_KIT)
  253. #define MANUFACTURER "JORGE_GARCIA"
  254. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  255. #define RELAY1_PIN 0
  256. #define RELAY1_PIN_INVERSE 1
  257. #define RELAY2_PIN 2
  258. #define RELAY2_PIN_INVERSE 1
  259. // -----------------------------------------------------------------------------
  260. // WiFi MQTT Relay / Thermostat
  261. // -----------------------------------------------------------------------------
  262. #elif defined(MQTT_RELAY)
  263. #define MANUFACTURER "OPENENERGYMONITOR"
  264. #define DEVICE "MQTT_RELAY"
  265. #define BUTTON1_PIN 0
  266. #define BUTTON1_RELAY 1
  267. #define RELAY1_PIN 12
  268. #define RELAY1_PIN_INVERSE 0
  269. #define LED1_PIN 16
  270. #define LED1_PIN_INVERSE 0
  271. // -----------------------------------------------------------------------------
  272. // Unknown hardware
  273. // -----------------------------------------------------------------------------
  274. #else
  275. #error "UNSUPPORTED HARDWARE!"
  276. #endif
  277. // -----------------------------------------------------------------------------
  278. // Default values
  279. // -----------------------------------------------------------------------------
  280. #ifndef BUTTON1_PRESS
  281. #define BUTTON1_PRESS BUTTON_MODE_NONE
  282. #endif
  283. #ifndef BUTTON2_PRESS
  284. #define BUTTON2_PRESS BUTTON_MODE_NONE
  285. #endif
  286. #ifndef BUTTON3_PRESS
  287. #define BUTTON3_PRESS BUTTON_MODE_NONE
  288. #endif
  289. #ifndef BUTTON4_PRESS
  290. #define BUTTON4_PRESS BUTTON_MODE_NONE
  291. #endif
  292. #ifndef BUTTON1_CLICK
  293. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  294. #endif
  295. #ifndef BUTTON2_CLICK
  296. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  297. #endif
  298. #ifndef BUTTON3_CLICK
  299. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  300. #endif
  301. #ifndef BUTTON4_CLICK
  302. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  303. #endif
  304. #ifndef BUTTON1_DBLCLICK
  305. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  306. #endif
  307. #ifndef BUTTON2_DBLCLICK
  308. #define BUTTON2_DBLCLICK BUTTON_MODE_NONE
  309. #endif
  310. #ifndef BUTTON3_DBLCLICK
  311. #define BUTTON3_DBLCLICK BUTTON_MODE_NONE
  312. #endif
  313. #ifndef BUTTON4_DBLCLICK
  314. #define BUTTON4_DBLCLICK BUTTON_MODE_NONE
  315. #endif
  316. #ifndef BUTTON1_LNGCLICK
  317. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  318. #endif
  319. #ifndef BUTTON2_LNGCLICK
  320. #define BUTTON2_LNGCLICK BUTTON_MODE_NONE
  321. #endif
  322. #ifndef BUTTON3_LNGCLICK
  323. #define BUTTON3_LNGCLICK BUTTON_MODE_NONE
  324. #endif
  325. #ifndef BUTTON4_LNGCLICK
  326. #define BUTTON4_LNGCLICK BUTTON_MODE_NONE
  327. #endif
  328. #ifndef BUTTON1_RELAY
  329. #define BUTTON1_RELAY 0
  330. #endif
  331. #ifndef BUTTON2_RELAY
  332. #define BUTTON2_RELAY 0
  333. #endif
  334. #ifndef BUTTON3_RELAY
  335. #define BUTTON3_RELAY 0
  336. #endif
  337. #ifndef BUTTON4_RELAY
  338. #define BUTTON4_RELAY 0
  339. #endif
  340. #ifndef RELAY1_LED
  341. #define RELAY1_LED 0
  342. #endif
  343. #ifndef RELAY2_LED
  344. #define RELAY2_LED 0
  345. #endif
  346. #ifndef RELAY3_LED
  347. #define RELAY3_LED 0
  348. #endif
  349. #ifndef RELAY4_LED
  350. #define RELAY4_LED 0
  351. #endif
  352. #ifndef WIFI_LED
  353. #define WIFI_LED 1
  354. #endif
  355. // Needed for ESP8285 boards under Windows using PlatformIO (?)
  356. #ifndef BUTTON_PUSHBUTTON
  357. #define BUTTON_PUSHBUTTON 0
  358. #define BUTTON_SWITCH 1
  359. #define BUTTON_DEFAULT_HIGH 2
  360. #define BUTTON_SET_PULLUP 4
  361. #endif