Skip to content

Commit ba73d82

Browse files
committed
Delay(0) is just a convoluted way of saying yield()
1 parent 845241b commit ba73d82

File tree

11 files changed

+20
-20
lines changed

11 files changed

+20
-20
lines changed

cores/esp8266/PolledTimeout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct DoNothing
4444

4545
struct YieldOrSkip
4646
{
47-
static void execute() {delay(0);}
47+
static void execute() {yield();}
4848
};
4949

5050
template <unsigned long delayMs>

cores/esp8266/core_esp8266_waveform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int startWaveform(uint8_t pin, uint32_t timeHighUS, uint32_t timeLowUS, uint32_t
139139
}
140140
}
141141
while (waveformToEnable) {
142-
delay(0); // Wait for waveform to update
142+
yield(); // Wait for waveform to update
143143
}
144144
}
145145

cores/esp8266/uart.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ uart_wait_tx_empty(uart_t* uart)
528528
return;
529529

530530
while(uart_tx_fifo_available(uart->uart_nr) > 0)
531-
delay(0);
531+
yield();
532532

533533
}
534534

@@ -892,7 +892,7 @@ inline void
892892
uart_write_char_delay(const int uart_nr, char c)
893893
{
894894
while(uart_tx_fifo_full(uart_nr))
895-
delay(0);
895+
yield();
896896

897897
USF(uart_nr) = c;
898898

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size)
854854
len -= readBytes;
855855
}
856856

857-
delay(0);
857+
yield();
858858
} else {
859859
delay(1);
860860
}
@@ -1000,7 +1000,7 @@ int HTTPClient::writeToStream(Stream * stream)
10001000
return returnError(HTTPC_ERROR_READ_TIMEOUT);
10011001
}
10021002

1003-
delay(0);
1003+
yield();
10041004
}
10051005
} else {
10061006
return returnError(HTTPC_ERROR_ENCODING);
@@ -1387,7 +1387,7 @@ int HTTPClient::handleHeaderResponse()
13871387
if((millis() - lastDataTime) > _tcpTimeout) {
13881388
return HTTPC_ERROR_READ_TIMEOUT;
13891389
}
1390-
delay(0);
1390+
yield();
13911391
}
13921392
}
13931393

@@ -1483,7 +1483,7 @@ int HTTPClient::writeToStreamDataBlock(Stream * stream, int size)
14831483
len -= bytesRead;
14841484
}
14851485

1486-
delay(0);
1486+
yield();
14871487
}
14881488

14891489
free(buff);

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
119119
Update.end();
120120
if (_serial_output) Serial.println("Update was aborted");
121121
}
122-
delay(0);
122+
yield();
123123
});
124124
}
125125

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,9 @@ bool ESP8266WiFiGenericClass::forceSleepBegin(uint32 sleepUs) {
523523
}
524524

525525
wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
526-
delay(0);
526+
yield();
527527
wifi_fpm_open();
528-
delay(0);
528+
yield();
529529
auto ret = wifi_fpm_do_sleep(sleepUs);
530530
if (ret != 0)
531531
{

libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ wl_status_t ESP8266WiFiMulti::run(void) {
6565
DEBUG_WIFI_MULTI("[WIFI] no networks found\n");
6666
WiFi.scanDelete();
6767
DEBUG_WIFI_MULTI("\n\n");
68-
delay(0);
68+
yield();
6969
WiFi.disconnect();
7070
DEBUG_WIFI_MULTI("[WIFI] start scan\n");
7171
// scan wifi async mode
@@ -81,7 +81,7 @@ wl_status_t ESP8266WiFiMulti::run(void) {
8181
int32_t bestChannel;
8282

8383
DEBUG_WIFI_MULTI("[WIFI] scan done\n");
84-
delay(0);
84+
yield();
8585

8686
DEBUG_WIFI_MULTI("[WIFI] %d networks found\n", scanResult);
8787
for(int8_t i = 0; i < scanResult; ++i) {
@@ -118,14 +118,14 @@ wl_status_t ESP8266WiFiMulti::run(void) {
118118
}
119119

120120
DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == ENC_TYPE_NONE) ? ' ' : '*');
121-
delay(0);
121+
yield();
122122
}
123123

124124
// clean up ram
125125
WiFi.scanDelete();
126126

127127
DEBUG_WIFI_MULTI("\n\n");
128-
delay(0);
128+
yield();
129129

130130
if(bestNetwork.ssid) {
131131
DEBUG_WIFI_MULTI("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channel: %d (%d)\n", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb);

libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden, uint8 ch
9494
ESP8266WiFiScanClass::_scanStarted = true;
9595

9696
if(ESP8266WiFiScanClass::_scanAsync) {
97-
delay(0); // time for the OS to trigger the scan
97+
yield(); // time for the OS to trigger the scan
9898
return WIFI_SCAN_RUNNING;
9999
}
100100

libraries/ESP8266WiFi/src/include/ClientContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ class ClientContext
342342
last_sent = millis();
343343
}
344344

345-
delay(0); // from sys or os context
345+
yield(); // from sys or os context
346346

347347
if ((state() != ESTABLISHED) || (sndbuf == TCP_SND_BUF)) {
348348
break;

libraries/SDFS/src/SDFSFormatter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SDFSFormatter {
7676
esp8266::polledTimeout::periodicFastMs timeToYield(5); // Yield every 5ms of runtime
7777
for (uint32_t i = 0; i < count; i++) {
7878
if (timeToYield) {
79-
delay(0); // WDT feed
79+
yield(); // WDT feed
8080
}
8181
if (!card->writeData(cache->data)) {
8282
DEBUGV("SDFS: Clear FAT/DIR writeData failed");
@@ -383,7 +383,7 @@ class SDFSFormatter {
383383
if (!card->erase(firstBlock, lastBlock)) {
384384
return false; // Erase fail
385385
}
386-
delay(0); // yield to the OS to avoid WDT
386+
yield(); // yield to the OS to avoid WDT
387387
firstBlock += ERASE_SIZE;
388388
} while (firstBlock < cardSizeBlocks);
389389

libraries/esp8266/examples/SerialStress/SerialStress.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void loop() {
128128
if ((out_idx += local_written_size) == BUFFER_SIZE) {
129129
out_idx = 0;
130130
}
131-
delay(0);
131+
yield();
132132

133133
DEBUG(logger->printf("----------\n"));
134134

0 commit comments

Comments
 (0)