Browse Source

Account for millis() overflow after 50 days.

Robert Marshall 5 years ago
parent
commit
64db43eb82
2 changed files with 2 additions and 3 deletions
  1. 1 2
      Transmitter/src/Motion.cpp
  2. 1 1
      Transmitter/src/Timer.cpp

+ 1 - 2
Transmitter/src/Motion.cpp

@@ -39,8 +39,7 @@ public:
 			_currentMotionState = motionDetected;
 		}
 		
-
-		if (_currentMotionState && millis() >= _motionDetectedTime + _triggerDuration){
+		if (_currentMotionState && millis() - _motionDetectedTime >= _triggerDuration){
 			_stopCallback();
 			_currentMotionState = false;
 		}

+ 1 - 1
Transmitter/src/Timer.cpp

@@ -15,7 +15,7 @@ public:
 	void loop(){
 		unsigned long tick = millis();
 
-		if (tick >= _lastTick + _interval){
+		if (tick - _lastTick >= _interval){
 			_callback();
 			_lastTick = tick;
 		}