Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f501e5

Browse files
Fix: Increase accuracy of "delay()" routine. (#203)
This fixes #194.
1 parent 1e94dfe commit 5f501e5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎cores/arduino/time.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
// this file implements the following public funcions: delay, delayMicroseconds, yield, millis, micros
66

7-
__attribute__((weak)) void delay(uint32_t ms) {
8-
R_BSP_SoftwareDelay(ms, BSP_DELAY_UNITS_MILLISECONDS);
7+
__attribute__((weak)) void delay(uint32_t ms)
8+
{
9+
auto const start = millis();
10+
auto const stop = start + ms;
11+
while(millis() < stop) yield();
912
}
1013

1114
void delayMicroseconds(unsigned int us) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /