-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_Timing.ino
45 lines (37 loc) · 890 Bytes
/
A_Timing.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Main Loop Timing:
*/
#define MILLITIMING 1
#if MILLITIMING // Millisecond timing:
#define TIMING_FUNCTION millis()
#define TIME_TYPE unsigned int
#define QUICK_MILLIS 0
#define LIMIT_FREQUENCY(v, dt) \
static unsigned long v = 0; \
if((int)(loopStartTime - v) < 0) \
return; \
else \
v = loopStartTime + dt;
#else // Microsecond timing:
#define TIMING_FUNCTION micros()
#define TIME_TYPE unsigned long
#define QUICK_MILLIS 10
#define LIMIT_FREQUENCY(v, dt) \
static unsigned long v = 0; \
if((long)(loopStartTime - v + dt * 1000) < 0) \
return; \
else \
v = loopStartTime + dt * 1000;
#endif
TIME_TYPE loopStartTime;
#if USE_NEOPIXEL_TIME_CORRECTION
unsigned long loopStartCorrection = 0;
TIME_TYPE ledCorrection;
#endif
int blinking(int value)
{
if(bitRead(loopStartTime, (8+QUICK_MILLIS)))
return value;
else
return 0;
}