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.

408 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. #elif defined(SONOFF_4CH)
  124. #define MANUFACTURER "ITEAD"
  125. #define DEVICE "SONOFF_4CH"
  126. #define BUTTON1_PIN 0
  127. #define BUTTON1_RELAY 1
  128. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  129. #define BUTTON2_PIN 9
  130. #define BUTTON2_RELAY 2
  131. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  132. #define BUTTON3_PIN 10
  133. #define BUTTON3_RELAY 3
  134. #define BUTTON3_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  135. #define BUTTON4_PIN 14
  136. #define BUTTON4_RELAY 4
  137. #define BUTTON4_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  138. #define RELAY1_PIN 12
  139. #define RELAY1_PIN_INVERSE 0
  140. #define RELAY2_PIN 5
  141. #define RELAY2_PIN_INVERSE 0
  142. #define RELAY3_PIN 4
  143. #define RELAY3_PIN_INVERSE 0
  144. #define RELAY4_PIN 15
  145. #define RELAY4_PIN_INVERSE 0
  146. #define LED1_PIN 13
  147. #define LED1_PIN_INVERSE 1
  148. #elif defined(ITEAD_1CH_INCHING)
  149. // The inching functionality is managed by a misterious IC in the board.
  150. // You cannot control the inching button and functionality from the ESP8266
  151. // Besides, enabling the inching functionality using the hardware button
  152. // will result in the relay switching on and off continuously.
  153. // Fortunately the unkown IC keeps memory of the hardware inching status
  154. // so you can just disable it and forget. The inching LED must be lit.
  155. // You can still use the pulse options from the web interface
  156. // without problem.
  157. #define MANUFACTURER "ITEAD"
  158. #define DEVICE "1CH_INCHING"
  159. #define BUTTON1_PIN 0
  160. #define BUTTON1_RELAY 1
  161. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  162. #define RELAY1_PIN 12
  163. #define RELAY1_PIN_INVERSE 0
  164. #define LED1_PIN 13
  165. #define LED1_PIN_INVERSE 1
  166. #elif defined(ITEAD_MOTOR)
  167. #define MANUFACTURER "ITEAD"
  168. #define DEVICE "MOTOR"
  169. #define BUTTON1_PIN 0
  170. #define BUTTON1_RELAY 1
  171. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  172. #define RELAY1_PIN 12
  173. #define RELAY1_PIN_INVERSE 0
  174. #define LED1_PIN 13
  175. #define LED1_PIN_INVERSE 1
  176. // -----------------------------------------------------------------------------
  177. // Electrodragon boards
  178. // -----------------------------------------------------------------------------
  179. #elif defined(ESP_RELAY_BOARD)
  180. #define MANUFACTURER "ELECTRODRAGON"
  181. #define DEVICE "ESP_RELAY_BOARD"
  182. #define BUTTON1_PIN 0
  183. #define BUTTON1_RELAY 1
  184. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  185. #define BUTTON2_PIN 2
  186. #define BUTTON2_RELAY 2
  187. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  188. #define RELAY1_PIN 12
  189. #define RELAY1_PIN_INVERSE 0
  190. #define RELAY2_PIN 13
  191. #define RELAY2_PIN_INVERSE 0
  192. #define LED1_PIN 16
  193. #define LED1_PIN_INVERSE 0
  194. // -----------------------------------------------------------------------------
  195. // WorkChoice ecoPlug
  196. // -----------------------------------------------------------------------------
  197. #elif defined(ECOPLUG)
  198. #define MANUFACTURER "WORKCHOICE"
  199. #define DEVICE "ECOPLUG"
  200. #define BUTTON1_PIN 13
  201. #define BUTTON1_RELAY 1
  202. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  203. #define RELAY1_PIN 15
  204. #define RELAY1_PIN_INVERSE 0
  205. #define LED1_PIN 2
  206. #define LED1_PIN_INVERSE 0
  207. // -----------------------------------------------------------------------------
  208. // Jan Goedeke Wifi Relay
  209. // https://github.com/JanGoe/esp8266-wifi-relay
  210. // -----------------------------------------------------------------------------
  211. #elif defined(WIFI_RELAY_NC)
  212. #define MANUFACTURER "JAN_GOEDEKE"
  213. #define DEVICE "WIFI_RELAY_NC"
  214. #define BUTTON1_PIN 12
  215. #define BUTTON1_RELAY 1
  216. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  217. #define BUTTON2_PIN 13
  218. #define BUTTON2_RELAY 2
  219. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  220. #define RELAY1_PIN 2
  221. #define RELAY1_PIN_INVERSE 1
  222. #define RELAY2_PIN 14
  223. #define RELAY2_PIN_INVERSE 1
  224. #elif defined(WIFI_RELAY_NO)
  225. #define MANUFACTURER "JAN_GOEDEKE"
  226. #define DEVICE "WIFI_RELAY_NO"
  227. #define BUTTON1_PIN 12
  228. #define BUTTON1_RELAY 1
  229. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  230. #define BUTTON2_PIN 13
  231. #define BUTTON2_RELAY 2
  232. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  233. #define RELAY1_PIN 2
  234. #define RELAY1_PIN_INVERSE 0
  235. #define RELAY2_PIN 14
  236. #define RELAY2_PIN_INVERSE 0
  237. // -----------------------------------------------------------------------------
  238. // Jorge García Wifi+Relays Board Kit
  239. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  240. // https://github.com/jorgegarciadev/wifikit
  241. // -----------------------------------------------------------------------------
  242. #elif defined(WIFI_RELAYS_BOARD_KIT)
  243. #define MANUFACTURER "JORGE_GARCIA"
  244. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  245. #define RELAY1_PIN 0
  246. #define RELAY1_PIN_INVERSE 1
  247. #define RELAY2_PIN 2
  248. #define RELAY2_PIN_INVERSE 1
  249. // -----------------------------------------------------------------------------
  250. // WiFi MQTT Relay / Thermostat
  251. // -----------------------------------------------------------------------------
  252. #elif defined(MQTT_RELAY)
  253. #define MANUFACTURER "OPENENERGYMONITOR"
  254. #define DEVICE "MQTT_RELAY"
  255. #define BUTTON1_PIN 0
  256. #define BUTTON1_RELAY 1
  257. #define RELAY1_PIN 12
  258. #define RELAY1_PIN_INVERSE 0
  259. #define LED1_PIN 16
  260. #define LED1_PIN_INVERSE 0
  261. // -----------------------------------------------------------------------------
  262. // Unknown hardware
  263. // -----------------------------------------------------------------------------
  264. #else
  265. #error "UNSUPPORTED HARDWARE!"
  266. #endif
  267. // -----------------------------------------------------------------------------
  268. // Default values
  269. // -----------------------------------------------------------------------------
  270. #ifndef BUTTON1_PRESS
  271. #define BUTTON1_PRESS BUTTON_MODE_NONE
  272. #endif
  273. #ifndef BUTTON2_PRESS
  274. #define BUTTON2_PRESS BUTTON_MODE_NONE
  275. #endif
  276. #ifndef BUTTON3_PRESS
  277. #define BUTTON3_PRESS BUTTON_MODE_NONE
  278. #endif
  279. #ifndef BUTTON4_PRESS
  280. #define BUTTON4_PRESS BUTTON_MODE_NONE
  281. #endif
  282. #ifndef BUTTON1_CLICK
  283. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  284. #endif
  285. #ifndef BUTTON2_CLICK
  286. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  287. #endif
  288. #ifndef BUTTON3_CLICK
  289. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  290. #endif
  291. #ifndef BUTTON4_CLICK
  292. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  293. #endif
  294. #ifndef BUTTON1_DBLCLICK
  295. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  296. #endif
  297. #ifndef BUTTON2_DBLCLICK
  298. #define BUTTON2_DBLCLICK BUTTON_MODE_AP
  299. #endif
  300. #ifndef BUTTON3_DBLCLICK
  301. #define BUTTON3_DBLCLICK BUTTON_MODE_AP
  302. #endif
  303. #ifndef BUTTON4_DBLCLICK
  304. #define BUTTON4_DBLCLICK BUTTON_MODE_AP
  305. #endif
  306. #ifndef BUTTON1_LNGCLICK
  307. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  308. #endif
  309. #ifndef BUTTON2_LNGCLICK
  310. #define BUTTON2_LNGCLICK BUTTON_MODE_RESET
  311. #endif
  312. #ifndef BUTTON3_LNGCLICK
  313. #define BUTTON3_LNGCLICK BUTTON_MODE_RESET
  314. #endif
  315. #ifndef BUTTON4_LNGCLICK
  316. #define BUTTON4_LNGCLICK BUTTON_MODE_RESET
  317. #endif
  318. #ifndef BUTTON1_RELAY
  319. #define BUTTON1_RELAY 0
  320. #endif
  321. #ifndef BUTTON2_RELAY
  322. #define BUTTON2_RELAY 0
  323. #endif
  324. #ifndef BUTTON3_RELAY
  325. #define BUTTON3_RELAY 0
  326. #endif
  327. #ifndef BUTTON4_RELAY
  328. #define BUTTON4_RELAY 0
  329. #endif
  330. #ifndef RELAY1_LED
  331. #define RELAY1_LED 0
  332. #endif
  333. #ifndef RELAY2_LED
  334. #define RELAY2_LED 0
  335. #endif
  336. #ifndef RELAY3_LED
  337. #define RELAY3_LED 0
  338. #endif
  339. #ifndef RELAY4_LED
  340. #define RELAY4_LED 0
  341. #endif
  342. #ifndef WIFI_LED
  343. #define WIFI_LED 1
  344. #endif
  345. // Needed for ESP8285 boards under Windows using PlatformIO (?)
  346. #ifndef BUTTON_PUSHBUTTON
  347. #define BUTTON_PUSHBUTTON 0
  348. #define BUTTON_SWITCH 1
  349. #define BUTTON_DEFAULT_HIGH 2
  350. #define BUTTON_SET_PULLUP 4
  351. #endif