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.

552 lines
18 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(MAGICHOME_LED_CONTROLLER_IR)
  199. setSetting("board", 21);
  200. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  201. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  202. setSetting("ledGPIO", 1, 2);
  203. setSetting("ledLogic", 1, 1);
  204. setSetting("chGPIO", 1, 5);
  205. setSetting("chGPIO", 2, 12);
  206. setSetting("chGPIO", 3, 13);
  207. setSetting("chGPIO", 4, 14);
  208. setSetting("chLogic", 1, 0);
  209. setSetting("chLogic", 2, 0);
  210. setSetting("chLogic", 3, 0);
  211. setSetting("chLogic", 4, 0);
  212. setSetting("relays", 1);
  213. #elif defined(ITEAD_MOTOR)
  214. setSetting("board", 22);
  215. setSetting("ledGPIO", 1, 13);
  216. setSetting("ledLogic", 1, 1);
  217. setSetting("btnGPIO", 1, 0);
  218. setSetting("btnRelay", 1, 1);
  219. setSetting("relayGPIO", 1, 12);
  220. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  221. #elif defined(TINKERMAN_ESPURNA_H06)
  222. setSetting("board", 23);
  223. setSetting("ledGPIO", 1, 5);
  224. setSetting("ledLogic", 1, 0);
  225. setSetting("btnGPIO", 1, 4);
  226. setSetting("btnRelay", 1, 1);
  227. setSetting("relayGPIO", 1, 12);
  228. setSetting("relayType", 1, RELAY_TYPE_INVERSE);
  229. setSetting("selGPIO", 2);
  230. setSetting("cf1GPIO", 13);
  231. setSetting("cfGPIO", 14);
  232. #elif defined(HUACANXING_H801)
  233. setSetting("board", 24);
  234. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  235. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  236. setSetting("ledGPIO", 1, 5);
  237. setSetting("ledLogic", 1, 1);
  238. setSetting("chGPIO", 1, 15);
  239. setSetting("chGPIO", 2, 13);
  240. setSetting("chGPIO", 3, 12);
  241. setSetting("chGPIO", 4, 14);
  242. setSetting("chGPIO", 5, 4);
  243. setSetting("chLogic", 1, 0);
  244. setSetting("chLogic", 2, 0);
  245. setSetting("chLogic", 3, 0);
  246. setSetting("chLogic", 4, 0);
  247. setSetting("chLogic", 5, 0);
  248. setSetting("relays", 1);
  249. #elif defined(ITEAD_BNSZ01)
  250. setSetting("board", 25);
  251. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  252. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  253. setSetting("ledGPIO", 3, 13);
  254. setSetting("ledLogic", 1, 1);
  255. setSetting("chGPIO", 1, 12);
  256. setSetting("chLogic", 1, 0);
  257. setSetting("relays", 1);
  258. #elif defined(ITEAD_SONOFF_RFBRIDGE)
  259. setSetting("board", 26);
  260. setSetting("ledGPIO", 1, 13);
  261. setSetting("ledLogic", 1, 1);
  262. setSetting("btnGPIO", 1, 0);
  263. setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE);
  264. setSetting("relays", 6);
  265. #elif defined(ITEAD_SONOFF_4CH_PRO)
  266. setSetting("board", 27);
  267. setSetting("ledGPIO", 1, 13);
  268. setSetting("ledLogic", 1, 1);
  269. setSetting("btnGPIO", 1, 0);
  270. setSetting("btnGPIO", 2, 9);
  271. setSetting("btnGPIO", 3, 10);
  272. setSetting("btnGPIO", 4, 14);
  273. setSetting("btnRelay", 1, 1);
  274. setSetting("btnRelay", 2, 2);
  275. setSetting("btnRelay", 3, 3);
  276. setSetting("btnRelay", 4, 4);
  277. setSetting("relayGPIO", 1, 12);
  278. setSetting("relayGPIO", 2, 5);
  279. setSetting("relayGPIO", 3, 4);
  280. setSetting("relayGPIO", 4, 15);
  281. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  282. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  283. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  284. setSetting("relayType", 4, RELAY_TYPE_NORMAL);
  285. #elif defined(ITEAD_SONOFF_B1)
  286. setSetting("board", 28);
  287. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  288. setSetting("lightProvider", LIGHT_PROVIDER_MY9192);
  289. setSetting("myDIGPIO", 12);
  290. setSetting("myDCKIGPIO", 14);
  291. setSetting("relays", 1);
  292. #elif defined(ITEAD_SONOFF_LED)
  293. setSetting("board", 29);
  294. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  295. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  296. setSetting("ledGPIO", 1, 13);
  297. setSetting("ledLogic", 1, 1);
  298. setSetting("chGPIO", 1, 12);
  299. setSetting("chLogic", 1, 0);
  300. setSetting("chGPIO", 2, 14);
  301. setSetting("chLogic", 2, 0);
  302. setSetting("relays", 1);
  303. #elif defined(ITEAD_SONOFF_T1_1CH)
  304. setSetting("board", 30);
  305. setSetting("ledGPIO", 1, 13);
  306. setSetting("ledLogic", 1, 1);
  307. setSetting("btnGPIO", 1, 9);
  308. setSetting("btnRelay", 1, 1);
  309. setSetting("relayGPIO", 1, 5);
  310. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  311. #elif defined(ITEAD_SONOFF_T1_2CH)
  312. setSetting("board", 31);
  313. setSetting("ledGPIO", 1, 13);
  314. setSetting("ledLogic", 1, 1);
  315. setSetting("btnGPIO", 1, 0);
  316. setSetting("btnGPIO", 2, 10);
  317. setSetting("btnRelay", 1, 1);
  318. setSetting("btnRelay", 2, 2);
  319. setSetting("relayGPIO", 1, 12);
  320. setSetting("relayGPIO", 2, 4);
  321. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  322. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  323. #elif defined(ITEAD_SONOFF_T1_3CH)
  324. setSetting("board", 32);
  325. setSetting("ledGPIO", 1, 13);
  326. setSetting("ledLogic", 1, 1);
  327. setSetting("btnGPIO", 1, 0);
  328. setSetting("btnGPIO", 2, 9);
  329. setSetting("btnGPIO", 3, 10);
  330. setSetting("btnRelay", 1, 1);
  331. setSetting("btnRelay", 2, 2);
  332. setSetting("btnRelay", 3, 3);
  333. setSetting("relayGPIO", 1, 12);
  334. setSetting("relayGPIO", 2, 5);
  335. setSetting("relayGPIO", 3, 4);
  336. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  337. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  338. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  339. #elif defined(ITEAD_SONOFF_RF)
  340. setSetting("board", 33);
  341. setSetting("ledGPIO", 1, 13);
  342. setSetting("ledLogic", 1, 1);
  343. setSetting("btnGPIO", 1, 0);
  344. setSetting("btnRelay", 1, 1);
  345. setSetting("relayGPIO", 1, 12);
  346. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  347. #elif defined(WION_50055)
  348. setSetting("board", 34);
  349. setSetting("ledGPIO", 1, 2);
  350. setSetting("ledLogic", 1, 0);
  351. setSetting("btnGPIO", 1, 13);
  352. setSetting("btnRelay", 1,1);
  353. setSetting("relayGPIO", 1, 15);
  354. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  355. #elif defined(EXS_WIFI_RELAY_V31)
  356. setSetting("board", 35);
  357. setSetting("btnGPIO", 1, 0);
  358. setSetting("btnRelay", 1, 1);
  359. setSetting("relayGPIO", 1, 13);
  360. setSetting("relayResetGPIO", 1, 12);
  361. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  362. #elif defined(HUACANXING_H802)
  363. setSetting("board", 36);
  364. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  365. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  366. setSetting("chGPIO", 1, 12);
  367. setSetting("chGPIO", 2, 14);
  368. setSetting("chGPIO", 3, 13);
  369. setSetting("chGPIO", 4, 15);
  370. setSetting("chLogic", 1, 0);
  371. setSetting("chLogic", 2, 0);
  372. setSetting("chLogic", 3, 0);
  373. setSetting("chLogic", 4, 0);
  374. setSetting("relays", 1);
  375. #elif defined(GENERIC_V9261F)
  376. setSetting("board", 37);
  377. #elif defined(GENERIC_ECH1560)
  378. setSetting("board", 38);
  379. #elif defined(TINKERMAN_ESPURNA_H07)
  380. setSetting("board", 39);
  381. setSetting("ledGPIO", 1, 2);
  382. setSetting("ledLogic", 1, 0);
  383. setSetting("btnGPIO", 1, 4);
  384. setSetting("btnRelay", 1, 1);
  385. setSetting("relayGPIO", 1, 12);
  386. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  387. setSetting("selGPIO", 5);
  388. setSetting("cf1GPIO", 13);
  389. setSetting("cfGPIO", 14);
  390. #elif defined(MANCAVEMADE_ESPLIVE)
  391. setSetting("board", 40);
  392. setSetting("btnGPIO", 1, 4);
  393. setSetting("btnGPIO", 2, 5);
  394. setSetting("btnRelay", 1, 1);
  395. setSetting("btnRelay", 2, 2);
  396. setSetting("relayGPIO", 1, 12);
  397. setSetting("relayGPIO", 2, 13);
  398. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  399. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  400. #elif defined(INTERMITTECH_QUINLED)
  401. setSetting("board", 41);
  402. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  403. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  404. setSetting("ledGPIO", 1, 1);
  405. setSetting("ledLogic", 1, 1);
  406. setSetting("chGPIO", 1, 0);
  407. setSetting("chGPIO", 2, 2);
  408. setSetting("chLogic", 1, 0);
  409. setSetting("chLogic", 2, 0);
  410. setSetting("relays", 1);
  411. #elif defined(MAGICHOME_LED_CONTROLLER_20)
  412. setSetting("board", 42);
  413. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  414. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  415. setSetting("chGPIO", 1, 5);
  416. setSetting("chGPIO", 2, 12);
  417. setSetting("chGPIO", 3, 13);
  418. setSetting("chGPIO", 4, 15);
  419. setSetting("chLogic", 1, 0);
  420. setSetting("chLogic", 2, 0);
  421. setSetting("chLogic", 3, 0);
  422. setSetting("chLogic", 4, 0);
  423. setSetting("relays", 1);
  424. #elif defined(ARILUX_AL_LC06)
  425. setSetting("board", 43);
  426. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  427. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  428. setSetting("chGPIO", 1, 12);
  429. setSetting("chGPIO", 2, 14);
  430. setSetting("chGPIO", 3, 13);
  431. setSetting("chGPIO", 4, 15);
  432. setSetting("chGPIO", 5, 5);
  433. setSetting("chLogic", 1, 0);
  434. setSetting("chLogic", 2, 0);
  435. setSetting("chLogic", 3, 0);
  436. setSetting("chLogic", 4, 0);
  437. setSetting("chLogic", 5, 0);
  438. setSetting("relays", 1);
  439. #elif defined(SM_PW702U)
  440. setSetting("board", 39);
  441. setSetting("ledGPIO", 1, 4);
  442. setSetting("ledLogic", 1, 0);
  443. setSetting("btnGPIO", 1, 13);
  444. setSetting("btnRelay", 1, 1);
  445. setSetting("relayGPIO", 1, 12);
  446. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  447. #else
  448. #error "UNSUPPORTED HARDWARE!"
  449. #endif
  450. saveSettings();
  451. }