-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockPower.h
More file actions
37 lines (33 loc) · 782 Bytes
/
blockPower.h
File metadata and controls
37 lines (33 loc) · 782 Bytes
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
#define _IN_VOLTAGE_PIN 2
#define _IN_DIRECTION_PIN 3
#define _IN_SUPPLY_PIN 4
#define _NOT_D2_PIN 4
#define _NUM_BLOCKS 2
#define _MAX_TRANSIT_TIME 30000
#define _SPEED_CHANGE_RATE 10
class Block {
public:
void init(int);
void setFull();
void setHalf();
void setStop();
void setOccupied();
void setClear();
void check();
private:
void _setSpeed(float); // speed in percentage
int _motorNum;
float _speed = 0.0; // percentage of max
int _prevSpeed = 0;
bool _outState = false;
bool _occupied = false;
long _enterTime = 0;
long _exitTime = 0;
long _transitTime = 0;
long _lastCheckTime = millis();
};
class BlockPowerManager {
public:
static void init();
static void check();
};