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.

423 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. #define RELAY1_PIN 2
  216. #define RELAY1_PIN_INVERSE 0
  217. #undef RELAY_PROVIDER
  218. #define RELAY_PROVIDER RELAY_PROVIDER_MY9291
  219. // -----------------------------------------------------------------------------
  220. // Jan Goedeke Wifi Relay
  221. // https://github.com/JanGoe/esp8266-wifi-relay
  222. // -----------------------------------------------------------------------------
  223. #elif defined(WIFI_RELAY_NC)
  224. #define MANUFACTURER "JAN_GOEDEKE"
  225. #define DEVICE "WIFI_RELAY_NC"
  226. #define BUTTON1_PIN 12
  227. #define BUTTON1_RELAY 1
  228. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  229. #define BUTTON2_PIN 13
  230. #define BUTTON2_RELAY 2
  231. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  232. #define RELAY1_PIN 2
  233. #define RELAY1_PIN_INVERSE 1
  234. #define RELAY2_PIN 14
  235. #define RELAY2_PIN_INVERSE 1
  236. #elif defined(WIFI_RELAY_NO)
  237. #define MANUFACTURER "JAN_GOEDEKE"
  238. #define DEVICE "WIFI_RELAY_NO"
  239. #define BUTTON1_PIN 12
  240. #define BUTTON1_RELAY 1
  241. #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  242. #define BUTTON2_PIN 13
  243. #define BUTTON2_RELAY 2
  244. #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
  245. #define RELAY1_PIN 2
  246. #define RELAY1_PIN_INVERSE 0
  247. #define RELAY2_PIN 14
  248. #define RELAY2_PIN_INVERSE 0
  249. // -----------------------------------------------------------------------------
  250. // Jorge García Wifi+Relays Board Kit
  251. // https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit
  252. // https://github.com/jorgegarciadev/wifikit
  253. // -----------------------------------------------------------------------------
  254. #elif defined(WIFI_RELAYS_BOARD_KIT)
  255. #define MANUFACTURER "JORGE_GARCIA"
  256. #define DEVICE "WIFI_RELAYS_BOARD_KIT"
  257. #define RELAY1_PIN 0
  258. #define RELAY1_PIN_INVERSE 1
  259. #define RELAY2_PIN 2
  260. #define RELAY2_PIN_INVERSE 1
  261. // -----------------------------------------------------------------------------
  262. // WiFi MQTT Relay / Thermostat
  263. // -----------------------------------------------------------------------------
  264. #elif defined(MQTT_RELAY)
  265. #define MANUFACTURER "OPENENERGYMONITOR"
  266. #define DEVICE "MQTT_RELAY"
  267. #define BUTTON1_PIN 0
  268. #define BUTTON1_RELAY 1
  269. #define RELAY1_PIN 12
  270. #define RELAY1_PIN_INVERSE 0
  271. #define LED1_PIN 16
  272. #define LED1_PIN_INVERSE 0
  273. // -----------------------------------------------------------------------------
  274. // Unknown hardware
  275. // -----------------------------------------------------------------------------
  276. #else
  277. #error "UNSUPPORTED HARDWARE!"
  278. #endif
  279. // -----------------------------------------------------------------------------
  280. // Default values
  281. // -----------------------------------------------------------------------------
  282. #ifndef BUTTON1_PRESS
  283. #define BUTTON1_PRESS BUTTON_MODE_NONE
  284. #endif
  285. #ifndef BUTTON2_PRESS
  286. #define BUTTON2_PRESS BUTTON_MODE_NONE
  287. #endif
  288. #ifndef BUTTON3_PRESS
  289. #define BUTTON3_PRESS BUTTON_MODE_NONE
  290. #endif
  291. #ifndef BUTTON4_PRESS
  292. #define BUTTON4_PRESS BUTTON_MODE_NONE
  293. #endif
  294. #ifndef BUTTON1_CLICK
  295. #define BUTTON1_CLICK BUTTON_MODE_TOGGLE
  296. #endif
  297. #ifndef BUTTON2_CLICK
  298. #define BUTTON2_CLICK BUTTON_MODE_TOGGLE
  299. #endif
  300. #ifndef BUTTON3_CLICK
  301. #define BUTTON3_CLICK BUTTON_MODE_TOGGLE
  302. #endif
  303. #ifndef BUTTON4_CLICK
  304. #define BUTTON4_CLICK BUTTON_MODE_TOGGLE
  305. #endif
  306. #ifndef BUTTON1_DBLCLICK
  307. #define BUTTON1_DBLCLICK BUTTON_MODE_AP
  308. #endif
  309. #ifndef BUTTON2_DBLCLICK
  310. #define BUTTON2_DBLCLICK BUTTON_MODE_NONE
  311. #endif
  312. #ifndef BUTTON3_DBLCLICK
  313. #define BUTTON3_DBLCLICK BUTTON_MODE_NONE
  314. #endif
  315. #ifndef BUTTON4_DBLCLICK
  316. #define BUTTON4_DBLCLICK BUTTON_MODE_NONE
  317. #endif
  318. #ifndef BUTTON1_LNGCLICK
  319. #define BUTTON1_LNGCLICK BUTTON_MODE_RESET
  320. #endif
  321. #ifndef BUTTON2_LNGCLICK
  322. #define BUTTON2_LNGCLICK BUTTON_MODE_NONE
  323. #endif
  324. #ifndef BUTTON3_LNGCLICK
  325. #define BUTTON3_LNGCLICK BUTTON_MODE_NONE
  326. #endif
  327. #ifndef BUTTON4_LNGCLICK
  328. #define BUTTON4_LNGCLICK BUTTON_MODE_NONE
  329. #endif
  330. #ifndef BUTTON1_RELAY
  331. #define BUTTON1_RELAY 0
  332. #endif
  333. #ifndef BUTTON2_RELAY
  334. #define BUTTON2_RELAY 0
  335. #endif
  336. #ifndef BUTTON3_RELAY
  337. #define BUTTON3_RELAY 0
  338. #endif
  339. #ifndef BUTTON4_RELAY
  340. #define BUTTON4_RELAY 0
  341. #endif
  342. #ifndef RELAY1_LED
  343. #define RELAY1_LED 0
  344. #endif
  345. #ifndef RELAY2_LED
  346. #define RELAY2_LED 0
  347. #endif
  348. #ifndef RELAY3_LED
  349. #define RELAY3_LED 0
  350. #endif
  351. #ifndef RELAY4_LED
  352. #define RELAY4_LED 0
  353. #endif
  354. #ifndef WIFI_LED
  355. #define WIFI_LED 1
  356. #endif
  357. // Needed for ESP8285 boards under Windows using PlatformIO (?)
  358. #ifndef BUTTON_PUSHBUTTON
  359. #define BUTTON_PUSHBUTTON 0
  360. #define BUTTON_SWITCH 1
  361. #define BUTTON_DEFAULT_HIGH 2
  362. #define BUTTON_SET_PULLUP 4
  363. #endif