-
Notifications
You must be signed in to change notification settings - Fork 39
/
sequencer2.cpp
58 lines (46 loc) · 1.24 KB
/
sequencer2.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <sequencer2.h>
Sequencer2::Sequencer2( void (*step1)(), unsigned long time1,
void (*step2)(), unsigned long time2){
t1 = time1;
t2 = time2;
s1func = step1;
s2func = step2;
}
void Sequencer2::set_step1_time(unsigned long time){
t1 = time;
}
void Sequencer2::set_step2_time(unsigned long time){
t2 = time;
}
unsigned long Sequencer2::get_step1_time(){
return t1;
}
unsigned long Sequencer2::get_step2_time(){
return t2;
}
void Sequencer2::reset(){
current_step = STEP1;
next_step_time = 0;
}
void Sequencer2::reset(unsigned long delay){
current_step = STEP1;
next_step_time = millis() + delay;
}
void Sequencer2::run(){
switch (current_step) {
case STEP1:
if (millis() >= next_step_time) {
s1func();
next_step_time = millis() + t1;
current_step = STEP2;
}
break;
case STEP2:
if (millis() >= next_step_time) {
s2func();
next_step_time = millis() + t2;
current_step = STEP1;
}
break;
}
}