-
Notifications
You must be signed in to change notification settings - Fork 1
/
Async_Operations.h
50 lines (46 loc) · 1.39 KB
/
Async_Operations.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
44
45
46
47
48
49
50
/*
* Async_Operations.h library for running time-consuming tasks without blocking the main thread
* Created by Dániel Földi (05. August 2020)
*/
#ifndef Async_Operations_Header
#define Async_Operations_Header
#include "Arduino.h"
class Async_Operations {
public:
Async_Operations(long long *steps, int stepCount);
Async_Operations(long long *steps, int stepCount, int repeat);
Async_Operations(long long *steps, int stepCount, int repeat, int pin);
Async_Operations(long long *steps, int stepCount, int repeat, int pin, bool initialState);
Async_Operations(long long *steps, int stepCount, int repeat, int pin, bool initialState, bool endState);
void start();
void restart();
void stop();
void pause();
void play();
bool getPaused();
bool getRunning();
int getRepeatCount();
bool getState();
void update();
void setStateChangeCallback(void (*stateChangeCallback)(void));
void deleteStateChangeCallback();
void setLoopCallback(void (*loopCallback)(void));
void deleteLoopCallback();
private:
long long *steps;
int stepCount;
int step;
int pin;
bool running;
long long startTime;
long long lastUpdate;
long long remaining;
bool state;
bool initialState;
bool endState;
int repeat;
int initialRepeat;
void (*stateChangeCallback)(void);
void (*loopCallback)(void);
};
#endif