Merge branch 'development' of https://github.com/arendst/Sonoff-Tasmota into development

This commit is contained in:
Joel Stein 2018-11-10 16:39:38 +01:00
commit 3c935d2419
5 changed files with 54 additions and 37 deletions

View File

@ -1,6 +1,10 @@
/* 6.3.0.5 20181107
/* 6.3.0.6 20181110
* Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40%
*
* 6.3.0.5 20181107
* Add code image and optional commit number to version
* Add support for Gosund SP1 v2.3 Power Socket with Energy Monitoring (#4297)
* Fix shelly2 ghost switching caused by lack of pull-up inputs (#4255)
*
* 6.3.0.4 20181106
* Add command SetSensorXX 0/1 to disable/re-enable compiled xsns_XX_sensor.ino driver

View File

@ -2383,8 +2383,9 @@ void SerialInput()
void GpioSwitchPinMode(uint8_t index)
{
if (pin[GPIO_SWT1 +index] < 99) {
// pinMode(pin[GPIO_SWT1 +index], (16 == pin[GPIO_SWT1 +index]) ? INPUT_PULLDOWN_16 : bitRead(switch_no_pullup, index) ? INPUT : INPUT_PULLUP);
pinMode(pin[GPIO_SWT1 +index], (16 == pin[GPIO_SWT1 +index]) ? INPUT_PULLDOWN_16 : bitRead(switch_no_pullup, index) ? INPUT : INPUT_PULLUP);
/*
// Re-enable pull-up on Shelly2 as of 20181110 (#4255)
uint8_t no_pullup = bitRead(switch_no_pullup, index); // 0 = INPUT_PULLUP, 1 = INPUT
if (no_pullup) {
if (SHELLY2 == Settings.module) {
@ -2393,6 +2394,7 @@ void GpioSwitchPinMode(uint8_t index)
}
}
pinMode(pin[GPIO_SWT1 +index], (16 == pin[GPIO_SWT1 +index]) ? INPUT_PULLDOWN_16 : (no_pullup) ? INPUT : INPUT_PULLUP);
*/
}
}

View File

@ -1125,9 +1125,9 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_REL1, // GPIO04
GPIO_REL2, // GPIO05
0, 0, 0, 0, 0, 0, // Flash connection
GPIO_SWT1_NP, // GPIO12
GPIO_SWT1, // GPIO12
0,
GPIO_SWT2_NP, // GPIO14
GPIO_SWT2, // GPIO14
0, // GPIO15 MCP39F501 Reset
0, 0
},

View File

@ -20,7 +20,7 @@
#ifndef _SONOFF_VERSION_H_
#define _SONOFF_VERSION_H_
#define VERSION 0x06030005
#define VERSION 0x06030006
#define D_PROGRAMNAME "Sonoff-Tasmota"
#define D_AUTHOR "Theo Arends"

View File

@ -84,7 +84,7 @@ const char HTTP_HEAD[] PROGMEM =
"function lc(p){"
"la('?t='+p);" // ?t related to WebGetArg("t", tmp, sizeof(tmp));
"}";
const char HTTP_HEAD_RELOAD[] PROGMEM =
"setTimeout(function(){location.href='.';},4000);";
@ -160,17 +160,28 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM =
"</script>";
const char HTTP_SCRIPT_MODULE1[] PROGMEM =
"var os;"
"function sk(s,g){"
"function sk(s,g){" // s = value, g = id and name
"var o=os.replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");"
"eb('g'+g).innerHTML=o;"
"}"
"function sl(){"
"var o0=\"";
"if(x!=null){x.abort();}" // Abort any request pending
"x=new XMLHttpRequest();"
"x.onreadystatechange=function(){"
"if(x.readyState==4&&x.status==200){"
"var i,o=x.responseText.replace(/}1/g,\"<option value=\").replace(/}2/g,\"</option>\");"
"i=o.indexOf(\"}3\");" // String separator means do not use "}3" in Module name and Sensor name
"os=o.substring(0,i);"
"sk(17,99);"
"os=o.substring(i+2);"; // +2 is length "}3"
const char HTTP_SCRIPT_MODULE2[] PROGMEM =
"}1'%d'>%02d %s}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name
"}"
"};"
"x.open('GET','md?m=1',true);" // ?m related to WebServer->hasArg("m")
"x.send();"
"}";
const char HTTP_SCRIPT_MODULE3[] PROGMEM =
"\";"
"os=o0.replace(/}1/g,\"<option value=\").replace(/}2/g,\"</option>\");";
"}1'%d'>%02d %s}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name
const char HTTP_SCRIPT_INFO_BEGIN[] PROGMEM =
"function i(){"
"var s,o=\"";
@ -749,8 +760,6 @@ void HandleModuleConfiguration()
if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MODULE);
if (WebServer->hasArg("save")) {
ModuleSaveSettings();
WebRestart(1);
@ -759,39 +768,41 @@ void HandleModuleConfiguration()
char stemp[20];
uint8_t midx;
mytmplt cmodule;
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
if (WebServer->hasArg("m")) {
String page = "";
for (byte i = 0; i < MAXMODULE; i++) {
midx = pgm_read_byte(kModuleNiceList + i);
snprintf_P(stemp, sizeof(stemp), kModules[midx].name);
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, midx +1, stemp);
page += mqtt_data;
}
page += "}3"; // String separator means do not use "}3" in Module name and Sensor name
for (byte j = 0; j < sizeof(kGpioNiceList); j++) {
midx = pgm_read_byte(kGpioNiceList + j);
if (!GetUsedInModule(midx, cmodule.gp.io)) {
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames));
page += mqtt_data;
}
}
WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), page);
return;
}
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MODULE);
String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR(S_CONFIGURE_MODULE));
page += FPSTR(HTTP_SCRIPT_MODULE1);
for (byte i = 0; i < MAXMODULE; i++) {
midx = pgm_read_byte(kModuleNiceList + i);
snprintf_P(stemp, sizeof(stemp), kModules[midx].name);
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE2, midx, midx +1, stemp);
page += mqtt_data;
}
page += FPSTR(HTTP_SCRIPT_MODULE3);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,99);o0=\""), Settings.module); // g99
page += mqtt_data;
mytmplt cmodule;
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
for (byte j = 0; j < sizeof(kGpioNiceList); j++) {
midx = pgm_read_byte(kGpioNiceList + j);
if (!GetUsedInModule(midx, cmodule.gp.io)) {
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE2, midx, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames));
page += mqtt_data;
}
}
page += FPSTR(HTTP_SCRIPT_MODULE3);
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,%d);"), my_module.gp.io[i], i); // g0 - g16
page += mqtt_data;
}
}
page += F("}");
page += FPSTR(HTTP_SCRIPT_MODULE2);
page += FPSTR(HTTP_HEAD_STYLE);
page.replace(F("<body>"), F("<body onload='sl()'>"));
page += FPSTR(HTTP_FORM_MODULE);