-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmartlock.hpp
62 lines (53 loc) · 1.15 KB
/
smartlock.hpp
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
59
60
61
62
/**
* @file smartlock.hpp
* @author Kirill Tregubov (KirillTregubov)
* @author Philip Cai (Gadnalf)
* @copyright Copyright (c) 2022 Kirill Tregubov & Philip Cai
*
* @brief This header defines the class for operating Smart Lock.
* @bug No known bugs.
*/
#ifndef SMARTLOCK_H
#define SMARTLOCK_H
#include "mbed.h"
class SmartLock {
public:
enum lock_state_t { LOCKED, UNLOCKED };
/**
* @brief Construct a new SmartLock object.
*
* @return Instance of SmartLock.
*/
SmartLock(events::EventQueue *event_queue);
/**
* @brief Lock the Smart Lock and update states.
*
* @return Void.
*/
void lock();
/**
* @brief Unlock the Smart Lock and update states.
*
* @return Void.
*/
void unlock();
/**
* @brief Returns true if the SmartLock is unlocked.
*
* @return true if condition holds, false otherwise.
*/
bool is_unlocked();
private:
lock_state_t _lock_state;
EventQueue *_event_queue;
AnalogOut _out_pin;
DigitalOut _led1;
DigitalOut _led2;
/**
* @brief Update the state of the Smart Lock.
*
* @return Void.
*/
void _update_state(lock_state_t new_state);
};
#endif // SMARTLOCK_H