Skip to content

Commit 3c32bf5

Browse files
committed
millis() return millis since first call
1 parent 0971aa9 commit 3c32bf5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

ArduinoCore-Linux/cores/arduino/Arduino.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,18 @@ char *dtostrf(double val, signed char width, unsigned char prec, char *sout){
5555

5656
// Returns the number of milliseconds passed since epich
5757
unsigned long millis() {
58+
static uint64_t start = 0;
5859
using namespace std::chrono;
5960
// Get current time with precision of milliseconds
6061
auto now = time_point_cast<milliseconds>(system_clock::now());
6162
// sys_milliseconds is type time_point<system_clock, milliseconds>
6263
using sys_milliseconds = decltype(now);
6364
// Convert time_point to signed integral type
64-
return now.time_since_epoch().count();
65+
auto result = now.time_since_epoch().count();
66+
if (start == 0) {
67+
start = result;
68+
}
69+
return result - start;
6570

6671
}
6772

0 commit comments

Comments
 (0)