From 0ad3cba113a93d96cb95ecc38f962bdfffbdd614 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 4 Mar 2021 15:26:39 +0100 Subject: [PATCH] millis --- src/counter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/counter.c b/src/counter.c index f84d739..aea59e0 100644 --- a/src/counter.c +++ b/src/counter.c @@ -79,13 +79,18 @@ int main (void) { uint8_t ledTick = 0; struct timespec timestamp; + uint32_t last_seconds = 0; + uint32_t last_milliseconds = 0; + while (1) { uint32_t period = ringbufferGet(); clock_gettime(CLOCK_REALTIME, ×tamp); + uint32_t current_seconds = timestamp.tv_sec; + uint32_t current_milliseconds = timestamp.tv_nsec / 1e6; // add averaging and forming the struct here - logmsg(LOG_DEBUG, "s: %lu, ns: %lu, p: %lu", timestamp.tv_sec, timestamp.tv_nsec, period); + logmsg(LOG_DEBUG, "s: %lu, ns: %lu, p: %lu", current_seconds, current_milliseconds, period); ledTick++; if (ledTick == 50) {