Browse Source

Move common Sonoff configuration

v2
Xose Pérez 6 years ago
parent
commit
326a729011
1 changed files with 40 additions and 163 deletions
  1. +40
    -163
      code/espurna/migrate.ino

+ 40
- 163
code/espurna/migrate.ino View File

@ -63,6 +63,42 @@ void migrate() {
_migrateMoveIndexDown("rlyType"); _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) #if defined(NODEMCU_LOLIN)
setSetting("board", 2); setSetting("board", 2);
@ -95,63 +131,25 @@ void migrate() {
setSetting("board", 4); 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) #elif defined(ITEAD_SONOFF_TH)
setSetting("board", 5); 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) #elif defined(ITEAD_SONOFF_SV)
setSetting("board", 6); 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) #elif defined(ITEAD_SONOFF_TOUCH)
setSetting("board", 7); 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("btnPress", 0, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 0, BUTTON_MODE_NONE); setSetting("btnClick", 0, BUTTON_MODE_NONE);
setSetting("btnDblClick", 0, BUTTON_MODE_NONE); setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngClick", 0, BUTTON_MODE_NONE); setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET); 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) #elif defined(ITEAD_SONOFF_POW)
setSetting("board", 8); setSetting("board", 8);
@ -201,41 +199,23 @@ void migrate() {
setSetting("board", 10); 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) #elif defined(ITEAD_SONOFF_4CH)
setSetting("board", 11); setSetting("board", 11);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10); setSetting("btnGPIO", 2, 10);
setSetting("btnGPIO", 3, 14); setSetting("btnGPIO", 3, 14);
setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2); setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 3); setSetting("btnRelay", 3, 3);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
setSetting("rlyGPIO", 0, 12);
setSetting("rlyGPIO", 1, 5); setSetting("rlyGPIO", 1, 5);
setSetting("rlyGPIO", 2, 4); setSetting("rlyGPIO", 2, 4);
setSetting("rlyGPIO", 3, 15); setSetting("rlyGPIO", 3, 15);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
setSetting("rlyType", 2, RELAY_TYPE_NORMAL); setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
setSetting("rlyType", 3, RELAY_TYPE_NORMAL); setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
@ -244,30 +224,10 @@ void migrate() {
setSetting("board", 12); 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) #elif defined(ITEAD_S20)
setSetting("board", 13); 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) #elif defined(ELECTRODRAGON_WIFI_IOT)
setSetting("board", 14); setSetting("board", 14);
@ -406,16 +366,6 @@ void migrate() {
setSetting("board", 22); 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) #elif defined(TINKERMAN_ESPURNA_H06)
setSetting("board", 23); setSetting("board", 23);
@ -501,15 +451,12 @@ void migrate() {
setSetting("board", 27); setSetting("board", 27);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10); setSetting("btnGPIO", 2, 10);
setSetting("btnGPIO", 3, 14); setSetting("btnGPIO", 3, 14);
setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 3, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2); setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 3); setSetting("btnRelay", 3, 3);
@ -545,14 +492,9 @@ void migrate() {
setSetting("btnPress", 3, BUTTON_MODE_TOGGLE); setSetting("btnPress", 3, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 3, BUTTON_MODE_NONE); 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", 1, 5);
setSetting("rlyGPIO", 2, 4); setSetting("rlyGPIO", 2, 4);
setSetting("rlyGPIO", 3, 15); setSetting("rlyGPIO", 3, 15);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
setSetting("rlyType", 2, RELAY_TYPE_NORMAL); setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
setSetting("rlyType", 3, RELAY_TYPE_NORMAL); setSetting("rlyType", 3, RELAY_TYPE_NORMAL);
@ -594,30 +536,18 @@ void migrate() {
setSetting("board", 30); 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("btnPress", 0, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 0, BUTTON_MODE_NONE); setSetting("btnClick", 0, BUTTON_MODE_NONE);
setSetting("btnDblClick", 0, BUTTON_MODE_NONE); setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngClick", 0, BUTTON_MODE_NONE); setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET); 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) #elif defined(ITEAD_SONOFF_T1_2CH)
setSetting("board", 31); setSetting("board", 31);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 1, 9);
setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
setSetting("btnPress", 1, BUTTON_MODE_TOGGLE); setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
@ -630,25 +560,17 @@ void migrate() {
setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET); setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
setSetting("btnLngLngClick", 1, 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("rlyGPIO", 1, 5);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_T1_3CH) #elif defined(ITEAD_SONOFF_T1_3CH)
setSetting("board", 32); setSetting("board", 32);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10); setSetting("btnGPIO", 2, 10);
setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2); setSetting("btnRelay", 2, 2);
setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
@ -667,13 +589,8 @@ void migrate() {
setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET); setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
setSetting("btnLngLngClick", 2, 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", 1, 5);
setSetting("rlyGPIO", 2, 4); setSetting("rlyGPIO", 2, 4);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
setSetting("rlyType", 2, RELAY_TYPE_NORMAL); setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
@ -681,16 +598,6 @@ void migrate() {
setSetting("board", 33); 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) #elif defined(WION_50055)
// WiOn 50055 Indoor Wi-Fi Wall Outlet & Tap // WiOn 50055 Indoor Wi-Fi Wall Outlet & Tap
@ -939,22 +846,14 @@ void migrate() {
setSetting("board", 48); setSetting("board", 48);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10); 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("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 0); setSetting("btnRelay", 2, 0);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, GPIO_LOGIC_INVERSE);
setSetting("rlyGPIO", 0, 12);
setSetting("rlyGPIO", 1, 5); setSetting("rlyGPIO", 1, 5);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
#elif defined(GENERIC_8CH) #elif defined(GENERIC_8CH)
@ -1056,8 +955,6 @@ void migrate() {
setSetting("board", 54); setSetting("board", 54);
setSetting("anaEnabled", 1);
setSetting("btnGPIO", 0, 4); setSetting("btnGPIO", 0, 4);
setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnPress", 0, BUTTON_MODE_TOGGLE); setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
@ -1072,6 +969,8 @@ void migrate() {
setSetting("rlyProvider", RELAY_PROVIDER_LIGHT); setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
setSetting("rlyCount", 1); setSetting("rlyCount", 1);
setSetting("anaEnabled", 1);
setSetting("litProvider", LIGHT_PROVIDER_DIMMER); setSetting("litProvider", LIGHT_PROVIDER_DIMMER);
setSetting("litChGPIO", 0, 15); setSetting("litChGPIO", 0, 15);
setSetting("litChGPIO", 1, 12); setSetting("litChGPIO", 1, 12);
@ -1378,16 +1277,6 @@ void migrate() {
setSetting("board", 71); 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("cseEnabled", 1);
setSetting("cseGPIO", 1); setSetting("cseGPIO", 1);
@ -1628,16 +1517,6 @@ void migrate() {
setSetting("board", 81); 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("cseEnabled", 1);
setSetting("cseGPIO", 1); setSetting("cseGPIO", 1);
@ -1686,7 +1565,7 @@ void migrate() {
#elif defined(GENERIC_GEIGER_COUNTER) #elif defined(GENERIC_GEIGER_COUNTER)
setSetting("board", 83); setSetting("board", 83);
setSetting("geiEnabled", 1); setSetting("geiEnabled", 1);
#else #else
@ -1696,6 +1575,4 @@ void migrate() {
#endif #endif
saveSettings();
} }

Loading…
Cancel
Save