From 56b89f66b74b7d7c727f4e6997d9d0e8298e8535 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 4 Oct 2019 09:48:04 +0100 Subject: [PATCH] changes --- snippets/test1/test1.c | 10 +++++++--- snippets/test2/.gitignore | 1 + snippets/test2/test2.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 snippets/test2/.gitignore create mode 100644 snippets/test2/test2.c diff --git a/snippets/test1/test1.c b/snippets/test1/test1.c index 5fd5938..fbd0f5a 100644 --- a/snippets/test1/test1.c +++ b/snippets/test1/test1.c @@ -131,6 +131,8 @@ void initCounter() { } int main (void) { + static uint32_t lastDiff = 0; + init(); initCounter(); @@ -139,8 +141,10 @@ int main (void) { pthread_cond_wait(&eventSignal, &eventMutex); pthread_mutex_unlock(&eventMutex); - double f = 1.0 / (((double) diff) / 1000000.0); - - printf("%d %d %d %f\n", ec, counter, diff, f); + if (diff != lastDiff) { + lastDiff = diff; + double f = 1.0 / (((double) diff) / 1000000.0); + printf("%d %d %d %f\n", ec, counter, diff, f); + } } } diff --git a/snippets/test2/.gitignore b/snippets/test2/.gitignore new file mode 100644 index 0000000..180cf83 --- /dev/null +++ b/snippets/test2/.gitignore @@ -0,0 +1 @@ +test2 diff --git a/snippets/test2/test2.c b/snippets/test2/test2.c new file mode 100644 index 0000000..4b72c1c --- /dev/null +++ b/snippets/test2/test2.c @@ -0,0 +1,17 @@ +#include +#include + +void main() { + uint8_t s = 25; + uint8_t c = 0; + uint8_t l = 0; + uint8_t d = 0; + + for (uint8_t i = 0; i < 30; i++) { + c += 25; + d = c - l; + printf("%d %d %d %d\n", i, c, l, d); + l = c; + } +} +