From 326a7290112dc987e4c406a7c65a51458ef0f7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 28 Jun 2018 01:03:13 +0200 Subject: [PATCH] Move common Sonoff configuration --- code/espurna/migrate.ino | 203 ++++++++------------------------------- 1 file changed, 40 insertions(+), 163 deletions(-) diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index 99a73fad..99bdeff5 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -63,6 +63,42 @@ void migrate() { _migrateMoveIndexDown("rlyType"); } + // ------------------------------------------------------------------------- + // Board definitions + // ------------------------------------------------------------------------- + + #if defined(ITEAD_SONOFF_BASIC) || \ + defined(ITEAD_SONOFF_TH) || \ + defined(ITEAD_SONOFF_SV) || \ + defined(ITEAD_SONOFF_TOUCH) || \ + defined(ITEAD_1CH_INCHING) || \ + defined(ITEAD_SONOFF_4CH) || \ + defined(ITEAD_SLAMPHER) || \ + defined(ITEAD_S20) || \ + defined(ITEAD_MOTOR) || \ + defined(ITEAD_SONOFF_4CH_PRO) || \ + defined(ITEAD_SONOFF_T1_1CH) || \ + defined(ITEAD_SONOFF_T1_2CH) || \ + defined(ITEAD_SONOFF_T1_3CH) || \ + defined(ITEAD_SONOFF_RF) || \ + defined(ITEAD_SONOFF_DUAL_R2) || \ + defined(ITEAD_SONOFF_POW_R2) || \ + defined(ITEAD_SONOFF_S31) + + setSetting("btnGPIO", 0, 0); + setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); + setSetting("btnRelay", 0, 0); + + setSetting("ledGPIO", 0, 13); + setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); + + setSetting("rlyGPIO", 0, 12); + setSetting("rlyType", 0, RELAY_TYPE_NORMAL); + + #endif + + // ------------------------------------------------------------------------- + #if defined(NODEMCU_LOLIN) setSetting("board", 2); @@ -95,63 +131,25 @@ void migrate() { setSetting("board", 4); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); #elif defined(ITEAD_SONOFF_TH) setSetting("board", 5); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(ITEAD_SONOFF_SV) setSetting("board", 6); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(ITEAD_SONOFF_TOUCH) setSetting("board", 7); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); setSetting("btnClick", 0, BUTTON_MODE_NONE); setSetting("btnDblClick", 0, BUTTON_MODE_NONE); setSetting("btnLngClick", 0, BUTTON_MODE_NONE); setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET); - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(ITEAD_SONOFF_POW) setSetting("board", 8); @@ -201,41 +199,23 @@ void migrate() { setSetting("board", 10); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(ITEAD_SONOFF_4CH) setSetting("board", 11); - setSetting("btnGPIO", 0, 0); setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 2, 10); setSetting("btnGPIO", 3, 14); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); setSetting("btnRelay", 1, 1); setSetting("btnRelay", 2, 2); setSetting("btnRelay", 3, 3); - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); setSetting("rlyGPIO", 1, 5); setSetting("rlyGPIO", 2, 4); setSetting("rlyGPIO", 3, 15); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 2, RELAY_TYPE_NORMAL); setSetting("rlyType", 3, RELAY_TYPE_NORMAL); @@ -244,30 +224,10 @@ void migrate() { setSetting("board", 12); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(ITEAD_S20) setSetting("board", 13); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(ELECTRODRAGON_WIFI_IOT) setSetting("board", 14); @@ -406,16 +366,6 @@ void migrate() { setSetting("board", 22); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(TINKERMAN_ESPURNA_H06) setSetting("board", 23); @@ -501,15 +451,12 @@ void migrate() { setSetting("board", 27); - setSetting("btnGPIO", 0, 0); setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 2, 10); setSetting("btnGPIO", 3, 14); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); setSetting("btnRelay", 1, 1); setSetting("btnRelay", 2, 2); setSetting("btnRelay", 3, 3); @@ -545,14 +492,9 @@ void migrate() { setSetting("btnPress", 3, BUTTON_MODE_TOGGLE); setSetting("btnClick", 3, BUTTON_MODE_NONE); - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); setSetting("rlyGPIO", 1, 5); setSetting("rlyGPIO", 2, 4); setSetting("rlyGPIO", 3, 15); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 2, RELAY_TYPE_NORMAL); setSetting("rlyType", 3, RELAY_TYPE_NORMAL); @@ -594,30 +536,18 @@ void migrate() { setSetting("board", 30); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); setSetting("btnClick", 0, BUTTON_MODE_NONE); setSetting("btnDblClick", 0, BUTTON_MODE_NONE); setSetting("btnLngClick", 0, BUTTON_MODE_NONE); setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET); - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(ITEAD_SONOFF_T1_2CH) setSetting("board", 31); - setSetting("btnGPIO", 0, 0); setSetting("btnGPIO", 1, 9); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); setSetting("btnRelay", 1, 1); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); setSetting("btnPress", 1, BUTTON_MODE_TOGGLE); @@ -630,25 +560,17 @@ void migrate() { setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET); setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET); - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); setSetting("rlyGPIO", 1, 5); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL); #elif defined(ITEAD_SONOFF_T1_3CH) setSetting("board", 32); - setSetting("btnGPIO", 0, 0); setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 2, 10); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); setSetting("btnRelay", 1, 1); setSetting("btnRelay", 2, 2); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); @@ -667,13 +589,8 @@ void migrate() { setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET); setSetting("btnLngLngClick", 2, BUTTON_MODE_RESET); - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); setSetting("rlyGPIO", 1, 5); setSetting("rlyGPIO", 2, 4); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 2, RELAY_TYPE_NORMAL); @@ -681,16 +598,6 @@ void migrate() { setSetting("board", 33); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - #elif defined(WION_50055) // WiOn 50055 Indoor Wi-Fi Wall Outlet & Tap @@ -939,22 +846,14 @@ void migrate() { setSetting("board", 48); - setSetting("btnGPIO", 0, 0); setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 2, 10); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP); - setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP); + setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); setSetting("btnRelay", 1, 1); setSetting("btnRelay", 2, 0); - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); setSetting("rlyGPIO", 1, 5); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL); #elif defined(GENERIC_8CH) @@ -1056,8 +955,6 @@ void migrate() { setSetting("board", 54); - setSetting("anaEnabled", 1); - setSetting("btnGPIO", 0, 4); setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); @@ -1072,6 +969,8 @@ void migrate() { setSetting("rlyProvider", RELAY_PROVIDER_LIGHT); setSetting("rlyCount", 1); + setSetting("anaEnabled", 1); + setSetting("litProvider", LIGHT_PROVIDER_DIMMER); setSetting("litChGPIO", 0, 15); setSetting("litChGPIO", 1, 12); @@ -1378,16 +1277,6 @@ void migrate() { setSetting("board", 71); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - setSetting("cseEnabled", 1); setSetting("cseGPIO", 1); @@ -1628,16 +1517,6 @@ void migrate() { setSetting("board", 81); - setSetting("btnGPIO", 0, 0); - setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); - setSetting("btnRelay", 0, 0); - - setSetting("ledGPIO", 0, 13); - setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE); - - setSetting("rlyGPIO", 0, 12); - setSetting("rlyType", 0, RELAY_TYPE_NORMAL); - setSetting("cseEnabled", 1); setSetting("cseGPIO", 1); @@ -1686,7 +1565,7 @@ void migrate() { #elif defined(GENERIC_GEIGER_COUNTER) setSetting("board", 83); - + setSetting("geiEnabled", 1); #else @@ -1696,6 +1575,4 @@ void migrate() { #endif - saveSettings(); - }