Merge pull request #8375 from gemu2015/scripter-tasks

Scripter tasks
This commit is contained in:
Theo Arends 2020-05-07 16:50:41 +02:00 committed by GitHub
commit 0ffd28bf21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 4 deletions

View File

@ -67,7 +67,7 @@ build_flags = ${core_active.build_flags}
; *********************************************************************
; *** Use custom settings from file user_config_override.h
-DUSE_CONFIG_OVERRIDE
; -DUSE_CONFIG_OVERRIDE
; *********************************************************************
; *** Fix espressif8266@1.7.0 induced undesired all warnings

View File

@ -1186,6 +1186,22 @@ chknext:
fvar=xPortGetCoreID();
goto exit;
}
#ifdef USE_SCRIPT_TASK
if (!strncmp(vname,"ct(",3)) {
lp+=3;
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
while (*lp==' ') lp++;
float fvar1;
lp=GetNumericResult(lp,OPER_EQU,&fvar1,0);
while (*lp==' ') lp++;
float fvar2;
lp=GetNumericResult(lp,OPER_EQU,&fvar2,0);
lp++;
fvar=scripter_create_task(fvar,fvar1,fvar2);
len=0;
goto exit;
}
#endif
#endif
break;
case 'd':
@ -5099,6 +5115,47 @@ bool RulesProcessEvent(char *json_event) {
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E",2,json_event);
}
#ifdef ESP32
#ifdef USE_SCRIPT_TASK
uint16_t task_timer1;
uint16_t task_timer2;
void script_task1(void *arg) {
while (1) {
delay(task_timer1);
Run_Scripter(">t1",3,0);
}
}
void script_task2(void *arg) {
while (1) {
delay(task_timer2);
Run_Scripter(">t2",3,0);
}
}
#ifndef STASK_STACK
#define STASK_STACK 4096
#endif
#ifndef STASK_PRIO
#define STASK_PRIO 5
#endif
uint32_t scripter_create_task(uint32_t num, uint32_t time, uint32_t core) {
//return 0;
BaseType_t res=0;
if (core>1) {core = 1;}
if (num == 1) {
res = xTaskCreatePinnedToCore(script_task1, "T 1", STASK_STACK, NULL, STASK_PRIO, NULL, core);
task_timer1=time;
} else {
res = xTaskCreatePinnedToCore(script_task2, "T 2", STASK_STACK, NULL, STASK_PRIO, NULL, core);
task_timer2=time;
}
return res;
}
#endif // USE_SCRIPT_TASK
#endif // ESP32
/*********************************************************************************************\
* Interface
\*********************************************************************************************/