Merge pull request #7041 from gemu2015/scripter-mfunc

scripter math functions
This commit is contained in:
Theo Arends 2019-11-27 19:56:06 +01:00 committed by GitHub
commit b99c35f87c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 2 deletions

35
tasmota/xdrv_10_scripter.ino Normal file → Executable file
View File

@ -1059,6 +1059,19 @@ char *isvar(char *lp, uint8_t *vtype,struct T_INDEX *tind,float *fp,char *sp,Jso
chknext: chknext:
switch (vname[0]) { switch (vname[0]) {
case 'a':
#ifdef USE_ANGLE_FUNC
if (!strncmp(vname,"acos(",5)) {
lp+=5;
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
fvar=acosf(fvar);
lp++;
len=0;
goto exit;
}
#endif
break;
case 'b': case 'b':
if (!strncmp(vname,"boot",4)) { if (!strncmp(vname,"boot",4)) {
if (rules_flag.system_boot) { if (rules_flag.system_boot) {
@ -1678,6 +1691,24 @@ chknext:
len+=1; len+=1;
goto exit; goto exit;
} }
#endif
#ifdef USE_ANGLE_FUNC
if (!strncmp(vname,"sin(",4)) {
lp+=4;
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
fvar=sinf(fvar);
lp++;
len=0;
goto exit;
}
if (!strncmp(vname,"sqrt(",5)) {
lp+=5;
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
fvar=sqrtf(fvar);
lp++;
len=0;
goto exit;
}
#endif #endif
break; break;
case 't': case 't':
@ -4730,8 +4761,8 @@ bool Xdrv10(uint8_t function)
#ifdef USE_24C256 #ifdef USE_24C256
#ifndef USE_SCRIPT_FATFS #ifndef USE_SCRIPT_FATFS
if (I2cEnabled(XI2C_37)) { if (I2cEnabled(XI2C_37)) {
if (I2cSetDevice(EEPROM_ADDRESS)) { if (I2cSetDevice(EEPROM_ADDRESS)) {
// found 32kb eeprom // found 32kb eeprom
char *script; char *script;
script=(char*)calloc(EEP_SCRIPT_SIZE+4,1); script=(char*)calloc(EEP_SCRIPT_SIZE+4,1);