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.

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