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.

327 lines
9.7 KiB

  1. /*
  2. HARDWARE MODULE
  3. Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. /*
  6. The goal of this file is to store board configuration values in EEPROM so
  7. the migration to future version 2 will be straigh forward.
  8. */
  9. void hwUpwardsCompatibility() {
  10. unsigned int board = getSetting("board", 0).toInt();
  11. if (board > 0) return;
  12. #ifdef NODEMCUV2
  13. setSetting("board", 2);
  14. setSetting("ledGPIO", 1, 2);
  15. setSetting("ledLogic", 1, 1);
  16. setSetting("btnGPIO", 1, 0);
  17. setSetting("btnRelay", 1, 1);
  18. setSetting("relayGPIO", 1, 12);
  19. setSetting("relayLogic", 1, 0);
  20. #endif
  21. #ifdef D1_RELAYSHIELD
  22. setSetting("board", 3);
  23. setSetting("ledGPIO", 1, 2);
  24. setSetting("ledLogic", 1, 1);
  25. setSetting("relayGPIO", 1, 5);
  26. setSetting("relayLogic", 1, 0);
  27. #endif
  28. #ifdef SONOFF
  29. setSetting("board", 4);
  30. setSetting("ledGPIO", 1, 13);
  31. setSetting("ledLogic", 1, 1);
  32. setSetting("btnGPIO", 1, 0);
  33. setSetting("btnRelay", 1, 1);
  34. setSetting("relayGPIO", 1, 12);
  35. setSetting("relayLogic", 1, 0);
  36. #endif
  37. #ifdef SONOFF_TH
  38. setSetting("board", 5);
  39. setSetting("ledGPIO", 1, 13);
  40. setSetting("ledLogic", 1, 1);
  41. setSetting("btnGPIO", 1, 0);
  42. setSetting("btnRelay", 1, 1);
  43. setSetting("relayGPIO", 1, 12);
  44. setSetting("relayLogic", 1, 0);
  45. #endif
  46. #ifdef SONOFF_SV
  47. setSetting("board", 6);
  48. setSetting("ledGPIO", 1, 13);
  49. setSetting("ledLogic", 1, 1);
  50. setSetting("btnGPIO", 1, 0);
  51. setSetting("btnRelay", 1, 1);
  52. setSetting("relayGPIO", 1, 12);
  53. setSetting("relayLogic", 1, 0);
  54. #endif
  55. #ifdef SONOFF_TOUCH
  56. setSetting("board", 7);
  57. setSetting("ledGPIO", 1, 13);
  58. setSetting("ledLogic", 1, 1);
  59. setSetting("btnGPIO", 1, 0);
  60. setSetting("btnRelay", 1, 1);
  61. setSetting("relayGPIO", 1, 12);
  62. setSetting("relayLogic", 1, 0);
  63. #endif
  64. #ifdef SONOFF_POW
  65. setSetting("board", 8);
  66. setSetting("ledGPIO", 1, 15);
  67. setSetting("ledLogic", 1, 1);
  68. setSetting("btnGPIO", 1, 0);
  69. setSetting("btnRelay", 1, 1);
  70. setSetting("relayGPIO", 1, 12);
  71. setSetting("relayLogic", 1, 0);
  72. #endif
  73. #ifdef SONOFF_DUAL
  74. setSetting("board", 9);
  75. setSetting("ledGPIO", 1, 13);
  76. setSetting("ledLogic", 1, 1);
  77. setSetting("btnRelay", 3, 1);
  78. setSetting("relayProvider", RELAY_PROVIDER_DUAL);
  79. #endif
  80. #ifdef ITEAD_1CH_INCHING
  81. setSetting("board", 10);
  82. setSetting("ledGPIO", 1, 13);
  83. setSetting("ledLogic", 1, 1);
  84. setSetting("btnGPIO", 1, 0);
  85. setSetting("btnRelay", 1, 1);
  86. setSetting("relayGPIO", 1, 12);
  87. setSetting("relayLogic", 1, 0);
  88. #endif
  89. #ifdef SONOFF_4CH
  90. setSetting("board", 11);
  91. setSetting("ledGPIO", 1, 13);
  92. setSetting("ledLogic", 1, 1);
  93. setSetting("btnGPIO", 1, 0);
  94. setSetting("btnGPIO", 2, 9);
  95. setSetting("btnGPIO", 3, 10);
  96. setSetting("btnGPIO", 4, 14);
  97. setSetting("btnRelay", 1, 2);
  98. setSetting("btnRelay", 2, 3);
  99. setSetting("btnRelay", 3, 4);
  100. setSetting("btnRelay", 4, 0);
  101. setSetting("relayGPIO", 1, 12);
  102. setSetting("relayGPIO", 2, 5);
  103. setSetting("relayGPIO", 3, 4);
  104. setSetting("relayGPIO", 4, 15);
  105. setSetting("relayLogic", 1, 0);
  106. setSetting("relayLogic", 2, 0);
  107. setSetting("relayLogic", 3, 0);
  108. setSetting("relayLogic", 4, 0);
  109. #endif
  110. #ifdef SLAMPHER
  111. setSetting("board", 12);
  112. setSetting("ledGPIO", 1, 13);
  113. setSetting("ledLogic", 1, 1);
  114. setSetting("btnGPIO", 1, 0);
  115. setSetting("btnRelay", 1, 1);
  116. setSetting("relayGPIO", 1, 12);
  117. setSetting("relayLogic", 1, 0);
  118. #endif
  119. #ifdef S20
  120. setSetting("board", 13);
  121. setSetting("ledGPIO", 1, 13);
  122. setSetting("ledLogic", 1, 1);
  123. setSetting("btnGPIO", 1, 0);
  124. setSetting("btnRelay", 1, 1);
  125. setSetting("relayGPIO", 1, 12);
  126. setSetting("relayLogic", 1, 0);
  127. #endif
  128. #ifdef ESP_RELAY_BOARD
  129. setSetting("board", 14);
  130. setSetting("ledGPIO", 1, 16);
  131. setSetting("ledLogic", 1, 0);
  132. setSetting("btnGPIO", 1, 0);
  133. setSetting("btnGPIO", 2, 2);
  134. setSetting("btnRelay", 1, 1);
  135. setSetting("btnRelay", 2, 2);
  136. setSetting("relayGPIO", 1, 12);
  137. setSetting("relayGPIO", 2, 13);
  138. setSetting("relayLogic", 1, 0);
  139. setSetting("relayLogic", 2, 0);
  140. #endif
  141. #ifdef ECOPLUG
  142. setSetting("board", 15);
  143. setSetting("ledGPIO", 1, 2);
  144. setSetting("ledLogic", 1, 0);
  145. setSetting("btnGPIO", 1, 13);
  146. setSetting("btnRelay", 1, 1);
  147. setSetting("relayGPIO", 1, 15);
  148. setSetting("relayLogic", 1, 0);
  149. #endif
  150. #ifdef WIFI_RELAY_NC
  151. setSetting("board", 16);
  152. setSetting("btnGPIO", 1, 12);
  153. setSetting("btnGPIO", 2, 13);
  154. setSetting("btnRelay", 1, 1);
  155. setSetting("btnRelay", 2, 2);
  156. setSetting("relayGPIO", 1, 2);
  157. setSetting("relayGPIO", 2, 14);
  158. setSetting("relayLogic", 1, 1);
  159. setSetting("relayLogic", 2, 1);
  160. #endif
  161. #ifdef WIFI_RELAY_NO
  162. setSetting("board", 17);
  163. setSetting("btnGPIO", 1, 12);
  164. setSetting("btnGPIO", 2, 13);
  165. setSetting("btnRelay", 1, 1);
  166. setSetting("btnRelay", 2, 2);
  167. setSetting("relayGPIO", 1, 2);
  168. setSetting("relayGPIO", 2, 14);
  169. setSetting("relayLogic", 1, 0);
  170. setSetting("relayLogic", 2, 0);
  171. #endif
  172. #ifdef MQTT_RELAY
  173. setSetting("board", 18);
  174. setSetting("ledGPIO", 1, 16);
  175. setSetting("ledLogic", 1, 1);
  176. setSetting("btnGPIO", 1, 0);
  177. setSetting("btnRelay", 1, 1);
  178. setSetting("relayGPIO", 1, 12);
  179. setSetting("relayLogic", 1, 0);
  180. #endif
  181. #ifdef WIFI_RELAYS_BOARD_KIT
  182. setSetting("board", 19);
  183. setSetting("relayGPIO", 1, 0);
  184. setSetting("relayLogic", 1, 1);
  185. setSetting("relayGPIO", 2, 2);
  186. setSetting("relayLogic", 2, 1);
  187. #endif
  188. #ifdef AI_LIGHT
  189. setSetting("board", 20);
  190. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  191. setSetting("lightProvider", LIGHT_PROVIDER_MY9192);
  192. setSetting("myDIGPIO", 13);
  193. setSetting("myDCKIGPIO", 15);
  194. #endif
  195. #ifdef LED_CONTROLLER
  196. setSetting("board", 21);
  197. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  198. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  199. setSetting("ledGPIO", 1, 2);
  200. setSetting("ledLogic", 1, 1);
  201. setSetting("ch1GPIO", 14);
  202. setSetting("ch2GPIO", 5);
  203. setSetting("ch3GPIO", 12);
  204. setSetting("ch4GPIO", 13);
  205. setSetting("ch1Logic", 0);
  206. setSetting("ch2Logic", 0);
  207. setSetting("ch3Logic", 0);
  208. setSetting("ch4Logic", 0);
  209. #endif
  210. #ifdef ITEAD_MOTOR
  211. setSetting("board", 22);
  212. setSetting("ledGPIO", 1, 13);
  213. setSetting("ledLogic", 1, 1);
  214. setSetting("btnGPIO", 1, 0);
  215. setSetting("btnRelay", 1, 1);
  216. setSetting("relayGPIO", 1, 12);
  217. setSetting("relayLogic", 1, 0);
  218. #endif
  219. #ifdef ESPURNA_H
  220. setSetting("board", 23);
  221. setSetting("ledGPIO", 1, 5);
  222. setSetting("ledLogic", 1, 0);
  223. setSetting("btnGPIO", 1, 4);
  224. setSetting("btnRelay", 1, 1);
  225. setSetting("relayGPIO", 1, 12);
  226. setSetting("relayLogic", 1, 1);
  227. #endif
  228. #ifdef H801_LED_CONTROLLER
  229. setSetting("board", 24);
  230. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  231. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  232. setSetting("ledGPIO", 5, 1);
  233. setSetting("ledLogic", 1, 1);
  234. setSetting("ch1GPIO", 15);
  235. setSetting("ch2GPIO", 13);
  236. setSetting("ch3GPIO", 12);
  237. setSetting("ch4GPIO", 14);
  238. setSetting("ch5GPIO", 4);
  239. setSetting("ch1Logic", 0);
  240. setSetting("ch2Logic", 0);
  241. setSetting("ch3Logic", 0);
  242. setSetting("ch4Logic", 0);
  243. setSetting("ch5Logic", 0);
  244. #endif
  245. #ifdef ITEAD_BNSZ01
  246. setSetting("board", 25);
  247. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  248. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  249. setSetting("ledGPIO", 13, 1);
  250. setSetting("ledLogic", 1, 1);
  251. setSetting("ch1GPIO", 12);
  252. setSetting("ch1Logic", 0);
  253. #endif
  254. #ifdef SONOFF_RFBRIDGE
  255. setSetting("board", 26);
  256. setSetting("ledGPIO", 1, 13);
  257. setSetting("ledLogic", 1, 1);
  258. setSetting("btnGPIO", 1, 0);
  259. setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE);
  260. #endif
  261. #ifdef SONOFF_4CH_PRO
  262. setSetting("board", 27);
  263. setSetting("ledGPIO", 1, 13);
  264. setSetting("ledLogic", 1, 1);
  265. setSetting("btnGPIO", 1, 0);
  266. setSetting("btnGPIO", 2, 9);
  267. setSetting("btnGPIO", 3, 10);
  268. setSetting("btnGPIO", 4, 14);
  269. setSetting("btnRelay", 1, 2);
  270. setSetting("btnRelay", 2, 3);
  271. setSetting("btnRelay", 3, 4);
  272. setSetting("btnRelay", 4, 0);
  273. setSetting("relayGPIO", 1, 12);
  274. setSetting("relayGPIO", 2, 5);
  275. setSetting("relayGPIO", 3, 4);
  276. setSetting("relayGPIO", 4, 15);
  277. setSetting("relayLogic", 1, 0);
  278. setSetting("relayLogic", 2, 0);
  279. setSetting("relayLogic", 3, 0);
  280. setSetting("relayLogic", 4, 0);
  281. #endif
  282. #ifdef SONOFF_B1
  283. setSetting("board", 28);
  284. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  285. setSetting("lightProvider", LIGHT_PROVIDER_MY9192);
  286. setSetting("myDIGPIO", 12);
  287. setSetting("myDCKIGPIO", 14);
  288. #endif
  289. saveSettings();
  290. }