mirror of https://github.com/arendst/Tasmota.git
Add initial support for Scripts
Add initial support for Scripts as replacement for Rules. Default disabled but can be enabled in my_user_config.h (#5689)
This commit is contained in:
parent
55ec55c8c9
commit
dc3d0aea94
|
@ -1,5 +1,6 @@
|
||||||
/* 6.5.0.11 20190517
|
/* 6.5.0.11 20190517
|
||||||
* Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689)
|
* Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689)
|
||||||
|
* Add initial support for Scripts as replacement for Rules. Default disabled but can be enabled in my_user_config.h (#5689)
|
||||||
*
|
*
|
||||||
* 6.5.0.10 20190513
|
* 6.5.0.10 20190513
|
||||||
* Enable ADC0 by default in my_user_config.h (#5671)
|
* Enable ADC0 by default in my_user_config.h (#5671)
|
||||||
|
|
|
@ -288,10 +288,10 @@
|
||||||
#define USE_SUNRISE // Add support for Sunrise and sunset tools (+16k)
|
#define USE_SUNRISE // Add support for Sunrise and sunset tools (+16k)
|
||||||
#define SUNRISE_DAWN_ANGLE DAWN_NORMAL // Select desired Dawn Angle from (DAWN_NORMAL, DAWN_CIVIL, DAWN_NAUTIC, DAWN_ASTRONOMIC)
|
#define SUNRISE_DAWN_ANGLE DAWN_NORMAL // Select desired Dawn Angle from (DAWN_NORMAL, DAWN_CIVIL, DAWN_NAUTIC, DAWN_ASTRONOMIC)
|
||||||
|
|
||||||
// -- Rules or Scripts ----------------------------
|
// -- Rules or Script ----------------------------
|
||||||
// Select none or only one of the below defines
|
// Select none or only one of the below defines
|
||||||
#define USE_RULES // Add support for rules (+4k4 code)
|
#define USE_RULES // Add support for rules (+8k code)
|
||||||
//#define USE_SCRIPT // Add support for script
|
//#define USE_SCRIPT // Add support for script (+15k code)
|
||||||
|
|
||||||
// #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
|
// #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
|
||||||
// #define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code)
|
// #define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code)
|
||||||
|
|
|
@ -103,7 +103,7 @@ void GetFeatures(void)
|
||||||
#ifdef USE_TIMERS_WEB
|
#ifdef USE_TIMERS_WEB
|
||||||
feature_drv1 |= 0x04000000; // xdrv_09_timers.ino
|
feature_drv1 |= 0x04000000; // xdrv_09_timers.ino
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_RULES) || defined(USE_SCRIPT)
|
#ifdef USE_RULES
|
||||||
feature_drv1 |= 0x08000000; // xdrv_10_rules.ino
|
feature_drv1 |= 0x08000000; // xdrv_10_rules.ino
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_KNX
|
#ifdef USE_KNX
|
||||||
|
@ -180,8 +180,10 @@ void GetFeatures(void)
|
||||||
#ifdef USE_SM16716
|
#ifdef USE_SM16716
|
||||||
feature_drv2 |= 0x00040000; // xdrv_04_light.ino
|
feature_drv2 |= 0x00040000; // xdrv_04_light.ino
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_SCRIPT
|
||||||
|
feature_drv2 |= 0x00080000; // xdrv_10_scripter.ino
|
||||||
|
#endif
|
||||||
|
|
||||||
// feature_drv2 |= 0x00080000;
|
|
||||||
// feature_drv2 |= 0x00100000;
|
// feature_drv2 |= 0x00100000;
|
||||||
// feature_drv2 |= 0x00200000;
|
// feature_drv2 |= 0x00200000;
|
||||||
// feature_drv2 |= 0x00400000;
|
// feature_drv2 |= 0x00400000;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_RULES
|
#ifdef USE_RULES
|
||||||
|
#ifndef USE_SCRIPT
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Rules based heavily on ESP Easy implementation
|
* Rules based heavily on ESP Easy implementation
|
||||||
*
|
*
|
||||||
|
@ -1287,4 +1288,5 @@ bool Xdrv10(uint8_t function)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // Do not USE_SCRIPT
|
||||||
#endif // USE_RULES
|
#endif // USE_RULES
|
|
@ -17,25 +17,28 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// for doku see up to date doku in file scripter.md
|
#ifdef USE_SCRIPT
|
||||||
|
#ifndef USE_RULES
|
||||||
|
/*********************************************************************************************\
|
||||||
|
|
||||||
// uses about 14,2 k of flash
|
for documentation see up to date docs in file SCRIPTER.md
|
||||||
// more stack could be needed for sendmail => -D CONT_STACKSIZE=4800 = +0.8k stack -0.8k heap
|
|
||||||
//
|
|
||||||
|
|
||||||
/* to doo
|
uses about 14,2 k of flash
|
||||||
|
more stack could be needed for sendmail => -D CONT_STACKSIZE=4800 = +0.8k stack -0.8k heap
|
||||||
|
|
||||||
|
|
||||||
|
to do
|
||||||
optimize code for space
|
optimize code for space
|
||||||
|
|
||||||
// remarks
|
remarks
|
||||||
goal is fast execution time, minimal use of ram and intuitive syntax
|
goal is fast execution time, minimal use of ram and intuitive syntax
|
||||||
therefore =>
|
therefore =>
|
||||||
case sensitive cmds and vars (lowercase uses time and code)
|
case sensitive cmds and vars (lowercase uses time and code)
|
||||||
no math hierarchy (costs ram and execution time, better group with brackets, anyhow better readable for beginners)
|
no math hierarchy (costs ram and execution time, better group with brackets, anyhow better readable for beginners)
|
||||||
(will probably make math hierarchy an ifdefed option)
|
(will probably make math hierarchy an ifdefed option)
|
||||||
keywords if then else endif, or, and are better readable for beginners (others may use {})
|
keywords if then else endif, or, and are better readable for beginners (others may use {})
|
||||||
*/
|
|
||||||
#ifdef USE_SCRIPT
|
\*********************************************************************************************/
|
||||||
#ifndef USE_RULES
|
|
||||||
|
|
||||||
#define XDRV_10 10
|
#define XDRV_10 10
|
||||||
|
|
||||||
|
@ -896,8 +899,8 @@ chknext:
|
||||||
float fvar2;
|
float fvar2;
|
||||||
lp=GetNumericResult(lp,OPER_EQU,&fvar2,0);
|
lp=GetNumericResult(lp,OPER_EQU,&fvar2,0);
|
||||||
lp++;
|
lp++;
|
||||||
fvar=pow(fvar1,fvar2);
|
//fvar=pow(fvar1,fvar2);
|
||||||
//fvar=FastPrecisePow(fvar1,fvar2);
|
fvar=FastPrecisePow(fvar1,fvar2);
|
||||||
len=0;
|
len=0;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -2231,5 +2234,5 @@ bool Xdrv10(byte function)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // not use RULES
|
#endif // Do not USE_RULES
|
||||||
#endif // USE_SCRIPT
|
#endif // USE_SCRIPT
|
||||||
|
|
Loading…
Reference in New Issue