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.

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