-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlock.c
50 lines (43 loc) · 868 Bytes
/
lock.c
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
/* lock.c */
#include "hello.h"
#include "uart.h"
#include "file.h"
#include "menu.h"
bool file_locked;
bool file_locked_request;
void lock_init(void)
{
file_locked = false;
file_locked_request = false;
}
void check_file_lock(void)
{
if (file_locked_request) {
if (file_open) {
stop_display();
}
file_locked = true;
file_locked_request = false;
uart_resume();
}
if (menu != MENU_NONE) {
if (file_open) {
stop_display();
}
}
if (!file_locked && !file_open && (menu == MENU_NONE)) {
start_display();
}
}
/* These functions may be called regardless of whether the lock is held */
void unlock_file(void)
{
file_locked = false;
}
void lock_file(void)
{
if (file_locked)
return;
file_locked_request = true;
uart_pause();
}