From 4ea287eb5b864eb7b7993e6084c83245509b55ca Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Wed, 27 Nov 2019 17:15:41 +0100 Subject: [PATCH] scripter math functions --- tasmota/xdrv_10_scripter.ino | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) mode change 100644 => 100755 tasmota/xdrv_10_scripter.ino diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino old mode 100644 new mode 100755 index 26584d7d7..0bab141d7 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -1059,6 +1059,19 @@ char *isvar(char *lp, uint8_t *vtype,struct T_INDEX *tind,float *fp,char *sp,Jso chknext: 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': if (!strncmp(vname,"boot",4)) { if (rules_flag.system_boot) { @@ -1678,6 +1691,24 @@ chknext: len+=1; 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 break; case 't': @@ -4730,8 +4761,8 @@ bool Xdrv10(uint8_t function) #ifdef USE_24C256 #ifndef USE_SCRIPT_FATFS - if (I2cEnabled(XI2C_37)) { - if (I2cSetDevice(EEPROM_ADDRESS)) { + if (I2cEnabled(XI2C_37)) { + if (I2cSetDevice(EEPROM_ADDRESS)) { // found 32kb eeprom char *script; script=(char*)calloc(EEP_SCRIPT_SIZE+4,1);