scripter tasks

This commit is contained in:
gemu2015 2020-05-07 16:16:46 +02:00
parent d78ca09c30
commit eb758d49d3
1 changed files with 57 additions and 0 deletions

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
\*********************************************************************************************/