Skip to content

Commit 71744d7

Browse files
committed
Add printTimeStamp to support.ino
1 parent 1d5a341 commit 71744d7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Firmware/RTK_Surveyor/support.ino

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,29 @@ byte readLine(char* buffer, byte bufferLength, int numberOfSeconds)
405405

406406
return readLength;
407407
}
408+
409+
#define TIMESTAMP_INTERVAL 1000 //Milliseconds
410+
411+
//Print the timestamp
412+
void printTimeStamp()
413+
{
414+
uint32_t currentMilliseconds;
415+
static uint32_t previousMilliseconds;
416+
417+
//Timestamp the messages
418+
currentMilliseconds = millis();
419+
if ((currentMilliseconds - previousMilliseconds) >= TIMESTAMP_INTERVAL)
420+
{
421+
// 1 2 3
422+
//123456789012345678901234567890
423+
//YYYY-mm-dd HH:MM:SS.xxxrn0
424+
struct tm timeinfo = rtc.getTimeStruct();
425+
char timestamp[30];
426+
strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", &timeinfo);
427+
Serial.printf("%s.%03ld\r\n", timestamp, rtc.getMillis());
428+
429+
//Select the next time to display the timestamp
430+
previousMilliseconds = currentMilliseconds;
431+
}
432+
}
433+

0 commit comments

Comments
 (0)