-->
Page 2 of 3

Re: Code for non-blocking tasks and shaky WiFi

PostPosted: Wed Oct 04, 2017 9:33 am
by mrburnette
I would just utilize delay (0) which is functionally equivalent to yield ()
Unless the 10mS delay is actually required,

For example, the 1mS is necessary in the code below:

/* Initializations */
// ------------------begin ESP8266'centric----------------------------------
WiFi.forceSleepBegin(); // turn off ESP8266 RF
delay(1); // give RF section time to shutdown
system_update_cpu_freq(FREQUENCY);
// ------------------end ESP8266'centric------------------------------------


I have a few other ESP8266 projects over on my page:
https://www.hackster.io/rayburne/projects


Ray

Re: Code for non-blocking tasks and shaky WiFi

PostPosted: Thu Oct 05, 2017 10:44 am
by andre_teprom
Whenever possible, use delays based on interrup timer rather than closed loop "delay(value)" implementations.

Re: Code for non-blocking tasks and shaky WiFi

PostPosted: Thu Oct 05, 2017 12:40 pm
by mrburnette
andre_teprom wrote:Whenever possible, use delays based on interrup timer rather than closed loop "delay(value)" implementations.


No.
The entire purpose of yield () or delay (0) is to provide a release of the Arduino thread so that non-OS can have some cpu time. There is no benefit in this case of interrupt-timed pauses.

Ray

Re: Code for non-blocking tasks and shaky WiFi

PostPosted: Thu Oct 05, 2017 5:33 pm
by andre_teprom
mrburnette wrote:No.
The entire purpose of yield () or delay (0) is to provide a release of the Arduino thread so that non-OS can have some cpu time. There is no benefit in this case of interrupt-timed pauses.


I wonder how one could implement a longest delay by using the suggested structure with argument 0.
Interrupt-based delay is allways the better choice, since this way can use a time slot to split the tasks into specific time alocation.