From 643778a27c85f3e69ba4b670c6862163164fcfae Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Tue, 10 May 2016 21:02:35 +0200 Subject: [PATCH] =?UTF-8?q?=C3=9Cberlaufbehandlung=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- status/status.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/status/status.ino b/status/status.ino index f1d8ef3..66ffc78 100644 --- a/status/status.ino +++ b/status/status.ino @@ -129,11 +129,12 @@ void sendState() { unsigned long calcStateTime() { // Variablen überlauf von millis erkennen - if (millis() - stateBegan >= 0) { - return millis() - stateBegan; - } else { - return millis() + (ULONG_MAX - stateBegan); + unsigned long current_uptime = millis(); + // kein überlauf + if (current_uptime > stateBegan) { + return current_uptime - stateBegan; } + return current_uptime + (ULONG_MAX - stateBegan); } // wird nach dem Starten dauerhaft ausgeführt