Page 1 of 1

LongPulse_mS vs Pulse

Posted: 03 Jul 2021, 23:23
by hestia
in https://espeasy.readthedocs.io I've read that
LongPulse_mS :
A long pulse is basically the same as the plain pulse. Duration is defined in seconds, which makes it more suitable for longer duration.
Pulse:
this is a blocking call, meaning no other actions will be performed during the pulse.
Question about <<no other actions will be performed during the pulse>> - no other actions in all the ESP or only in the sequence of the pulse?
For instance, if I do

Code: Select all

Pulse, 13,0,250
Pulse, 13,1,250
Pulse, 13,0,250
Pulse, 13,1,250
Nothing else could happen during 1 second in all the ESP?
Is it a good way to bling a LED?
On the other hand I could not do it with LongPulse_mS

Code: Select all

LongPulse_mS , 13,0,250
LongPulse_mS , 13,1,250
LongPulse_mS , 13,0,250
LongPulse_mS , 13,1,250
because all events are sent at the same time.
So, how to blink fast?

Re: LongPulse_mS vs Pulse

Posted: 04 Jul 2021, 00:11
by ThomasB
So, how to blink fast?
Based on your examples, I suggest using the Notify-Chiming plugin available in mega's TESTING release.

Basic Installation as follows:
1. Install the Notify-Chiming plugin.
2. Select the Enable box.
3. Select the Actuator Inversed Logic box.
4. Enter your GPIO-13 pin in the GPIO → Driver#1 entry.
5. Set Chiming/Strike Time to 250ms.
6. Set Normal Pause Time to 250mS.

Your double blink "Pulse" code from your rule example looked like this:

Code: Select all

Pulse, 13,0,250
Pulse, 13,1,250
Pulse, 13,0,250
Pulse, 13,1,250
But now you will use non-blocking rule code like this to blink twice:

Code: Select all

chime,11
If you want to blink five times then do this:

Code: Select all

chime,11111
Other blink patterns are possible. Details are here: https://github.com/letscontrolit/ESPEas ... ng.ino#L12

- Thomas

Re: LongPulse_mS vs Pulse

Posted: 04 Jul 2021, 10:25
by TD-er
I think the PWM command may also be useful here.
The PWM command is only given once and being executed in the background without the need to process events or rules.

See: https://espeasy.readthedocs.io/en/lates ... ernal-gpio
The pwm command can accept a frequency parameter too , but sadly it also needs a duration which you don't need.
The duration is a fade from one duty cycle to another (to fade lights), but this is blocking code so don't use it continuously.
What you can do however is call it once with a frequency and a very short fade.
Then the frequency is set and you can then call the PWM to start blinking (e.g. 50% duty cycle at 10Hz) without the need to process rules at 10x a second, which is a burden on the ESP.

Re: LongPulse_mS vs Pulse

Posted: 04 Jul 2021, 15:32
by hestia
thanks both of you
I'd rather not to install any plugin if possible , so I've tried the PWM
with no success :-(
I've tried several codes around

Code: Select all

on Rules#Timer=4 do
	timerSet,4,1
	//PWM,13,0,1000,10
	PWM,13,0
endon

on System#Boot do
  timerSet,4,1
  PWM,13,0,1,10 // init the frequency
endon
with no blink at the end!

Re: LongPulse_mS vs Pulse

Posted: 04 Jul 2021, 16:24
by hestia
Basic Installation as follows:
1. Install the Notify-Chiming plugin.
I did find how to install a plugin :-(
Possible OTA? I have a Sonoff 4CH R3

Re: LongPulse_mS vs Pulse

Posted: 04 Jul 2021, 20:02
by ThomasB
I did find how to install a plugin :-(
Possible OTA? I have a Sonoff 4CH R3
This plugin is in the Mega [Testing] builds. To get it you need to reflash with a ESPEasy Mega TESTING release that is compatible with your device.

- Thomas

Re: LongPulse_mS vs Pulse

Posted: 04 Jul 2021, 20:10
by hestia
thanks Thomas
I'm not willing to flash my Sonoff because I'll need to put it off the wall and reopen it. I think I'm at the end of the testing and I don't want to break everything.
I'll try PWM if I can get some progress