Skip to content

Commit

Permalink
Update TimerFa.cpp
Browse files Browse the repository at this point in the history
micros overflow proplem
  • Loading branch information
fatihaslamaci authored Aug 22, 2017
1 parent 5cea029 commit 54d60f7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions TimerFa.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
#include <Arduino.h>
#include "TimerFa.h"
#include <limits.h>


bool TimerFa::MicrosaniyedeBir(unsigned long BeklemeSuresi)
{
volatile bool R = false;
volatile unsigned long now = micros();
volatile unsigned long fark = now - BeklemeSuresi;
if (SonOkunanMicrosaniye > now)
{
ArtikSure=ULONG_MAX - SonOkunanMicrosaniye;
SonOkunanMicrosaniye = 0;
}
volatile unsigned long fark = now - BeklemeSuresi-ArtikSure;
if ((SonOkunanMicrosaniye < fark) && (BeklemeSuresi < now))
{
SonOkunanMicrosaniye = now - (now - SonOkunanMicrosaniye - BeklemeSuresi);
SonOkunanMicrosaniye = now - (now - SonOkunanMicrosaniye - BeklemeSuresi)-ArtikSure;
ArtikSure=0;
R = true;
}
return R;

}

void TimerFa::Reset()
{
SonOkunanMicrosaniye=micros();
ArtikSure=0;
}





0 comments on commit 54d60f7

Please sign in to comment.