static unsigned long lastCountMillis = 0; // Holds the counter start millis
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void printTime()
{
Serial.println("+-- printTime()");
struct timeval current_time;
gettimeofday(¤t_time, NULL);
lastCountMillis = millis();
int seconds = current_time.tv_sec;
Serial.printf("--- Seconds : %ld\n--- micro seconds : %ld\n--- Millis: %lu\n", seconds, current_time.tv_usec, lastCountMillis);
int hours = seconds / 3600;
int minutes = (seconds / 60) % 60;
int actual_seconds = seconds % 60;
unsigned long actual_ms = current_time.tv_usec / 1000;
Serial.printf("--- Time Alive[H:M:S:ms]: %02d:%02d:%02d:%u\n", hours, minutes, actual_seconds, actual_ms);
Serial.println("");
}
void loop() {
// put your main code here, to run repeatedly:
printTime();
delay(1000); // this speeds up the simulation
}