mirror of https://github.com/arendst/Tasmota.git
web gui rework
This commit is contained in:
parent
7adbb99423
commit
1f860deb02
|
@ -2,7 +2,7 @@
|
|||
// compressed by tools/unishox/compress-html-uncompressed.py
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
const size_t HTTP_SCRIPT_ROOT_SIZE = 779;
|
||||
const size_t HTTP_SCRIPT_ROOT_SIZE = 880;
|
||||
const char HTTP_SCRIPT_ROOT_COMPRESSED[] PROGMEM = "\x33\xBF\xAF\x98\xF0\xA3\xE1\xC8\x75\x11\x8A\x3C\x18\x17\xC1\xD6\xE7\x20\xAC\xEE"
|
||||
"\x8C\x3B\xC7\xB6\xCF\x83\x0F\xF1\xFE\x3E\xCF\xB3\xC0\x61\x3B\xF9\x56\x8D\x78\x2E"
|
||||
"\x8E\xE9\x8A\x3B\xC0\x93\x34\x2A\x2B\x3B\xC7\x8D\x30\x77\x4D\x87\xF0\xF9\xC2\xC2"
|
||||
|
@ -24,7 +24,9 @@ const char HTTP_SCRIPT_ROOT_COMPRESSED[] PROGMEM = "\x33\xBF\xAF\x98\xF0\xA3\xE1
|
|||
"\xDC\x40\x89\xCB\x2F\x99\x9D\x9D\xD1\x97\xF3\xAB\x4C\xEF\xE7\x78\xF6\x85\x67\x74"
|
||||
"\xFB\x3F\x5E\x33\x3E\x1F\x67\x6F\x4C\xEF\xE7\x6C\xFB\x3F\x67\xD9\xDB\x19\x7F\x3B"
|
||||
"\xC7\x80\x46\xC3\x74\x12\x30\xD0\x41\xE6\xE0\xF0\x0A\x78\xA7\xCC\x78\x51\xF0\xE3"
|
||||
"\x20\x46\xC6\xC6\x7C\xEE\x98\x3B\xC7\xB7\x4C\x1D\xD3\x07\x78\xF6\x82\x67\x0B\xA0"
|
||||
"\x99\xC3\xF8\x28\x70\xCA\x08\x5A\x79\xEE\x61\x79\x82\xF6\x40\x08\x7A\xF9\xEE";
|
||||
"\x20\x4A\xC6\xE8\x13\x71\xC1\x97\xF4\x7C\x43\x2F\xE7\x4F\x05\xA1\xB3\xBA\x71\x9D"
|
||||
"\x47\x72\x8E\xF1\xDC\x3B\x64\x08\xD3\x8E\x59\xDE\x20\x60\xBA\x08\xCF\x9D\xD3\x07"
|
||||
"\x78\xF6\xE9\x83\xBA\x60\xEF\x1E\xD0\x4C\xE3\x08\x13\x38\xE4\x05\x0E\x32\x81\x0B"
|
||||
"\x74\x3D\xCC\x2F\x30\x5E\xC8\x01\x0F\x5F\x3D\xC6";
|
||||
|
||||
#define HTTP_SCRIPT_ROOT Decompress(HTTP_SCRIPT_ROOT_COMPRESSED,HTTP_SCRIPT_ROOT_SIZE).c_str()
|
|
@ -71,6 +71,7 @@ keywords if then else endif, or, and are better readable for beginners (others m
|
|||
|
||||
uint32_t EncodeLightId(uint8_t relay_id);
|
||||
uint32_t DecodeLightId(uint32_t hue_id);
|
||||
char *web_send_line(char mc, char *lp);
|
||||
|
||||
#define SPECIAL_EEPMODE_SIZE 6200
|
||||
|
||||
|
@ -433,6 +434,7 @@ struct SCRIPT_MEM {
|
|||
char web_mode;
|
||||
char *glob_script = 0;
|
||||
char *fast_script = 0;
|
||||
char *event_script = 0;
|
||||
char *web_pages[5];
|
||||
uint32_t script_lastmillis;
|
||||
bool event_handeled = false;
|
||||
|
@ -4683,14 +4685,14 @@ void Replace_Cmd_Vars(char *srcbuf, uint32_t srcsize, char *dstbuf, uint32_t dst
|
|||
char string[SCRIPT_MAXSSIZE];
|
||||
dstsize -= 2;
|
||||
for (count = 0; count<dstsize; count++) {
|
||||
if (srcsize && (*cp==SCRIPT_EOL)) break;
|
||||
if (*cp=='%') {
|
||||
if (srcsize && (*cp == SCRIPT_EOL)) break;
|
||||
if (*cp == '%') {
|
||||
cp++;
|
||||
if (*cp=='%') {
|
||||
if (*cp == '%') {
|
||||
dstbuf[count] = *cp++;
|
||||
} else {
|
||||
if (isdigit(*cp)) {
|
||||
if (*(cp+1)=='.') {
|
||||
if (*(cp+1) == '.') {
|
||||
lzero = *cp & 0xf;
|
||||
cp+=2;
|
||||
}
|
||||
|
@ -4757,6 +4759,8 @@ void Replace_Cmd_Vars(char *srcbuf, uint32_t srcsize, char *dstbuf, uint32_t dst
|
|||
dstbuf[count] = '\r';
|
||||
} else if (*cp=='\\') {
|
||||
dstbuf[count] = '\\';
|
||||
} else if (*cp=='#') {
|
||||
dstbuf[count] = '#';
|
||||
} else {
|
||||
dstbuf[count] = *cp;
|
||||
}
|
||||
|
@ -5490,10 +5494,14 @@ int16_t Run_script_sub(const char *type, int8_t tlen, struct GVARS *gv) {
|
|||
else if (!strncmp(lp, "wcs", 3)) {
|
||||
lp+=4;
|
||||
// skip one space after cmd
|
||||
web_send_line(0, lp);
|
||||
/*
|
||||
char tmp[256];
|
||||
Replace_Cmd_Vars(lp ,1 , tmp, sizeof(tmp));
|
||||
WSContentFlush();
|
||||
WSContentSend_P(PSTR("%s"),tmp);
|
||||
*/
|
||||
|
||||
WSContentFlush();
|
||||
goto next_line;
|
||||
}
|
||||
|
@ -6383,6 +6391,7 @@ void SaveScriptEnd(void) {
|
|||
|
||||
//glob_script_mem.fast_script = Run_Scripter(">F", -2, 0);
|
||||
if (Run_Scripter(">F", -2, 0) == 99) {glob_script_mem.fast_script = glob_script_mem.section_ptr + 2;} else {glob_script_mem.fast_script = 0;}
|
||||
if (Run_Scripter(">E", -2, 0) == 99) {glob_script_mem.event_script = glob_script_mem.section_ptr + 2;} else {glob_script_mem.event_script = 0;}
|
||||
|
||||
script_set_web_pages();
|
||||
|
||||
|
@ -6875,7 +6884,8 @@ void Script_Handle_Hue(String *path) {
|
|||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str());
|
||||
WSSend(code, CT_APP_JSON, response);
|
||||
if (resp) {
|
||||
Run_Scripter(">E", 2, 0);
|
||||
//Run_Scripter(">E", 2, 0);
|
||||
if (glob_script_mem.event_script) Run_Scripter(glob_script_mem.event_script, 0, 0);
|
||||
}
|
||||
}
|
||||
#endif // hue interface
|
||||
|
@ -7621,6 +7631,13 @@ const char HTTP_SCRIPT_FULLPAGE2[] PROGMEM =
|
|||
"la('&sv='+ivar+'_'+par);"
|
||||
"rfsh=0;"
|
||||
"}"
|
||||
"function sivat(par,ivar){"
|
||||
"rfsh=1;"
|
||||
// remove : from time string
|
||||
"par = par.slice(0, 2) + par.slice(3);"
|
||||
"la('&sv='+ivar+'_'+par);"
|
||||
"rfsh=0;"
|
||||
"}"
|
||||
"function pr(f){"
|
||||
"if (f) {"
|
||||
"lt=setTimeout(la,%d);"
|
||||
|
@ -7670,15 +7687,13 @@ void ScriptFullWebpage(uint8_t page) {
|
|||
}
|
||||
|
||||
WSContentBegin(200, CT_HTML);
|
||||
const char *title = "Full Screen";
|
||||
WSContentSend_P(HTTP_HEADER1, PSTR(D_HTML_LANGUAGE), SettingsText(SET_DEVICENAME), title);
|
||||
WSContentSend_P(HTTP_HEADER1, PSTR(D_HTML_LANGUAGE), SettingsText(SET_DEVICENAME), PSTR("Full Screen"));
|
||||
WSContentSend_P(HTTP_SCRIPT_FULLPAGE1, page , fullpage_refresh);
|
||||
WSContentSend_P(HTTP_SCRIPT_FULLPAGE2, fullpage_refresh);
|
||||
//WSContentSend_P(PSTR("<div id='l1' name='l1'></div>"));
|
||||
|
||||
//WSContentSendStyle();
|
||||
|
||||
|
||||
WSContentSend_P(PSTR("<div id='l1' name='l1'>"));
|
||||
ScriptWebShow('w', page);
|
||||
WSContentSend_P(PSTR("</div>"));
|
||||
|
@ -7722,7 +7737,9 @@ void Script_Check_HTML_Setvars(void) {
|
|||
|
||||
//toLog(cmdbuf);
|
||||
execute_script(cmdbuf);
|
||||
Run_Scripter(">E", 2, 0);
|
||||
//Run_Scripter(">E", 2, 0);
|
||||
if (glob_script_mem.event_script) Run_Scripter(glob_script_mem.event_script, 0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7751,24 +7768,23 @@ const char SCRIPT_MSG_SLIDER[] PROGMEM =
|
|||
"<div><input type='range' min='%d' max='%d' value='%d' onchange='seva(value,\"%s\")'></div>";
|
||||
|
||||
const char SCRIPT_MSG_CHKBOX[] PROGMEM =
|
||||
"<div><center><label><b>%s</b><input type='checkbox' %s onchange='seva(%d,\"%s\")'></label></div>";
|
||||
"%s<label><b>%s</b><input type='checkbox' %s onchange='seva(%d,\"%s\")'></label>";
|
||||
|
||||
const char SCRIPT_MSG_PULLDOWNa[] PROGMEM =
|
||||
"<div><center><label for=\'pu_%s\'>%s:</label><select style='width:200px' name='pu%d' id='pu_%s' onchange='seva(value,\"%s\")'>";
|
||||
"%s<label for=\'pu_%s\'>%s</label><select style='width:%dpx' name='pu%d' id='pu_%s' onchange='seva(value,\"%s\")'>";
|
||||
const char SCRIPT_MSG_PULLDOWNb[] PROGMEM =
|
||||
"<option %s value='%d'>%s</option>";
|
||||
const char SCRIPT_MSG_PULLDOWNc[] PROGMEM =
|
||||
"</select></div>";
|
||||
"</select>";
|
||||
|
||||
const char SCRIPT_MSG_TEXTINP[] PROGMEM =
|
||||
"<div><center><label><b>%s</b><input type='text' value='%s' style='width:200px' onfocusin='pr(0)' onfocusout='pr(1)' onchange='siva(value,\"%s\")'></label></div>";
|
||||
"%s<label><b>%s</b><input type='text' value='%s' style='width:%dpx' onfocusin='pr(0)' onfocusout='pr(1)' onchange='siva(value,\"%s\")'></label>";
|
||||
|
||||
const char SCRIPT_MSG_TEXTINP_U[] PROGMEM =
|
||||
"<div><center><label><b>%s</b><input type='%s' value='%s' min='%s' max='%s' style='width:200px' onfocusin='pr(0)' onfocusout='pr(1)' onchange='siva(value,\"%s\")'></label></div>";
|
||||
|
||||
"%s<label><b>%s</b><input type='%s' value='%s' min='%s' max='%s' style='width:%dpx' onfocusin='pr(0)' onfocusout='pr(1)' onchange='%s(value,\"%s\")'></label>";
|
||||
|
||||
const char SCRIPT_MSG_NUMINP[] PROGMEM =
|
||||
"<div><center><label><b>%s</b><input min='%s' max='%s' step='%s' value='%s' type='number' style='width:200px' onfocusin='pr(0)' onfocusout='pr(1)' onchange='siva(value,\"%s\")'></label></div>";
|
||||
"%s<label><b>%s</b><input min='%s' max='%s' step='%s' value='%s' type='number' style='width:%dpx' onfocusin='pr(0)' onfocusout='pr(1)' onchange='siva(value,\"%s\")'></label>";
|
||||
|
||||
|
||||
#ifdef USE_GOOGLE_CHARTS
|
||||
|
@ -7907,6 +7923,32 @@ char *gc_send_labels(char *lp,uint32_t anum) {
|
|||
return lp;
|
||||
}
|
||||
|
||||
const char *GC_type(uint8_t type) {
|
||||
switch (type) {
|
||||
case 'l':
|
||||
return PSTR("LineChart");
|
||||
case 'b':
|
||||
return PSTR("BarChart");
|
||||
case 'p':
|
||||
return PSTR("PieChart");
|
||||
case 'g':
|
||||
return PSTR("Gauge");
|
||||
case 't':
|
||||
return PSTR("Table");
|
||||
case 'T':
|
||||
return PSTR("Timeline");
|
||||
case 'h':
|
||||
return PSTR("Histogram");
|
||||
case 'c':
|
||||
return PSTR("ColumnChart");
|
||||
case 'C':
|
||||
return PSTR("ComboChart");
|
||||
default:
|
||||
return PSTR("*");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // USE_GOOGLE_CHARTS
|
||||
|
||||
void ScriptGetVarname(char *nbuf,char *sp, uint32_t blen) {
|
||||
|
@ -7920,45 +7962,67 @@ uint32_t cnt;
|
|||
nbuf[cnt] = 0;
|
||||
}
|
||||
|
||||
void ScriptWebShow(char mc, uint8_t page) {
|
||||
uint8_t web_script;
|
||||
glob_script_mem.web_mode = mc;
|
||||
if (mc=='w' || mc=='x') {
|
||||
if (mc=='x') {
|
||||
mc='$';
|
||||
#define WSO_NOCENTER 1
|
||||
#define WSO_NODIV 2
|
||||
#define WSO_FORCEPLAIN 4
|
||||
#define WSO_STOP_DIV 0x80
|
||||
|
||||
void WCS_DIV(uint8_t flag) {
|
||||
if (flag & WSO_NODIV) return;
|
||||
if (flag & WSO_STOP_DIV) {
|
||||
WSContentSend_PD(SCRIPT_MSG_BUT_STOP);
|
||||
} else {
|
||||
WSContentSend_PD(SCRIPT_MSG_BUT_START);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t specopt;
|
||||
uint8_t chartindex;
|
||||
uint8_t google_libs;
|
||||
#ifdef USE_GOOGLE_CHARTS
|
||||
char gs_ctype;
|
||||
#endif
|
||||
|
||||
void ScriptWebShow(char mc, uint8_t page) {
|
||||
float cv_max = 0;
|
||||
float cv_inc = 0;
|
||||
float *cv_count = 0;
|
||||
char *cv_ptr;
|
||||
|
||||
//uint8_t web_script;
|
||||
glob_script_mem.web_mode = mc;
|
||||
if (mc == 'w' || mc == 'x') {
|
||||
if (mc == 'x') {
|
||||
mc = '$';
|
||||
}
|
||||
//web_script = Run_Scripter(">w", -2, 0);
|
||||
glob_script_mem.section_ptr = glob_script_mem.web_pages[page];
|
||||
} else {
|
||||
//web_script = Run_Scripter(">W", -2, 0);
|
||||
glob_script_mem.section_ptr = glob_script_mem.web_pages[0];
|
||||
}
|
||||
|
||||
//if (web_script==99) {
|
||||
if (glob_script_mem.section_ptr) {
|
||||
char tmp[256];
|
||||
uint8_t optflg = 0;
|
||||
uint8_t chartindex = 1;
|
||||
uint8_t google_libs = 0;
|
||||
|
||||
chartindex = 1;
|
||||
google_libs = 0;
|
||||
char *lp = glob_script_mem.section_ptr + 2;
|
||||
if (mc=='w') {
|
||||
if (mc == 'w') {
|
||||
while (*lp) {
|
||||
if (*lp=='\n') break;
|
||||
if (*lp == '\n') break;
|
||||
lp++;
|
||||
}
|
||||
}
|
||||
char *cv_ptr;
|
||||
float cv_max=0;
|
||||
float cv_inc=0;
|
||||
float *cv_count=0;
|
||||
|
||||
specopt = 0;
|
||||
while (lp) {
|
||||
while (*lp==SCRIPT_EOL) {
|
||||
while (*lp == SCRIPT_EOL) {
|
||||
lp++;
|
||||
}
|
||||
if (!*lp || *lp=='#' || *lp=='>') {
|
||||
break;
|
||||
}
|
||||
if (*lp!=';') {
|
||||
if (*lp != ';') {
|
||||
|
||||
// send this line to web
|
||||
SCRIPT_SKIP_SPACES
|
||||
if (!strncmp(lp, "%for ", 5)) {
|
||||
|
@ -7966,7 +8030,7 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
struct T_INDEX ind;
|
||||
uint8_t vtype;
|
||||
lp = isvar(lp + 5, &vtype, &ind, 0, 0, 0);
|
||||
if ((vtype!=VAR_NV) && (vtype&STYPE)==0) {
|
||||
if ((vtype != VAR_NV) && (vtype&STYPE) == 0) {
|
||||
uint16_t index = glob_script_mem.type[ind.index].index;
|
||||
cv_count = &glob_script_mem.fvars[index];
|
||||
SCRIPT_SKIP_SPACES
|
||||
|
@ -7976,7 +8040,7 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
SCRIPT_SKIP_SPACES
|
||||
lp = GetNumericArgument(lp , OPER_EQU, &cv_inc, 0);
|
||||
cv_ptr = lp;
|
||||
goto nextwebline;
|
||||
//goto nextwebline;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -7984,55 +8048,77 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
if (cv_count) {
|
||||
// for next loop
|
||||
*cv_count += cv_inc;
|
||||
if (*cv_count<=cv_max) {
|
||||
if (*cv_count <= cv_max) {
|
||||
lp = cv_ptr;
|
||||
} else {
|
||||
cv_count = 0;
|
||||
goto nextwebline;
|
||||
//goto nextwebline;
|
||||
}
|
||||
} else {
|
||||
goto nextwebline;
|
||||
//goto nextwebline;
|
||||
}
|
||||
} else if (!strncmp(lp, "%=#", 3)) {
|
||||
// subroutine
|
||||
uint8_t sflg = specopt;
|
||||
specopt = WSO_FORCEPLAIN;
|
||||
lp = scripter_sub(lp + 1, 0);
|
||||
goto nextwebline;
|
||||
specopt = sflg;
|
||||
//goto nextwebline;
|
||||
} else {
|
||||
web_send_line(mc, lp);
|
||||
}
|
||||
nextwebline:
|
||||
if (*lp == SCRIPT_EOL) {
|
||||
lp++;
|
||||
} else {
|
||||
lp = strchr(lp, SCRIPT_EOL);
|
||||
if (!lp) break;
|
||||
lp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *web_send_line(char mc, char *lp1) {
|
||||
char tmp[256];
|
||||
char center[10];
|
||||
uint8_t optflg = 0;
|
||||
const char *gc_str;
|
||||
|
||||
Replace_Cmd_Vars(lp1, 1, tmp, sizeof(tmp));
|
||||
|
||||
Replace_Cmd_Vars(lp, 1, tmp, sizeof(tmp));
|
||||
char *lin = tmp;
|
||||
if ((!mc && (*lin!='$')) || (mc=='w' && (*lin!='$'))) {
|
||||
/*if (!mc || mc=='w') {
|
||||
if (*lin=='$') {
|
||||
lin++;
|
||||
if (!strncmp(lin,"gc(", 3)) {
|
||||
goto exgc;
|
||||
}
|
||||
}*/
|
||||
if ((!mc && (*lin != '$')) || (mc == 'w' && (*lin != '$'))) {
|
||||
// normal web section
|
||||
if (*lin=='@') {
|
||||
if (*lin == '@') {
|
||||
lin++;
|
||||
optflg = 1;
|
||||
} else {
|
||||
optflg = 0;
|
||||
}
|
||||
// check for input elements
|
||||
// prescan for html tags
|
||||
/*
|
||||
restart:
|
||||
//if (*lp == 0 || *lp == SCRIPT_EOL)
|
||||
if (*lin == '<') {
|
||||
char *cp = strchr(lin, '>');
|
||||
if (cp) {
|
||||
char svd = *(cp + 1);
|
||||
*(cp + 1) = 0;
|
||||
WSContentSend_PD("%s", lin);
|
||||
*(cp + 1) = svd;
|
||||
lin = cp + 1;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!strncmp(lin, "sl(", 3)) {
|
||||
if (specopt & WSO_NOCENTER) {
|
||||
center[0] = 0;
|
||||
} else {
|
||||
strcpy_P(center, PSTR("<center>"));
|
||||
}
|
||||
|
||||
if (!strncmp(lin, "so(", 3)) {
|
||||
// set options
|
||||
char *lp = lin;
|
||||
float var;
|
||||
lp = GetNumericArgument(lp + 3, OPER_EQU, &var, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
lp++;
|
||||
specopt = var;
|
||||
// bit 0 = center mode
|
||||
if (specopt & WSO_NOCENTER) {
|
||||
center[0] = 0;
|
||||
} else {
|
||||
strcpy_P(center, PSTR("<center>"));
|
||||
}
|
||||
} else if (!strncmp(lin, "sl(", 3)) {
|
||||
// insert slider sl(min max var left mid right)
|
||||
char *lp = lin;
|
||||
float min;
|
||||
|
@ -8061,6 +8147,7 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
SCRIPT_SKIP_SPACES
|
||||
|
||||
WSContentSend_PD(SCRIPT_MSG_SLIDER, left,mid, right, (uint32_t)min, (uint32_t)max, (uint32_t)val, vname);
|
||||
lp++;
|
||||
|
||||
} else if (!strncmp(lin, "ck(", 3)) {
|
||||
char *lp = lin + 3;
|
||||
|
@ -8083,7 +8170,10 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
cp = "";
|
||||
uval = 1;
|
||||
}
|
||||
WSContentSend_PD(SCRIPT_MSG_CHKBOX, label, (char*)cp, uval, vname);
|
||||
WCS_DIV(specopt);
|
||||
WSContentSend_PD(SCRIPT_MSG_CHKBOX, center, label, (char*)cp, uval, vname);
|
||||
WCS_DIV(specopt | WSO_STOP_DIV);
|
||||
lp++;
|
||||
} else if (!strncmp(lin, "pd(", 3)) {
|
||||
// pull down
|
||||
char *lp = lin + 3;
|
||||
|
@ -8098,8 +8188,20 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
SCRIPT_SKIP_SPACES
|
||||
char pulabel[SCRIPT_MAXSSIZE];
|
||||
lp = GetStringArgument(lp, OPER_EQU, pulabel, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
|
||||
WSContentSend_PD(SCRIPT_MSG_PULLDOWNa, vname, pulabel, 1, vname, vname);
|
||||
glob_script_mem.glob_error = 0;
|
||||
uint16_t tsiz = 200;
|
||||
float fvar;
|
||||
char *slp1 = lp;
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &fvar, 0);
|
||||
if (!glob_script_mem.glob_error) {
|
||||
tsiz = fvar;
|
||||
} else {
|
||||
lp = slp1;
|
||||
}
|
||||
WCS_DIV(specopt);
|
||||
WSContentSend_PD(SCRIPT_MSG_PULLDOWNa, center, vname, pulabel, tsiz, 1, vname, vname);
|
||||
|
||||
// get pu labels
|
||||
uint8_t index = 1;
|
||||
|
@ -8143,6 +8245,7 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
index++;
|
||||
}
|
||||
WSContentSend_PD(SCRIPT_MSG_PULLDOWNc);
|
||||
WCS_DIV(specopt | WSO_STOP_DIV);
|
||||
} else if (!strncmp(lin, "bu(", 3)) {
|
||||
char *lp = lin + 3;
|
||||
uint8_t bcnt = 0;
|
||||
|
@ -8182,7 +8285,7 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
cp = offtxt;
|
||||
uval = 1;
|
||||
}
|
||||
if (bcnt>1 && cnt==bcnt-1) {
|
||||
if (bcnt > 1 && cnt == bcnt - 1) {
|
||||
if (!optflg) proz += 2;
|
||||
}
|
||||
if (!optflg) {
|
||||
|
@ -8190,7 +8293,7 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
} else {
|
||||
WSContentSend_PD(SCRIPT_MSG_BUTTONa_TBL, proz, uval, vname, cp);
|
||||
}
|
||||
if (bcnt>1 && cnt<bcnt-1) {
|
||||
if (bcnt > 1 && cnt < bcnt - 1) {
|
||||
if (!optflg) WSContentSend_PD(SCRIPT_MSG_BUTTONb, 2);
|
||||
}
|
||||
lp += 4;
|
||||
|
@ -8198,7 +8301,38 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
if (optflg) WSContentSend_PD(SCRIPT_MSG_BUT_STOP_TBL);
|
||||
else WSContentSend_PD(SCRIPT_MSG_BUT_STOP);
|
||||
|
||||
} else if (!strncmp(lin, "tm(", 3)) {
|
||||
// time only HH:MM
|
||||
float val;
|
||||
char *lp = lin + 3;
|
||||
char *slp = lp;
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &val, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
char vname[16];
|
||||
ScriptGetVarname(vname, slp, sizeof(vname));
|
||||
SCRIPT_SKIP_SPACES
|
||||
char label[SCRIPT_MAXSSIZE];
|
||||
lp = GetStringArgument(lp, OPER_EQU, label, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
uint16_t tsiz = 70;
|
||||
if (*lp != ')') {
|
||||
float fvar;
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &fvar, 0);
|
||||
tsiz = fvar;
|
||||
}
|
||||
lp++;
|
||||
char vstr[16];
|
||||
uint32_t tv = val;
|
||||
sprintf_P(vstr,PSTR("%02d:%02d"),tv / 100, tv % 100);
|
||||
const char *type = PSTR("time");
|
||||
const char *min = PSTR("00:00");
|
||||
const char *max = PSTR("23:59");
|
||||
const char *styp = PSTR("sivat");
|
||||
WCS_DIV(specopt);
|
||||
WSContentSend_PD(SCRIPT_MSG_TEXTINP_U, center, label, type, vstr, min, max, tsiz, styp, vname);
|
||||
WCS_DIV(specopt | WSO_STOP_DIV);
|
||||
} else if (!strncmp(lin, "tx(", 3)) {
|
||||
// text
|
||||
char *lp = lin + 3;
|
||||
char *slp = lp;
|
||||
char str[SCRIPT_MAXSSIZE];
|
||||
|
@ -8209,6 +8343,20 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
char vname[16];
|
||||
ScriptGetVarname(vname, slp, sizeof(vname));
|
||||
SCRIPT_SKIP_SPACES
|
||||
|
||||
uint16_t tsiz = 200;
|
||||
if (*lp != ')') {
|
||||
glob_script_mem.glob_error = 0;
|
||||
float fvar;
|
||||
char *slp1 = lp;
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &fvar, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
if (!glob_script_mem.glob_error) {
|
||||
tsiz = fvar;
|
||||
} else {
|
||||
lp = slp1;
|
||||
}
|
||||
|
||||
if (*lp != ')') {
|
||||
char type[SCRIPT_MAXSSIZE];
|
||||
lp = GetStringArgument(lp, OPER_EQU, type, 0);
|
||||
|
@ -8220,9 +8368,19 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
char max[SCRIPT_MAXSSIZE];
|
||||
lp = GetStringArgument(lp, OPER_EQU, max, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
WSContentSend_PD(SCRIPT_MSG_TEXTINP_U, label, type, str, min, max, vname);
|
||||
WCS_DIV(specopt);
|
||||
const char *styp = PSTR("siva");
|
||||
WSContentSend_PD(SCRIPT_MSG_TEXTINP_U, center, label, type, str, min, max, tsiz, styp, vname);
|
||||
WCS_DIV(specopt | WSO_STOP_DIV);
|
||||
} else {
|
||||
WSContentSend_PD(SCRIPT_MSG_TEXTINP, label, str, vname);
|
||||
WCS_DIV(specopt);
|
||||
WSContentSend_PD(SCRIPT_MSG_TEXTINP, center, label, str, tsiz, vname);
|
||||
WCS_DIV(specopt | WSO_STOP_DIV);
|
||||
}
|
||||
} else {
|
||||
WCS_DIV(specopt);
|
||||
WSContentSend_PD(SCRIPT_MSG_TEXTINP, center, label, str, tsiz, vname);
|
||||
WCS_DIV(specopt | WSO_STOP_DIV);
|
||||
}
|
||||
lp++;
|
||||
//goto restart;
|
||||
|
@ -8247,16 +8405,32 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
|
||||
char label[SCRIPT_MAXSSIZE];
|
||||
lp = GetStringArgument(lp, OPER_EQU, label, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
uint16_t tsiz = 200;
|
||||
uint8_t dprec = 1;
|
||||
if (*lp != ')') {
|
||||
float val;
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &val, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
tsiz = val;
|
||||
if (*lp != ')') {
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &val, 0);
|
||||
dprec = val;
|
||||
}
|
||||
}
|
||||
|
||||
char vstr[16],minstr[16],maxstr[16],stepstr[16];
|
||||
dtostrfd(val, 4, vstr);
|
||||
dtostrfd(min, 4, minstr);
|
||||
dtostrfd(max, 4, maxstr);
|
||||
dtostrfd(step, 4, stepstr);
|
||||
WSContentSend_PD(SCRIPT_MSG_NUMINP, label, minstr, maxstr, stepstr, vstr, vname);
|
||||
dtostrfd(val, dprec, vstr);
|
||||
dtostrfd(min, dprec, minstr);
|
||||
dtostrfd(max, dprec, maxstr);
|
||||
dtostrfd(step, dprec, stepstr);
|
||||
WCS_DIV(specopt);
|
||||
WSContentSend_PD(SCRIPT_MSG_NUMINP, center, label, minstr, maxstr, stepstr, vstr, tsiz, vname);
|
||||
WCS_DIV(specopt | WSO_STOP_DIV);
|
||||
lp++;
|
||||
|
||||
} else {
|
||||
if (mc=='w') {
|
||||
if (mc == 'w' || (specopt & WSO_FORCEPLAIN)) {
|
||||
WSContentSend_PD(PSTR("%s"), lin);
|
||||
} else {
|
||||
if (optflg) {
|
||||
|
@ -8269,7 +8443,7 @@ void ScriptWebShow(char mc, uint8_t page) {
|
|||
// end standard web interface
|
||||
} else {
|
||||
// main section interface
|
||||
if (*lin==mc) {
|
||||
if (*lin == mc) {
|
||||
|
||||
#ifdef USE_GOOGLE_CHARTS
|
||||
lin++;
|
||||
|
@ -8279,70 +8453,52 @@ exgc:
|
|||
// get google table
|
||||
lp = lin + 3;
|
||||
SCRIPT_SKIP_SPACES
|
||||
const char *type;
|
||||
|
||||
const char *func;
|
||||
char options[312];
|
||||
uint8_t nanum = MAX_GARRAY;
|
||||
uint8_t y2f = 0;
|
||||
uint8_t tonly = 0;
|
||||
char ctype;
|
||||
ctype = *lp;
|
||||
char type = *lp;
|
||||
if (type != 'e') {
|
||||
gs_ctype = type;
|
||||
}
|
||||
lp++;
|
||||
if (!(google_libs & GLIBS_MAIN)) {
|
||||
google_libs |= GLIBS_MAIN;
|
||||
WSContentSend_PD(SCRIPT_MSG_GTABLE);
|
||||
}
|
||||
switch (ctype) {
|
||||
case 'l':
|
||||
type = PSTR("LineChart");
|
||||
break;
|
||||
case 'b':
|
||||
type = PSTR("BarChart");
|
||||
break;
|
||||
case 'p':
|
||||
type = PSTR("PieChart");
|
||||
break;
|
||||
|
||||
gc_str = GC_type(gs_ctype);
|
||||
|
||||
switch (gs_ctype) {
|
||||
case 'g':
|
||||
type = PSTR("Gauge");
|
||||
if (!(google_libs & GLIBS_GAUGE)) {
|
||||
google_libs |= GLIBS_GAUGE;
|
||||
WSContentSend_PD(SCRIPT_MSG_GAUGE);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
type = PSTR("Table");
|
||||
if (!(google_libs & GLIBS_TABLE)) {
|
||||
google_libs |= GLIBS_TABLE;
|
||||
WSContentSend_PD(SCRIPT_MSG_TABLE);
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
type = PSTR("Timeline");
|
||||
if (!(google_libs & GLIBS_TIMELINE)) {
|
||||
google_libs |= GLIBS_TIMELINE;
|
||||
WSContentSend_PD(SCRIPT_MSG_TIMELINE);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
type = PSTR("Histogram");
|
||||
break;
|
||||
case 'c':
|
||||
type = PSTR("ColumnChart");
|
||||
break;
|
||||
case 'C':
|
||||
type = PSTR("ComboChart");
|
||||
break;
|
||||
case 'e':
|
||||
WSContentSend_PD(SCRIPT_MSG_GTABLEbx, type, chartindex);
|
||||
chartindex++;
|
||||
goto nextwebline;
|
||||
break;
|
||||
default:
|
||||
// error
|
||||
goto nextwebline;
|
||||
break;
|
||||
}
|
||||
if (ctype=='l' && *lp=='f') {
|
||||
if (type == 'e') {
|
||||
WSContentSend_PD(SCRIPT_MSG_GTABLEbx, gc_str, chartindex);
|
||||
chartindex++;
|
||||
return lp1;
|
||||
}
|
||||
|
||||
|
||||
if (gs_ctype=='l' && *lp=='f') {
|
||||
lp++;
|
||||
func = PSTR(",curveType:'function'");
|
||||
} else {
|
||||
|
@ -8368,12 +8524,13 @@ exgc:
|
|||
lp = gc_get_arrays(lp, &arrays[0], &anum, &entries, &ipos);
|
||||
|
||||
if (anum>nanum) {
|
||||
goto nextwebline;
|
||||
return lp1;
|
||||
//goto nextwebline;
|
||||
}
|
||||
// we know how many arrays and the number of entries
|
||||
//Serial.printf("arrays %d\n",anum);
|
||||
//Serial.printf("entries %d\n",entries);
|
||||
if (ctype=='T') {
|
||||
if (gs_ctype=='T') {
|
||||
if (anum && !(entries & 1)) {
|
||||
WSContentSend_PD(SCRIPT_MSG_GTABLEa);
|
||||
char label[SCRIPT_MAXSSIZE];
|
||||
|
@ -8516,14 +8673,15 @@ exgc:
|
|||
// table complete
|
||||
if (tonly) {
|
||||
WSContentSend_PD("]);");
|
||||
goto nextwebline;
|
||||
return lp1;
|
||||
//goto nextwebline;
|
||||
}
|
||||
// get header
|
||||
char header[SCRIPT_MAXSSIZE];
|
||||
lp = GetStringArgument(lp, OPER_EQU, header, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
|
||||
switch (ctype) {
|
||||
switch (gs_ctype) {
|
||||
case 't':
|
||||
snprintf_P(options, sizeof(options), SCRIPT_MSG_GOPT2);
|
||||
break;
|
||||
|
@ -8549,7 +8707,7 @@ exgc:
|
|||
snprintf_P(options, sizeof(options), SCRIPT_MSG_GOPT3, header, maxstr1, maxstr2, func);
|
||||
} else {
|
||||
SCRIPT_SKIP_SPACES
|
||||
if (ctype!='g') {
|
||||
if (gs_ctype!='g') {
|
||||
if (*lp!=')') {
|
||||
float max1;
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &max1, 0);
|
||||
|
@ -8567,7 +8725,7 @@ exgc:
|
|||
}
|
||||
}
|
||||
|
||||
if (ctype=='g') {
|
||||
if (gs_ctype=='g') {
|
||||
float yellowFrom;
|
||||
lp = GetNumericArgument(lp, OPER_EQU, &yellowFrom, 0);
|
||||
SCRIPT_SKIP_SPACES
|
||||
|
@ -8584,7 +8742,7 @@ exgc:
|
|||
}
|
||||
}
|
||||
WSContentSend_PD(SCRIPT_MSG_GTABLEb, options);
|
||||
WSContentSend_PD(SCRIPT_MSG_GTABLEbx, type, chartindex);
|
||||
WSContentSend_PD(SCRIPT_MSG_GTABLEbx, gc_str, chartindex);
|
||||
chartindex++;
|
||||
} else {
|
||||
WSContentSend_PD(PSTR("%s"), lin);
|
||||
|
@ -8597,18 +8755,9 @@ exgc:
|
|||
#endif //USE_GOOGLE_CHARTS
|
||||
}
|
||||
}
|
||||
}
|
||||
nextwebline:
|
||||
if (*lp==SCRIPT_EOL) {
|
||||
lp++;
|
||||
} else {
|
||||
lp = strchr(lp, SCRIPT_EOL);
|
||||
if (!lp) break;
|
||||
lp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lp1;
|
||||
}
|
||||
|
||||
#endif //USE_SCRIPT_WEB_DISPLAY
|
||||
|
||||
|
||||
|
@ -8684,7 +8833,10 @@ void ScriptJsonAppend(void) {
|
|||
|
||||
|
||||
bool RulesProcessEvent(const char *json_event) {
|
||||
if (bitRead(Settings->rule_enabled, 0)) Run_Scripter(">E", 2, json_event);
|
||||
if (bitRead(Settings->rule_enabled, 0)) {
|
||||
//Run_Scripter(">E", 2, json_event);
|
||||
if (glob_script_mem.event_script) Run_Scripter(glob_script_mem.event_script, 0, json_event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8860,7 +9012,9 @@ int32_t http_req(char *host, char *request) {
|
|||
|
||||
// AddLog(LOG_LEVEL_INFO, PSTR("JSON %s"), wd_jstr);
|
||||
// TasmotaGlobal.mqtt_data = wd_jstr;
|
||||
Run_Scripter(">E", 2, ResponseData());
|
||||
//Run_Scripter(">E", 2, ResponseData());
|
||||
if (glob_script_mem.event_script) Run_Scripter(glob_script_mem.event_script, 0, ResponseData());
|
||||
|
||||
|
||||
glob_script_mem.glob_error = 0;
|
||||
#endif
|
||||
|
@ -8886,7 +9040,7 @@ String authCookie = "";
|
|||
|
||||
// get tesla powerwall info page json string
|
||||
uint32_t call2https(const char *host, const char *path) {
|
||||
if (TasmotaGlobal.global_state.wifi_down) return 1;
|
||||
//if (TasmotaGlobal.global_state.wifi_down) return 1;
|
||||
uint32_t status = 0;
|
||||
|
||||
#ifdef TESLA_POWERWALL
|
||||
|
@ -8925,12 +9079,15 @@ uint32_t call2https(const char *host, const char *path) {
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
AddLog(LOG_LEVEL_INFO,PSTR(">>> host %s"),host);
|
||||
|
||||
uint32_t retry = 0;
|
||||
while ((!httpsClient->connect(host, 443)) && (retry < 5)) {
|
||||
while ((!httpsClient->connect(host, 443)) && (retry < 10)) {
|
||||
delay(100);
|
||||
retry++;
|
||||
}
|
||||
if (retry == 5) {
|
||||
if (retry == 10) {
|
||||
return 2;
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO,PSTR("connected"));
|
||||
|
@ -9631,6 +9788,7 @@ bool Xdrv10(uint8_t function)
|
|||
if (bitRead(Settings->rule_enabled, 0)) {
|
||||
Run_Scripter(">B\n", 3, 0);
|
||||
if (Run_Scripter(">F", -2, 0) == 99) {glob_script_mem.fast_script = glob_script_mem.section_ptr + 2;} else {glob_script_mem.fast_script = 0;}
|
||||
if (Run_Scripter(">E", -2, 0) == 99) {glob_script_mem.event_script = glob_script_mem.section_ptr + 2;} else {glob_script_mem.event_script = 0;}
|
||||
script_set_web_pages();
|
||||
#if defined(USE_SCRIPT_HUE) && defined(USE_WEBSERVER) && defined(USE_EMULATION) && defined(USE_EMULATION_HUE) && defined(USE_LIGHT)
|
||||
Script_Check_Hue(0);
|
||||
|
@ -9652,7 +9810,8 @@ bool Xdrv10(uint8_t function)
|
|||
if (bitRead(Settings->rule_enabled, 0)) Run_Scripter(">P", 2, 0);
|
||||
#else
|
||||
if (bitRead(Settings->rule_enabled, 0)) {
|
||||
Run_Scripter(">E", 2, 0);
|
||||
//Run_Scripter(">E", 2, 0);
|
||||
if (glob_script_mem.event_script) Run_Scripter(glob_script_mem.event_script, 0, 0);
|
||||
result = glob_script_mem.event_handeled;
|
||||
}
|
||||
#endif //SCRIPT_POWER_SECTION
|
||||
|
@ -9663,10 +9822,12 @@ bool Xdrv10(uint8_t function)
|
|||
if (!strncmp_P(ResponseData(), PSTR("{\"Status"), 8)) {
|
||||
Run_Scripter(">U", 2, ResponseData());
|
||||
} else {
|
||||
Run_Scripter(">E", 2, ResponseData());
|
||||
//Run_Scripter(">E", 2, ResponseData());
|
||||
if (glob_script_mem.event_script) Run_Scripter(glob_script_mem.event_script, 0, ResponseData());
|
||||
}
|
||||
#else
|
||||
Run_Scripter(">E", 2, ResponseData());
|
||||
//Run_Scripter(">E", 2, ResponseData());
|
||||
if (glob_script_mem.event_script) Run_Scripter(glob_script_mem.event_script, 0, ResponseData());
|
||||
#endif
|
||||
|
||||
result = glob_script_mem.event_handeled;
|
||||
|
|
Loading…
Reference in New Issue