Browse Source

Move configuration to hardware.ino

v2
Xose Pérez 6 years ago
parent
commit
c262066e7e
28 changed files with 1852 additions and 108 deletions
  1. +2
    -0
      code/devices/005_itead_sonoff_th.json
  2. +1
    -1
      code/devices/009_itead_sonoff_dual.json
  3. +1
    -1
      code/devices/020_aithinker_ai_light.json
  4. +1
    -1
      code/devices/021_magichome_led_controller.json
  5. +1
    -1
      code/devices/024_huacanxing_h801.json
  6. +1
    -1
      code/devices/025_itead_bnsz01.json
  7. +1
    -1
      code/devices/026_itead_sonoff_rfbridge.json
  8. +1
    -1
      code/devices/028_itead_sonoff_b1.json
  9. +1
    -1
      code/devices/029_itead_sonoff_led.json
  10. +1
    -1
      code/devices/036_huacanxing_h802.json
  11. +1
    -1
      code/devices/041_intermittech_quinled.json
  12. +1
    -1
      code/devices/042_magichome_led_controller_20.json
  13. +1
    -1
      code/devices/043_arilux_al_lc06.json
  14. +1
    -1
      code/devices/045_authometion_lyt8266.json
  15. +1
    -1
      code/devices/046_arilux_e27.json
  16. +1
    -1
      code/devices/050_arilux_al_lc01.json
  17. +1
    -1
      code/devices/051_arilux_al_lc11.json
  18. +1
    -1
      code/devices/052_arilux_al_lc02.json
  19. +1
    -1
      code/devices/054_gizwits_witty_cloud.json
  20. +1
    -1
      code/devices/082_stm_relay.json
  21. +1
    -1
      code/espurna/button.ino
  22. +0
    -4
      code/espurna/config/defaults.h
  23. +1
    -6
      code/espurna/espurna.ino
  24. +1822
    -0
      code/espurna/hardware.ino
  25. +1
    -1
      code/espurna/led.ino
  26. +0
    -60
      code/espurna/migrate.ino
  27. +6
    -5
      code/espurna/relay.ino
  28. +0
    -12
      code/espurna/utils.ino

+ 2
- 0
code/devices/005_itead_sonoff_th.json View File

@ -4,6 +4,8 @@
"btnMode0": 2,
"btnRelay0": 0,
"device": "ITEAD_SONOFF_TH",
"dhtGPIO0": 14,
"dsGPIO0": 14,
"ledGPIO0": 13,
"ledLogic0": 1,
"rlyGPIO0": 12,


+ 1
- 1
code/devices/009_itead_sonoff_dual.json View File

@ -6,6 +6,6 @@
"device": "ITEAD_SONOFF_DUAL",
"ledGPIO0": 13,
"ledLogic0": 1,
"rlyCount": 2,
"rlyDummy": 2,
"rlyProvider": 1
}

+ 1
- 1
code/devices/020_aithinker_ai_light.json View File

@ -7,6 +7,6 @@
"myDIGPIO": 13,
"myMapping": "0123",
"myModel": 0,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/021_magichome_led_controller.json View File

@ -15,6 +15,6 @@
"litChLogic2": 0,
"litChLogic3": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/024_huacanxing_h801.json View File

@ -16,6 +16,6 @@
"litChLogic3": 0,
"litChLogic4": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/025_itead_bnsz01.json View File

@ -6,6 +6,6 @@
"litChGPIO0": 12,
"litChLogic0": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/026_itead_sonoff_rfbridge.json View File

@ -10,6 +10,6 @@
"rfbDirect": 0,
"rfbRXGPIO": 4,
"rfbTXGPIO": 5,
"rlyCount": 8,
"rlyDummy": 8,
"rlyProvider": 3
}

+ 1
- 1
code/devices/028_itead_sonoff_b1.json View File

@ -9,6 +9,6 @@
"myDIGPIO": 12,
"myMapping": "43501",
"myModel": 1,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/029_itead_sonoff_led.json View File

@ -8,6 +8,6 @@
"litChLogic0": 0,
"litChLogic1": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/036_huacanxing_h802.json View File

@ -12,6 +12,6 @@
"litChLogic2": 0,
"litChLogic3": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/041_intermittech_quinled.json View File

@ -8,6 +8,6 @@
"litChLogic0": 0,
"litChLogic1": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/042_magichome_led_controller_20.json View File

@ -15,6 +15,6 @@
"litChLogic2": 0,
"litChLogic3": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/043_arilux_al_lc06.json View File

@ -12,6 +12,6 @@
"litChLogic3": 0,
"litChLogic4": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/045_authometion_lyt8266.json View File

@ -12,6 +12,6 @@
"litEnableGPIO": 15,
"litEnableLogic": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/046_arilux_e27.json View File

@ -7,6 +7,6 @@
"myDIGPIO": 13,
"myMapping": "0123",
"myModel": 0,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/050_arilux_al_lc01.json View File

@ -8,6 +8,6 @@
"litChLogic1": 0,
"litChLogic2": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/051_arilux_al_lc11.json View File

@ -12,6 +12,6 @@
"litChLogic3": 0,
"litChLogic4": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/052_arilux_al_lc02.json View File

@ -10,6 +10,6 @@
"litChLogic2": 0,
"litChLogic3": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/054_gizwits_witty_cloud.json View File

@ -18,6 +18,6 @@
"litChLogic1": 0,
"litChLogic2": 0,
"litProvider": 2,
"rlyCount": 1,
"rlyDummy": 1,
"rlyProvider": 2
}

+ 1
- 1
code/devices/082_stm_relay.json View File

@ -2,6 +2,6 @@
"board": 82,
"dbgSerial": 0,
"device": "STM_RELAY",
"rlyCount": 2,
"rlyDummy": 2,
"rlyProvider": 4
}

