-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
105 lines (90 loc) · 2.66 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "extapp_api.h"
#include "inc/peripherals.h"
#include "inc/screens.h"
#include "inc/logic.h"
//variable to know the current screen
int current_screen = 0; // "Option" = 0, "Drawing" = 1, "Files" = 2, "Tutorial" = 3, "About" = 4
void extapp_main(void) {
int Option = 0; // 0 = New Drawing, 1 = Open Files, 2 = Tutorial, 3 = About, 4 = Quit
blank_page(0x0E88);
optionScreen(Option, 1, 1);
extapp_msleep(200);
while (true) {
extapp_msleep(200);
if (exit_app() == 1) {
return;
}
while (true) {
if (exit_app() == 1) {
return;
}
if (extapp_isKeydown(KEY_CTRL_OK) || extapp_isKeydown(52)){
break;
}
extapp_msleep(200);
if (extapp_isKeydown(KEY_CTRL_UP)) {
Option -= 1;
if (Option < 0) Option = 0;
optionScreen(Option, Option + 1, 0);
}
else if (extapp_isKeydown(KEY_CTRL_DOWN)) {
Option += 1;
if (Option > 4) Option = 4;
optionScreen(Option, Option - 1, 0);
}
}
if (Option == 0){
// New Drawing
Drawing(1);
}
if (Option == 1){
// Open Files
Files();
}
if (Option == 2) {
// Tutorial
current_screen = Tutorial();
extapp_msleep(500);
while (current_screen == 3) {
if (exit_app() == 1) {
break;
}
if (extapp_isKeydown(KEY_CTRL_OK) ||
extapp_isKeydown(52)) {
current_screen = 0;
}
}
if (current_screen == 0) {
// Display option menu again
optionScreen(Option, Option + 1, 1);
}
extapp_msleep(500);
}
if (Option == 3){
// Tutorial
current_screen = About();
extapp_msleep(500);
while (current_screen == 4) {
if (exit_app() == 1) {
break;
}
if (extapp_isKeydown(KEY_CTRL_OK) ||
extapp_isKeydown(52)) {
current_screen = 0;
}
}
if (current_screen == 0) {
// Display option menu again
optionScreen(Option, Option + 1, 1);
}
extapp_msleep(500);
}
if (Option == 4){
// Quit
return;
}
}
}