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.

370 lines
12 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. // Note: definitions for this board are based on third party data
  148. // and have not been fully tested yet. If you have the chance to
  149. // test them, please report back. Thank you.
  150. #define MANUFACTURER "ITEAD"
  151. #define DEVICE "1CH_INCHING"
  152. #define BUTTON1_PIN 0
  153. #define BUTTON1_RELAY 1
  154. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  155. #define BUTTON2_PIN 15
  156. #define BUTTON2_CLICK BUTTON_MODE_PULSE
  157. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  158. #define RELAY1_PIN 12
  159. #define RELAY1_PIN_INVERSE 0
  160. #define LED1_PIN 13
  161. #define LED1_PIN_INVERSE 0
  162. // Special LED that shows pulse mode status
  163. #define LED_PULSE 14
  164. // -----------------------------------------------------------------------------
  165. // Electrodragon boards
  166. // -----------------------------------------------------------------------------
  167. #elif defined(ESP_RELAY_BOARD)
  168. #define MANUFACTURER "ELECTRODRAGON"
  169. #define DEVICE "ESP_RELAY_BOARD"
  170. #define BUTTON1_PIN 0
  171. #define BUTTON1_RELAY 1
  172. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  173. #define BUTTON2_PIN 2
  174. #define BUTTON2_RELAY 2
  175. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  176. #define RELAY1_PIN 12
  177. #define RELAY1_PIN_INVERSE 0
  178. #define RELAY2_PIN 13
  179. #define RELAY2_PIN_INVERSE 0
  180. #define LED1_PIN 16
  181. #define LED1_PIN_INVERSE 0
  182. // -----------------------------------------------------------------------------
  183. // WorkChoice ecoPlug
  184. // -----------------------------------------------------------------------------
  185. #elif defined(ECOPLUG)
  186. #define MANUFACTURER "WORKCHOICE"
  187. #define DEVICE "ECOPLUG"
  188. #define BUTTON1_PIN 13
  189. #define BUTTON1_RELAY 1
  190. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  191. #define RELAY1_PIN 15
  192. #define RELAY1_PIN_INVERSE 0
  193. #define LED1_PIN 2
  194. #define LED1_PIN_INVERSE 0
  195. // -----------------------------------------------------------------------------
  196. // Jan Goedeke Wifi Relay
  197. // https://github.com/JanGoe/esp8266-wifi-relay
  198. // -----------------------------------------------------------------------------
  199. #elif defined(WIFI_RELAY_NC)
  200. #define MANUFACTURER "JAN_GOEDEKE"
  201. #define DEVICE "WIFI_RELAY_NC"
  202. #define BUTTON1_PIN 12
  203. #define BUTTON1_RELAY 1
  204. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  205. #define BUTTON2_PIN 13
  206. #define BUTTON2_RELAY 2
  207. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  208. #define RELAY1_PIN 2
  209. #define RELAY1_PIN_INVERSE 1
  210. #define RELAY2_PIN 14
  211. #define RELAY2_PIN_INVERSE 1
  212. #elif defined(WIFI_RELAY_NO)
  213. #define MANUFACTURER "JAN_GOEDEKE"
  214. #define DEVICE "WIFI_RELAY_NO"
  215. #define BUTTON1_PIN 12
  216. #define BUTTON1_RELAY 1
  217. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  218. #define BUTTON2_PIN 13
  219. #define BUTTON2_RELAY 2
  220. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  221. #define RELAY1_PIN 2
  222. #define RELAY1_PIN_INVERSE 0
  223. #define RELAY2_PIN 14
  224. #define RELAY2_PIN_INVERSE 0
  225. // -----------------------------------------------------------------------------
  226. // Jorge García Wifi+Relays Board Kit
  227. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  228. // https://github.com/jorgegarciadev/wifikit
  229. // -----------------------------------------------------------------------------
  230. #elif defined(WIFI_RELAYS_BOARD_KIT)
  231. #define MANUFACTURER "JORGE_GARCIA"
  232. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  233. #define RELAY1_PIN 0
  234. #define RELAY1_PIN_INVERSE 1
  235. #define RELAY2_PIN 2
  236. #define RELAY2_PIN_INVERSE 1
  237. // -----------------------------------------------------------------------------
  238. // WiFi MQTT Relay / Thermostat
  239. // -----------------------------------------------------------------------------
  240. #elif defined(MQTT_RELAY)
  241. #define MANUFACTURER "OPENENERGYMONITOR"
  242. #define DEVICE "MQTT_RELAY"
  243. #define BUTTON1_PIN 0
  244. #define BUTTON1_RELAY 1
  245. #define RELAY1_PIN 12
  246. #define RELAY1_PIN_INVERSE 0
  247. #define LED1_PIN 16
  248. #define LED1_PIN_INVERSE 0
  249. // -----------------------------------------------------------------------------
  250. // Unknown hardware
  251. // -----------------------------------------------------------------------------
  252. #else
  253. #error "UNSUPPORTED HARDWARE!"
  254. #endif
  255. // -----------------------------------------------------------------------------
  256. // Default values
  257. // -----------------------------------------------------------------------------
  258. #ifndef BUTTON1_PRESS
  259. #define BUTTON1_PRESS BUTTON_MODE_NONE
  260. #endif
  261. #ifndef BUTTON2_PRESS
  262. #define BUTTON2_PRESS BUTTON_MODE_NONE
  263. #endif
  264. #ifndef BUTTON3_PRESS
  265. #define BUTTON3_PRESS BUTTON_MODE_NONE
  266. #endif
  267. #ifndef BUTTON4_PRESS
  268. #define BUTTON4_PRESS BUTTON_MODE_NONE
  269. #endif
  270. #ifndef BUTTON1_CLICK
  271. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  272. #endif
  273. #ifndef BUTTON2_CLICK
  274. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  275. #endif
  276. #ifndef BUTTON3_CLICK
  277. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  278. #endif
  279. #ifndef BUTTON4_CLICK
  280. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  281. #endif
  282. #ifndef BUTTON1_DBLCLICK
  283. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  284. #endif
  285. #ifndef BUTTON2_DBLCLICK
  286. #define BUTTON2_DBLCLICK BUTTON_MODE_AP
  287. #endif
  288. #ifndef BUTTON3_DBLCLICK
  289. #define BUTTON3_DBLCLICK BUTTON_MODE_AP
  290. #endif
  291. #ifndef BUTTON4_DBLCLICK
  292. #define BUTTON4_DBLCLICK BUTTON_MODE_AP
  293. #endif
  294. #ifndef BUTTON1_LNGCLICK
  295. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  296. #endif
  297. #ifndef BUTTON2_LNGCLICK
  298. #define BUTTON2_LNGCLICK BUTTON_MODE_RESET
  299. #endif
  300. #ifndef BUTTON3_LNGCLICK
  301. #define BUTTON3_LNGCLICK BUTTON_MODE_RESET
  302. #endif
  303. #ifndef BUTTON4_LNGCLICK
  304. #define BUTTON4_LNGCLICK BUTTON_MODE_RESET
  305. #endif
  306. #ifndef BUTTON1_RELAY
  307. #define BUTTON1_RELAY 0
  308. #endif
  309. #ifndef BUTTON2_RELAY
  310. #define BUTTON2_RELAY 0
  311. #endif
  312. #ifndef BUTTON3_RELAY
  313. #define BUTTON3_RELAY 0
  314. #endif
  315. #ifndef BUTTON4_RELAY
  316. #define BUTTON4_RELAY 0
  317. #endif