+ 1
- 1
code/espurna/button.ino View File

@ -185,7 +185,7 @@ void _buttonConfigure() {
#endif
DEBUG_MSG_P(PSTR("[BUTTON] Number of buttons: %u\n"), _buttons.size());
DEBUG_MSG_P(PSTR("[BUTTON] Buttons: %u\n"), _buttons.size());
}


+ 0
- 4
code/espurna/config/defaults.h View File

@ -212,10 +212,6 @@
// Relays
// -----------------------------------------------------------------------------
#ifndef DUMMY_RELAY_COUNT
#define DUMMY_RELAY_COUNT 0
#endif
#ifndef RELAY1_PIN
#define RELAY1_PIN GPIO_NONE
#endif


+ 1
- 6
code/espurna/espurna.ino View File

@ -59,8 +59,7 @@ void setup() {
settingsSetup();
// Load board data
loadBoard();
migrate();
hardwareSetup();
// Show welcome message and system configuration
info();
@ -169,15 +168,11 @@ void setup() {
uartmqttSetup();
#endif
// 3rd party code hook
#if USE_EXTRA
extraSetup();
#endif
// Prepare configuration for version 2.0
migrate();
saveSettings();
}


+ 1822
- 0
code/espurna/hardware.ino
File diff suppressed because it is too large
View File


+ 1
- 1
code/espurna/led.ino View File

@ -146,7 +146,7 @@ void _ledConfigure() {
}
DEBUG_MSG_P(PSTR("[LED] Number of leds: %d\n"), _leds.size());
DEBUG_MSG_P(PSTR("[LED] LEDs: %d\n"), _leds.size());
_led_update = true;


+ 0
- 60
code/espurna/migrate.ino View File

@ -1,60 +0,0 @@
/*
MIGRATE MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
*/
void _migrateMoveIndexDown(const char * key, int offset = 0) {
if (hasSetting(key, 0)) return;
for (unsigned char index = 1; index < SETTINGS_MAX_LIST_COUNT; index++) {
if (hasSetting(key, index)) {
setSetting(key, index - 1, getSetting(key, index).toInt() + offset);
} else {
delSetting(key, index - 1);
}
}
}
// Configuration versions
//
// 1: based on Embedis, no board definitions
// 2: based on Embedis, with board definitions 1-based
// 3: based on Embedis, with board definitions 0-based
// 4: based on Embedis, added sensors and force resetting
void migrate() {
moveSetting("boardName", "device");
moveSettings("relayGPIO", "rlyGPIO");
moveSettings("relayResetGPIO", "rlyResetGPIO");
moveSettings("relayType", "rlyType");
moveSetting("selGPIO", "hlwSELGPIO");
moveSetting("cfGPIO", "hlwCFGPIO");
moveSetting("cf1GPIO", "hlwCF1GPIO");
moveSetting("relayProvider", "rlyProvider");
moveSetting("lightProvider", "litProvider");
moveSetting("relays", "rlyCount");
moveSettings("chGPIO", "litChGPIO");
moveSettings("chLogic", "litChLogic");
moveSetting("enGPIO", "litEnableGPIO");
moveSetting("hlwSelC", "hlwCurLevel");
moveSetting("hlwIntM", "hlwInt");
delSetting("ledWifi");
// Get config version
unsigned int board = getSetting("board", 0).toInt();
unsigned int config_version = getSetting("cfg", board > 0 ? 2 : 1).toInt();
setSetting("cfg", CFG_VERSION);
if (config_version == 2) {
_migrateMoveIndexDown("ledGPIO");
_migrateMoveIndexDown("ledLogic");
_migrateMoveIndexDown("btnGPIO");
_migrateMoveIndexDown("btnRelay", -1);
_migrateMoveIndexDown("rlyGPIO");
_migrateMoveIndexDown("rlyType");
}
}

+ 6
- 5
code/espurna/relay.ino View File

@ -514,15 +514,16 @@ void _relayConfigure() {
// Dummy relays for AI Light, Magic Home LED Controller, H801,
// Sonoff Dual and Sonoff RF Bridge
#if DUMMY_RELAY_COUNT > 0
unsigned char dummy = getSetting("rlyDummy", 0).toInt();
if (dummy > 0) {
for (unsigned char index=0; index < DUMMY_RELAY_COUNT; index++) {
for (unsigned char index=0; index < dummy; index++) {
unsigned long delay_on = getSetting("rlyDelayOn", index, 0).toInt();
unsigned long delay_off = getSetting("rlyDelayOff", index, 0).toInt();
_relays.push_back((relay_t) {0, RELAY_TYPE_NORMAL, 0, delay_on, delay_off});
}
#else
} else {
unsigned char index = 0;
while (index < MAX_COMPONENTS) {
@ -547,9 +548,9 @@ void _relayConfigure() {
}
#endif
}
DEBUG_MSG_P(PSTR("[RELAY] Number of relays: %d\n"), _relays.size());
DEBUG_MSG_P(PSTR("[RELAY] Relays: %d\n"), _relays.size());
}


+ 0
- 12
code/espurna/utils.ino View File

@ -34,18 +34,6 @@ String getPassword() {
return getSetting("adminPass", ADMIN_PASS);
}
void loadBoard() {
#ifndef ESPURNA_CORE
char buffer[device_config_len+1];
strncpy_P(buffer, (const char *) device_config, device_config_len);
buffer[device_config_len] = 0;
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.parseObject(buffer);
json["app"] = APP_NAME;
settingsRestoreJson(json);
#endif
}
String getManufacturer() {
String device = getDevice();
uint8_t pos = device.indexOf("_");


Loading…
Cancel
Save