-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animation.h
43 lines (35 loc) · 1.32 KB
/
Animation.h
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
// helpful: https://learn.adafruit.com/multi-tasking-the-arduino-part-3/using-neopatterns
#include "Arduino.h"
#include "Enums.h"
#ifndef Animation_h
#define Animation_h
#define INDICATOR_LEFT_STEPS 8
#define INDICATOR_RIGHT_STEPS 4
#define INDICATOR_WARNING_STEPS 2
#define SIRENS_STEPS 24
typedef void (*updateFunction)(unsigned long, unsigned long, int, bool); // elapsed, duration, step, stop
class Animation
{
public:
Animation();
void play(AnimationType animationType);
void update();
void stop();
static int step(long elapsed_time, long duration, int value) {
return (elapsed_time % duration) * value / duration;
}
private:
void setAnimation(unsigned long duration, bool loopAnimation, updateFunction function, int steps);
updateFunction _update;
unsigned long _start; //ms
unsigned long _duration; //ms
int _steps;
int _lastStep;
bool _loop;
bool _alive;
};
void animate_indicator_left(unsigned long elapsed_time, unsigned long duration, int step, bool stop);
void animate_indicator_right(unsigned long elapsed_time, unsigned long duration, int step, bool stop);
void animate_indicator_warning(unsigned long elapsed_time, unsigned long duration, int step, bool stop);
void animate_sirens(unsigned long elapsed_time, unsigned long duration, int step, bool stop);
#endif