mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
commit
b5aad9ba75
@ -2674,6 +2674,40 @@ exit10:
|
|||||||
return lp;
|
return lp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ESP32
|
||||||
|
|
||||||
|
TimerHandle_t beep_th;
|
||||||
|
void StopBeep( TimerHandle_t xTimer );
|
||||||
|
|
||||||
|
void StopBeep( TimerHandle_t xTimer ) {
|
||||||
|
ledcWriteTone(7,0);
|
||||||
|
xTimerStop(xTimer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp32_beep(int32_t freq ,uint32_t len) {
|
||||||
|
if (freq<0) {
|
||||||
|
ledcSetup(7,500,10);
|
||||||
|
ledcAttachPin(-freq,7);
|
||||||
|
ledcWriteTone(7,0);
|
||||||
|
if (!beep_th) {
|
||||||
|
beep_th = xTimerCreate("beep",100,pdFALSE,( void * ) 0,StopBeep);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!beep_th) return;
|
||||||
|
if (!freq) {
|
||||||
|
ledcWriteTone(7,0);
|
||||||
|
xTimerStop(beep_th, 10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (len < 10) return;
|
||||||
|
if (xTimerIsTimerActive(beep_th)) return;
|
||||||
|
ledcWriteTone(7,freq);
|
||||||
|
uint32_t ticks = pdMS_TO_TICKS(len);
|
||||||
|
xTimerChangePeriod( beep_th, ticks, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ESP32
|
||||||
|
|
||||||
//#define IFTHEN_DEBUG
|
//#define IFTHEN_DEBUG
|
||||||
|
|
||||||
#define IF_NEST 8
|
#define IF_NEST 8
|
||||||
@ -2706,11 +2740,12 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObject *jo=0;
|
JsonObject *jo=0;
|
||||||
|
DynamicJsonBuffer jsonBuffer; // on heap
|
||||||
|
JsonObject &jobj=jsonBuffer.parseObject(js);
|
||||||
if (js) {
|
if (js) {
|
||||||
DynamicJsonBuffer jsonBuffer; // on heap
|
|
||||||
JsonObject &jobj=jsonBuffer.parseObject(js);
|
|
||||||
jo=&jobj;
|
jo=&jobj;
|
||||||
|
} else {
|
||||||
|
jo=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *lp=glob_script_mem.scriptptr;
|
char *lp=glob_script_mem.scriptptr;
|
||||||
@ -2995,13 +3030,10 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
|||||||
else if (!strncmp(lp,"beep(",5)) {
|
else if (!strncmp(lp,"beep(",5)) {
|
||||||
lp+=5;
|
lp+=5;
|
||||||
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
|
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
|
||||||
if (fvar<0) {
|
SCRIPT_SKIP_SPACES
|
||||||
ledcSetup(7,500,10);
|
float fvar1;
|
||||||
ledcAttachPin(-fvar,7);
|
lp=GetNumericResult(lp,OPER_EQU,&fvar1,0);
|
||||||
ledcWriteTone(7,0);
|
esp32_beep(fvar,fvar1);
|
||||||
} else {
|
|
||||||
ledcWriteTone(7,fvar);
|
|
||||||
}
|
|
||||||
lp++;
|
lp++;
|
||||||
goto next_line;
|
goto next_line;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user