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.

465 lines
15 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. #if defined(NODEMCU_LOLIN)
  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("relayType", 1, RELAY_TYPE_NORMAL);
  20. #elif defined(WEMOS_D1_MINI_RELAYSHIELD)
  21. setSetting("board", 3);
  22. setSetting("ledGPIO", 1, 2);
  23. setSetting("ledLogic", 1, 1);
  24. setSetting("relayGPIO", 1, 5);
  25. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  26. #elif defined(ITEAD_SONOFF_BASIC)
  27. setSetting("board", 4);
  28. setSetting("ledGPIO", 1, 13);
  29. setSetting("ledLogic", 1, 1);
  30. setSetting("btnGPIO", 1, 0);
  31. setSetting("btnRelay", 1, 1);
  32. setSetting("relayGPIO", 1, 12);
  33. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  34. #elif defined(ITEAD_SONOFF_TH)
  35. setSetting("board", 5);
  36. setSetting("ledGPIO", 1, 13);
  37. setSetting("ledLogic", 1, 1);
  38. setSetting("btnGPIO", 1, 0);
  39. setSetting("btnRelay", 1, 1);
  40. setSetting("relayGPIO", 1, 12);
  41. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  42. #elif defined(ITEAD_SONOFF_SV)
  43. setSetting("board", 6);
  44. setSetting("ledGPIO", 1, 13);
  45. setSetting("ledLogic", 1, 1);
  46. setSetting("btnGPIO", 1, 0);
  47. setSetting("btnRelay", 1, 1);
  48. setSetting("relayGPIO", 1, 12);
  49. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  50. #elif defined(ITEAD_SONOFF_TOUCH)
  51. setSetting("board", 7);
  52. setSetting("ledGPIO", 1, 13);
  53. setSetting("ledLogic", 1, 1);
  54. setSetting("btnGPIO", 1, 0);
  55. setSetting("btnRelay", 1, 1);
  56. setSetting("relayGPIO", 1, 12);
  57. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  58. #elif defined(ITEAD_SONOFF_POW)
  59. setSetting("board", 8);
  60. setSetting("ledGPIO", 1, 15);
  61. setSetting("ledLogic", 1, 1);
  62. setSetting("btnGPIO", 1, 0);
  63. setSetting("btnRelay", 1, 1);
  64. setSetting("relayGPIO", 1, 12);
  65. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  66. setSetting("selGPIO", 5);
  67. setSetting("cf1GPIO", 13);
  68. setSetting("cfGPIO", 14);
  69. #elif defined(ITEAD_SONOFF_DUAL)
  70. setSetting("board", 9);
  71. setSetting("ledGPIO", 1, 13);
  72. setSetting("ledLogic", 1, 1);
  73. setSetting("btnRelay", 3, 1);
  74. setSetting("relayProvider", RELAY_PROVIDER_DUAL);
  75. setSetting("relays", 2);
  76. #elif defined(ITEAD_1CH_INCHING)
  77. setSetting("board", 10);
  78. setSetting("ledGPIO", 1, 13);
  79. setSetting("ledLogic", 1, 1);
  80. setSetting("btnGPIO", 1, 0);
  81. setSetting("btnRelay", 1, 1);
  82. setSetting("relayGPIO", 1, 12);
  83. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  84. #elif defined(ITEAD_SONOFF_4CH)
  85. setSetting("board", 11);
  86. setSetting("ledGPIO", 1, 13);
  87. setSetting("ledLogic", 1, 1);
  88. setSetting("btnGPIO", 1, 0);
  89. setSetting("btnGPIO", 2, 9);
  90. setSetting("btnGPIO", 3, 10);
  91. setSetting("btnGPIO", 4, 14);
  92. setSetting("btnRelay", 1, 1);
  93. setSetting("btnRelay", 2, 2);
  94. setSetting("btnRelay", 3, 3);
  95. setSetting("btnRelay", 4, 4);
  96. setSetting("relayGPIO", 1, 12);
  97. setSetting("relayGPIO", 2, 5);
  98. setSetting("relayGPIO", 3, 4);
  99. setSetting("relayGPIO", 4, 15);
  100. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  101. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  102. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  103. setSetting("relayType", 4, RELAY_TYPE_NORMAL);
  104. #elif defined(ITEAD_SLAMPHER)
  105. setSetting("board", 12);
  106. setSetting("ledGPIO", 1, 13);
  107. setSetting("ledLogic", 1, 1);
  108. setSetting("btnGPIO", 1, 0);
  109. setSetting("btnRelay", 1, 1);
  110. setSetting("relayGPIO", 1, 12);
  111. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  112. #elif defined(ITEAD_S20)
  113. setSetting("board", 13);
  114. setSetting("ledGPIO", 1, 13);
  115. setSetting("ledLogic", 1, 1);
  116. setSetting("btnGPIO", 1, 0);
  117. setSetting("btnRelay", 1, 1);
  118. setSetting("relayGPIO", 1, 12);
  119. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  120. #elif defined(ELECTRODRAGON_WIFI_IOT)
  121. setSetting("board", 14);
  122. setSetting("ledGPIO", 1, 16);
  123. setSetting("ledLogic", 1, 0);
  124. setSetting("btnGPIO", 1, 0);
  125. setSetting("btnGPIO", 2, 2);
  126. setSetting("btnRelay", 1, 1);
  127. setSetting("btnRelay", 2, 2);
  128. setSetting("relayGPIO", 1, 12);
  129. setSetting("relayGPIO", 2, 13);
  130. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  131. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  132. #elif defined(WORKCHOICE_ECOPLUG)
  133. setSetting("board", 15);
  134. setSetting("ledGPIO", 1, 2);
  135. setSetting("ledLogic", 1, 0);
  136. setSetting("btnGPIO", 1, 13);
  137. setSetting("btnRelay", 1, 1);
  138. setSetting("relayGPIO", 1, 15);
  139. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  140. #elif defined(JANGOE_WIFI_RELAY_NC)
  141. setSetting("board", 16);
  142. setSetting("btnGPIO", 1, 12);
  143. setSetting("btnGPIO", 2, 13);
  144. setSetting("btnRelay", 1, 1);
  145. setSetting("btnRelay", 2, 2);
  146. setSetting("relayGPIO", 1, 2);
  147. setSetting("relayGPIO", 2, 14);
  148. setSetting("relayType", 1, RELAY_TYPE_INVERSE);
  149. setSetting("relayType", 2, RELAY_TYPE_INVERSE);
  150. #elif defined(JANGOE_WIFI_RELAY_NO)
  151. setSetting("board", 17);
  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("relayType", 1, RELAY_TYPE_NORMAL);
  159. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  160. #elif defined(OPENENERGYMONITOR_MQTT_RELAY)
  161. setSetting("board", 18);
  162. setSetting("ledGPIO", 1, 16);
  163. setSetting("ledLogic", 1, 1);
  164. setSetting("btnGPIO", 1, 0);
  165. setSetting("btnRelay", 1, 1);
  166. setSetting("relayGPIO", 1, 12);
  167. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  168. #elif defined(JORGEGARCIA_WIFI_RELAYS)
  169. setSetting("board", 19);
  170. setSetting("relayGPIO", 1, 0);
  171. setSetting("relayGPIO", 2, 2);
  172. setSetting("relayType", 1, RELAY_TYPE_INVERSE);
  173. setSetting("relayType", 2, RELAY_TYPE_INVERSE);
  174. #elif defined(AITHINKER_AI_LIGHT)
  175. setSetting("board", 20);
  176. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  177. setSetting("lightProvider", LIGHT_PROVIDER_MY9192);
  178. setSetting("myDIGPIO", 13);
  179. setSetting("myDCKIGPIO", 15);
  180. setSetting("relays", 1);
  181. #elif defined(MAGICHOME_LED_CONTROLLER)
  182. setSetting("board", 21);
  183. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  184. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  185. setSetting("ledGPIO", 1, 2);
  186. setSetting("ledLogic", 1, 1);
  187. setSetting("chGPIO", 1, 14);
  188. setSetting("chGPIO", 2, 5);
  189. setSetting("chGPIO", 3, 12);
  190. setSetting("chGPIO", 4, 13);
  191. setSetting("chLogic", 1, 0);
  192. setSetting("chLogic", 2, 0);
  193. setSetting("chLogic", 3, 0);
  194. setSetting("chLogic", 4, 0);
  195. setSetting("relays", 1);
  196. #elif defined(ITEAD_MOTOR)
  197. setSetting("board", 22);
  198. setSetting("ledGPIO", 1, 13);
  199. setSetting("ledLogic", 1, 1);
  200. setSetting("btnGPIO", 1, 0);
  201. setSetting("btnRelay", 1, 1);
  202. setSetting("relayGPIO", 1, 12);
  203. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  204. #elif defined(TINKERMAN_ESPURNA_H)
  205. setSetting("board", 23);
  206. setSetting("ledGPIO", 1, 5);
  207. setSetting("ledLogic", 1, 0);
  208. setSetting("btnGPIO", 1, 4);
  209. setSetting("btnRelay", 1, 1);
  210. setSetting("relayGPIO", 1, 12);
  211. setSetting("relayType", 1, RELAY_TYPE_INVERSE);
  212. setSetting("selGPIO", 2);
  213. setSetting("cf1GPIO", 13);
  214. setSetting("cfGPIO", 14);
  215. #elif defined(HUACANXING_H801)
  216. setSetting("board", 24);
  217. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  218. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  219. setSetting("ledGPIO", 1, 5);
  220. setSetting("ledLogic", 1, 1);
  221. setSetting("chGPIO", 1, 15);
  222. setSetting("chGPIO", 2, 13);
  223. setSetting("chGPIO", 3, 12);
  224. setSetting("chGPIO", 4, 14);
  225. setSetting("chGPIO", 5, 4);
  226. setSetting("chLogic", 1, 0);
  227. setSetting("chLogic", 2, 0);
  228. setSetting("chLogic", 3, 0);
  229. setSetting("chLogic", 4, 0);
  230. setSetting("chLogic", 5, 0);
  231. setSetting("relays", 1);
  232. #elif defined(ITEAD_BNSZ01)
  233. setSetting("board", 25);
  234. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  235. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  236. setSetting("ledGPIO", 3, 13);
  237. setSetting("ledLogic", 1, 1);
  238. setSetting("chGPIO", 1, 12);
  239. setSetting("chLogic", 1, 0);
  240. setSetting("relays", 1);
  241. #elif defined(ITEAD_SONOFF_RFBRIDGE)
  242. setSetting("board", 26);
  243. setSetting("ledGPIO", 1, 13);
  244. setSetting("ledLogic", 1, 1);
  245. setSetting("btnGPIO", 1, 0);
  246. setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE);
  247. setSetting("relays", 6);
  248. #elif defined(ITEAD_SONOFF_4CH_PRO)
  249. setSetting("board", 27);
  250. setSetting("ledGPIO", 1, 13);
  251. setSetting("ledLogic", 1, 1);
  252. setSetting("btnGPIO", 1, 0);
  253. setSetting("btnGPIO", 2, 9);
  254. setSetting("btnGPIO", 3, 10);
  255. setSetting("btnGPIO", 4, 14);
  256. setSetting("btnRelay", 1, 1);
  257. setSetting("btnRelay", 2, 2);
  258. setSetting("btnRelay", 3, 3);
  259. setSetting("btnRelay", 4, 4);
  260. setSetting("relayGPIO", 1, 12);
  261. setSetting("relayGPIO", 2, 5);
  262. setSetting("relayGPIO", 3, 4);
  263. setSetting("relayGPIO", 4, 15);
  264. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  265. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  266. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  267. setSetting("relayType", 4, RELAY_TYPE_NORMAL);
  268. #elif defined(ITEAD_SONOFF_B1)
  269. setSetting("board", 28);
  270. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  271. setSetting("lightProvider", LIGHT_PROVIDER_MY9192);
  272. setSetting("myDIGPIO", 12);
  273. setSetting("myDCKIGPIO", 14);
  274. setSetting("relays", 1);
  275. #elif defined(ITEAD_SONOFF_LED)
  276. setSetting("board", 29);
  277. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  278. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  279. setSetting("ledGPIO", 1, 13);
  280. setSetting("ledLogic", 1, 1);
  281. setSetting("chGPIO", 1, 12);
  282. setSetting("chLogic", 1, 0);
  283. setSetting("chGPIO", 2, 14);
  284. setSetting("chLogic", 2, 0);
  285. setSetting("relays", 1);
  286. #elif defined(ITEAD_SONOFF_T1_1CH)
  287. setSetting("board", 30);
  288. setSetting("ledGPIO", 1, 13);
  289. setSetting("ledLogic", 1, 1);
  290. setSetting("btnGPIO", 1, 9);
  291. setSetting("btnRelay", 1, 1);
  292. setSetting("relayGPIO", 1, 5);
  293. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  294. #elif defined(ITEAD_SONOFF_T1_2CH)
  295. setSetting("board", 31);
  296. setSetting("ledGPIO", 1, 13);
  297. setSetting("ledLogic", 1, 1);
  298. setSetting("btnGPIO", 1, 0);
  299. setSetting("btnGPIO", 2, 10);
  300. setSetting("btnRelay", 1, 1);
  301. setSetting("btnRelay", 2, 2);
  302. setSetting("relayGPIO", 1, 12);
  303. setSetting("relayGPIO", 2, 4);
  304. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  305. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  306. #elif defined(ITEAD_SONOFF_T1_3CH)
  307. setSetting("board", 32);
  308. setSetting("ledGPIO", 1, 13);
  309. setSetting("ledLogic", 1, 1);
  310. setSetting("btnGPIO", 1, 0);
  311. setSetting("btnGPIO", 2, 9);
  312. setSetting("btnGPIO", 3, 10);
  313. setSetting("btnRelay", 1, 1);
  314. setSetting("btnRelay", 2, 2);
  315. setSetting("btnRelay", 3, 3);
  316. setSetting("relayGPIO", 1, 12);
  317. setSetting("relayGPIO", 2, 5);
  318. setSetting("relayGPIO", 3, 4);
  319. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  320. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  321. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  322. #elif defined(ITEAD_SONOFF_RF)
  323. setSetting("board", 33);
  324. setSetting("ledGPIO", 1, 13);
  325. setSetting("ledLogic", 1, 1);
  326. setSetting("btnGPIO", 1, 0);
  327. setSetting("btnRelay", 1, 1);
  328. setSetting("relayGPIO", 1, 12);
  329. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  330. #elif defined(WION_50055)
  331. setSetting("board", 34);
  332. setSetting("ledGPIO", 1, 2);
  333. setSetting("ledLogic", 1, 0);
  334. setSetting("btnGPIO", 1, 13);
  335. setSetting("btnRelay", 1,1);
  336. setSetting("relayGPIO", 1, 15);
  337. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  338. #elif defined(EXS_WIFI_RELAY_V31)
  339. setSetting("board", 35);
  340. setSetting("btnGPIO", 1, 0);
  341. setSetting("btnRelay", 1, 1);
  342. setSetting("relayGPIO", 1, 13);
  343. setSetting("relayResetGPIO", 1, 12);
  344. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  345. #elif defined(HUACANXING_H802)
  346. setSetting("board", 36);
  347. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  348. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  349. setSetting("chGPIO", 1, 12);
  350. setSetting("chGPIO", 2, 14);
  351. setSetting("chGPIO", 3, 13);
  352. setSetting("chGPIO", 4, 15);
  353. setSetting("chLogic", 1, 0);
  354. setSetting("chLogic", 2, 0);
  355. setSetting("chLogic", 3, 0);
  356. setSetting("chLogic", 4, 0);
  357. setSetting("relays", 1);
  358. #elif defined(GENERIC_V9261F)
  359. setSetting("board", 37);
  360. #elif defined(GENERIC_ECH1560)
  361. setSetting("board", 38);
  362. #elif defined(ESPLIVE)
  363. setSetting("board", 39);
  364. setSetting("btnGPIO", 1, 4);
  365. setSetting("btnGPIO", 2, 5);
  366. setSetting("btnRelay", 1, 1);
  367. setSetting("btnRelay", 2, 2);
  368. setSetting("relayGPIO", 1, 12);
  369. setSetting("relayGPIO", 2, 13);
  370. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  371. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  372. #else
  373. #error "UNSUPPORTED HARDWARE!"
  374. #endif
  375. saveSettings();
  376. }