-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloors.h
45 lines (34 loc) · 1.23 KB
/
floors.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
#include <stdbool.h>
#include "elev.h"
// Current floor indicator
typedef enum floor_num {
UNDEFINED = -1, // Unknown floor, only used on startup
FLOOR_1 = 0,
FLOOR_2 = 1,
FLOOR_3 = 2,
FLOOR_4 = 3
} floor_num;
// Main floor struct, containing the current order status of each type
typedef struct floor {
bool upOrder;
bool downOrder;
bool innerOrder;
} floor;
// Update floor structs by reading button status
void updateFloorStatus(floor *floors);
// Update current floor by reading sensor status, return true if floor was changed
bool updateCurrentFloor(floor_num *current);
// Update button lights by reading from floor structs
void updateLights(floor *floors);
// Update floor with current floor
void updateFloorLight(floor_num current);
// Return status of the emergency stop button
bool getStopButton();
// Set the door open status
void setDoorOpen(bool status);
// Return true if there are orders at any floors in the given direction
bool hasOrdersInDir(floor_num current, floor *floors, elev_motor_direction_t dir);
// Return true if floor at index has any orders at all.
bool hasOrders(floor *floors, floor_num index);
// Clears all orders from floor at index
void clearOrders(floor *floors, floor_num index);