Skip to content

Commit a315f6e

Browse files
committed
add myDelay function
1 parent ed58cfb commit a315f6e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ddcommon.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,14 @@ void writeToSerial(double msg, bool nl)
6262
Serial.println();
6363
}
6464
}
65+
66+
bool myDelay(uint32_t ms, unsigned long *startMillis)
67+
{
68+
bool ret = true;
69+
unsigned long currentMillis = millis();
70+
if (currentMillis - *startMillis < ms)
71+
ret = false;
72+
else
73+
*startMillis = currentMillis;
74+
return ret;
75+
}

ddcommon.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* 1.0.0 VERSION */
1+
/* 1.1.0 VERSION */
22

33
#ifndef ddcommon_h
44
#define ddcommon_h
@@ -19,4 +19,6 @@ void writeToSerial(unsigned int, bool);
1919

2020
void writeToSerial(double, bool);
2121

22+
bool myDelay(uint32_t, unsigned long *);
23+
2224
#endif

0 commit comments

Comments
 (0)