mirror of https://github.com/arendst/Tasmota.git
scripter fix create task
This commit is contained in:
parent
aadfff1c0b
commit
9b0aa51515
|
@ -891,6 +891,16 @@ if (hsv.S == 0) {
|
|||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
#include "esp_pm.h"
|
||||
#include "esp_clk.h"
|
||||
uint32_t switch_freq(uint32_t mhz) {
|
||||
setCpuFrequencyMhz(mhz); //Set CPU clock to 80MHz fo example
|
||||
return getCpuFrequencyMhz(); //Get CPU clock
|
||||
}
|
||||
#endif // ESP32
|
||||
|
||||
// vtype => ff=nothing found, fe=constant number,fd = constant string else bit 7 => 80 = string, 0 = number
|
||||
// no flash strings here for performance reasons!!!
|
||||
char *isvar(char *lp, uint8_t *vtype,struct T_INDEX *tind,float *fp,char *sp,JsonObject *jo) {
|
||||
|
@ -1879,6 +1889,19 @@ chknext:
|
|||
len=0;
|
||||
goto strexit;
|
||||
}
|
||||
#ifdef ESP32
|
||||
if (!strncmp(vname,"sf(",3)) {
|
||||
lp+=2;
|
||||
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
|
||||
if (fvar<80) fvar=80;
|
||||
if (fvar>240) fvar=240;
|
||||
setCpuFrequencyMhz(fvar);
|
||||
fvar=getCpuFrequencyMhz();
|
||||
lp++;
|
||||
len=0;
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
#if defined(USE_TIMERS) && defined(USE_SUNRISE)
|
||||
if (!strncmp(vname,"sunrise",7)) {
|
||||
fvar=SunMinutes(0);
|
||||
|
@ -2093,7 +2116,7 @@ chknext:
|
|||
len=0;
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
#endif //ESP32, USE_WEBCAM
|
||||
if (!strncmp(vname,"wday",4)) {
|
||||
fvar=RtcTime.day_of_week;
|
||||
goto exit;
|
||||
|
@ -2692,11 +2715,13 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
|||
return -99;
|
||||
}
|
||||
|
||||
DynamicJsonBuffer jsonBuffer; // on heap
|
||||
JsonObject &jobj=jsonBuffer.parseObject(js);
|
||||
JsonObject *jo;
|
||||
if (js) jo=&jobj;
|
||||
else jo=0;
|
||||
JsonObject *jo=0;
|
||||
|
||||
if (js) {
|
||||
DynamicJsonBuffer jsonBuffer; // on heap
|
||||
JsonObject &jobj=jsonBuffer.parseObject(js);
|
||||
jo=&jobj;
|
||||
}
|
||||
|
||||
char *lp=glob_script_mem.scriptptr;
|
||||
|
||||
|
@ -5119,6 +5144,8 @@ bool RulesProcessEvent(char *json_event) {
|
|||
#ifdef USE_SCRIPT_TASK
|
||||
uint16_t task_timer1;
|
||||
uint16_t task_timer2;
|
||||
TaskHandle_t task_t1;
|
||||
TaskHandle_t task_t2;
|
||||
|
||||
void script_task1(void *arg) {
|
||||
while (1) {
|
||||
|
@ -5143,14 +5170,16 @@ void script_task2(void *arg) {
|
|||
|
||||
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;}
|
||||
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;
|
||||
if (task_t1) { vTaskDelete(task_t1); }
|
||||
res = xTaskCreatePinnedToCore(script_task1, "T1", STASK_STACK, NULL, STASK_PRIO, &task_t1, core);
|
||||
task_timer1 = time;
|
||||
} else {
|
||||
res = xTaskCreatePinnedToCore(script_task2, "T 2", STASK_STACK, NULL, STASK_PRIO, NULL, core);
|
||||
task_timer2=time;
|
||||
if (task_t2) { vTaskDelete(task_t2); }
|
||||
res = xTaskCreatePinnedToCore(script_task2, "T2", STASK_STACK, NULL, STASK_PRIO, &task_t2, core);
|
||||
task_timer2 = time;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue