From 51b9740a5d4e18fd34876086b92e3625a3056a5b Mon Sep 17 00:00:00 2001 From: Norbert Richter Date: Thu, 23 Jul 2020 13:23:16 +0200 Subject: [PATCH] Add script usage flags --- tasmota/settings.h | 2 +- tasmota/xdrv_10_rules.ino | 5 +++++ tasmota/xdrv_10_scripter.ino | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tasmota/settings.h b/tasmota/settings.h index 57aa35860..913309393 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -422,7 +422,7 @@ struct { uint8_t light_correction; // 49D uint8_t light_dimmer; // 49E uint8_t rule_enabled; // 49F - uint8_t rule_once; // 4A0 + uint8_t rule_once; // 4A0 bit 6+7 used by xdrv_10_scripter uint8_t light_fade; // 4A1 uint8_t light_speed; // 4A2 uint8_t light_scheme; // 4A3 diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 782116fc0..47c789935 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -791,6 +791,11 @@ bool RulesProcess(void) void RulesInit(void) { + // indicates scripter not enabled + bitWrite(Settings.rule_once, 7, 0); + // and indicates scripter do not use compress + bitWrite(Settings.rule_once, 6, 0); + rules_flag.data = 0; for (uint32_t i = 0; i < MAX_RULE_SETS; i++) { if (0 == GetRuleLen(i)) { diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 922e75ebc..19f24e1aa 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -6619,6 +6619,8 @@ bool Xdrv10(uint8_t function) glob_script_mem.script_pram=(uint8_t*)Settings.script_pram[0]; glob_script_mem.script_pram_size=PMEM_SIZE; + // indicates scripter enabled (use rules[][] as single array) + bitWrite(Settings.rule_once, 7, 1); #ifdef USE_SCRIPT_COMPRESSION int32_t len_decompressed; sprt=(char*)calloc(UNISHOXRSIZE+8,1); @@ -6627,7 +6629,12 @@ bool Xdrv10(uint8_t function) glob_script_mem.script_size=UNISHOXRSIZE; len_decompressed = SCRIPT_DECOMPRESS(Settings.rules[0], strlen(Settings.rules[0]), glob_script_mem.script_ram, glob_script_mem.script_size); if (len_decompressed>0) glob_script_mem.script_ram[len_decompressed]=0; + // indicates scripter use compression + bitWrite(Settings.rule_once, 6, 1); //AddLog_P2(LOG_LEVEL_INFO, PSTR("decompressed script len %d"),len_decompressed); +#else // USE_SCRIPT_COMPRESSION + // indicates scripter does not use compression + bitWrite(Settings.rule_once, 6, 0); #endif // USE_SCRIPT_COMPRESSION #ifdef USE_BUTTON_EVENT