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.

470 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(MAGICHOME_LED_CONTROLLER_IR)
  197. setSetting("board", 21);
  198. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  199. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  200. setSetting("ledGPIO", 1, 2);
  201. setSetting("ledLogic", 1, 1);
  202. setSetting("chGPIO", 1, 5);
  203. setSetting("chGPIO", 2, 12);
  204. setSetting("chGPIO", 3, 13);
  205. setSetting("chGPIO", 4, 14);
  206. setSetting("chLogic", 1, 0);
  207. setSetting("chLogic", 2, 0);
  208. setSetting("chLogic", 3, 0);
  209. setSetting("chLogic", 4, 0);
  210. setSetting("relays", 1);
  211. #elif defined(ITEAD_MOTOR)
  212. setSetting("board", 22);
  213. setSetting("ledGPIO", 1, 13);
  214. setSetting("ledLogic", 1, 1);
  215. setSetting("btnGPIO", 1, 0);
  216. setSetting("btnRelay", 1, 1);
  217. setSetting("relayGPIO", 1, 12);
  218. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  219. #elif defined(TINKERMAN_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("relayType", 1, RELAY_TYPE_INVERSE);
  227. setSetting("selGPIO", 2);
  228. setSetting("cf1GPIO", 13);
  229. setSetting("cfGPIO", 14);
  230. #elif defined(HUACANXING_H801)
  231. setSetting("board", 24);
  232. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  233. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  234. setSetting("ledGPIO", 1, 5);
  235. setSetting("ledLogic", 1, 1);
  236. setSetting("chGPIO", 1, 15);
  237. setSetting("chGPIO", 2, 13);
  238. setSetting("chGPIO", 3, 12);
  239. setSetting("chGPIO", 4, 14);
  240. setSetting("chGPIO", 5, 4);
  241. setSetting("chLogic", 1, 0);
  242. setSetting("chLogic", 2, 0);
  243. setSetting("chLogic", 3, 0);
  244. setSetting("chLogic", 4, 0);
  245. setSetting("chLogic", 5, 0);
  246. setSetting("relays", 1);
  247. #elif defined(ITEAD_BNSZ01)
  248. setSetting("board", 25);
  249. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  250. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  251. setSetting("ledGPIO", 3, 13);
  252. setSetting("ledLogic", 1, 1);
  253. setSetting("chGPIO", 1, 12);
  254. setSetting("chLogic", 1, 0);
  255. setSetting("relays", 1);
  256. #elif defined(ITEAD_SONOFF_RFBRIDGE)
  257. setSetting("board", 26);
  258. setSetting("ledGPIO", 1, 13);
  259. setSetting("ledLogic", 1, 1);
  260. setSetting("btnGPIO", 1, 0);
  261. setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE);
  262. setSetting("relays", 6);
  263. #elif defined(ITEAD_SONOFF_4CH_PRO)
  264. setSetting("board", 27);
  265. setSetting("ledGPIO", 1, 13);
  266. setSetting("ledLogic", 1, 1);
  267. setSetting("btnGPIO", 1, 0);
  268. setSetting("btnGPIO", 2, 9);
  269. setSetting("btnGPIO", 3, 10);
  270. setSetting("btnGPIO", 4, 14);
  271. setSetting("btnRelay", 1, 1);
  272. setSetting("btnRelay", 2, 2);
  273. setSetting("btnRelay", 3, 3);
  274. setSetting("btnRelay", 4, 4);
  275. setSetting("relayGPIO", 1, 12);
  276. setSetting("relayGPIO", 2, 5);
  277. setSetting("relayGPIO", 3, 4);
  278. setSetting("relayGPIO", 4, 15);
  279. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  280. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  281. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  282. setSetting("relayType", 4, RELAY_TYPE_NORMAL);
  283. #elif defined(ITEAD_SONOFF_B1)
  284. setSetting("board", 28);
  285. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  286. setSetting("lightProvider", LIGHT_PROVIDER_MY9192);
  287. setSetting("myDIGPIO", 12);
  288. setSetting("myDCKIGPIO", 14);
  289. setSetting("relays", 1);
  290. #elif defined(ITEAD_SONOFF_LED)
  291. setSetting("board", 29);
  292. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  293. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  294. setSetting("ledGPIO", 1, 13);
  295. setSetting("ledLogic", 1, 1);
  296. setSetting("chGPIO", 1, 12);
  297. setSetting("chLogic", 1, 0);
  298. setSetting("chGPIO", 2, 14);
  299. setSetting("chLogic", 2, 0);
  300. setSetting("relays", 1);
  301. #elif defined(ITEAD_SONOFF_T1_1CH)
  302. setSetting("board", 30);
  303. setSetting("ledGPIO", 1, 13);
  304. setSetting("ledLogic", 1, 1);
  305. setSetting("btnGPIO", 1, 9);
  306. setSetting("btnRelay", 1, 1);
  307. setSetting("relayGPIO", 1, 5);
  308. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  309. #elif defined(ITEAD_SONOFF_T1_2CH)
  310. setSetting("board", 31);
  311. setSetting("ledGPIO", 1, 13);
  312. setSetting("ledLogic", 1, 1);
  313. setSetting("btnGPIO", 1, 0);
  314. setSetting("btnGPIO", 2, 10);
  315. setSetting("btnRelay", 1, 1);
  316. setSetting("btnRelay", 2, 2);
  317. setSetting("relayGPIO", 1, 12);
  318. setSetting("relayGPIO", 2, 4);
  319. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  320. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  321. #elif defined(ITEAD_SONOFF_T1_3CH)
  322. setSetting("board", 32);
  323. setSetting("ledGPIO", 1, 13);
  324. setSetting("ledLogic", 1, 1);
  325. setSetting("btnGPIO", 1, 0);
  326. setSetting("btnGPIO", 2, 9);
  327. setSetting("btnGPIO", 3, 10);
  328. setSetting("btnRelay", 1, 1);
  329. setSetting("btnRelay", 2, 2);
  330. setSetting("btnRelay", 3, 3);
  331. setSetting("relayGPIO", 1, 12);
  332. setSetting("relayGPIO", 2, 5);
  333. setSetting("relayGPIO", 3, 4);
  334. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  335. setSetting("relayType", 2, RELAY_TYPE_NORMAL);
  336. setSetting("relayType", 3, RELAY_TYPE_NORMAL);
  337. #elif defined(ITEAD_SONOFF_RF)
  338. setSetting("board", 33);
  339. setSetting("ledGPIO", 1, 13);
  340. setSetting("ledLogic", 1, 1);
  341. setSetting("btnGPIO", 1, 0);
  342. setSetting("btnRelay", 1, 1);
  343. setSetting("relayGPIO", 1, 12);
  344. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  345. #elif defined(WION_50055)
  346. setSetting("board", 34);
  347. setSetting("ledGPIO", 1, 2);
  348. setSetting("ledLogic", 1, 0);
  349. setSetting("btnGPIO", 1, 13);
  350. setSetting("btnRelay", 1,1);
  351. setSetting("relayGPIO", 1, 15);
  352. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  353. #elif defined(EXS_WIFI_RELAY_V31)
  354. setSetting("board", 35);
  355. setSetting("btnGPIO", 1, 0);
  356. setSetting("btnRelay", 1, 1);
  357. setSetting("relayGPIO", 1, 13);
  358. setSetting("relayResetGPIO", 1, 12);
  359. setSetting("relayType", 1, RELAY_TYPE_NORMAL);
  360. #elif defined(HUACANXING_H802)
  361. setSetting("board", 36);
  362. setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
  363. setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
  364. setSetting("chGPIO", 1, 12);
  365. setSetting("chGPIO", 2, 14);
  366. setSetting("chGPIO", 3, 13);
  367. setSetting("chGPIO", 4, 15);
  368. setSetting("chLogic", 1, 0);
  369. setSetting("chLogic", 2, 0);
  370. setSetting("chLogic", 3, 0);
  371. setSetting("chLogic", 4, 0);
  372. setSetting("relays", 1);
  373. #elif defined(GENERIC_V9261F)
  374. setSetting("board", 37);
  375. #elif defined(GENERIC_ECH1560)
  376. setSetting("board", 38);
  377. #else
  378. #error "UNSUPPORTED HARDWARE!"
  379. #endif
  380. saveSettings();
  381. }