Sat, 20 Oct 2018 17:09:48 +0200
Updated lots of doxygen comments
0 | 1 | /** |
2 | * @file files.c | |
3 | * @brief Files management. | |
4 | */ | |
5 | ||
6 | #include "config.h" | |
7 | ||
8 | ||
9 | extern sButton Buttons[MAXBUTTONS]; | |
10 | extern int Main_Screen; | |
11 | ||
12 | ||
13 | ||
1
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
14 | /** |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
15 | * @brief Show files directory |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
16 | * @param path The path from which to list |
ad2c8b13eb88
Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
17 | */ |
0 | 18 | void Files_Dir(char *path) |
19 | { | |
20 | char filename[256], tmp[42]; | |
21 | uint16_t y = 28; | |
22 | DIR *dir; | |
23 | struct dirent *de; | |
24 | struct stat st; | |
25 | ||
26 | _bg = TFT_BLACK; | |
27 | TFT_fillScreen(_bg); | |
28 | TopMessage(path); | |
29 | _fg = TFT_WHITE; | |
30 | TFT_setFont(DEFAULT_FONT, NULL); | |
31 | ||
32 | if ((dir = opendir(path))) { | |
33 | de = readdir(dir); | |
34 | while (de) { | |
35 | TFT_print(de->d_name, 2, y); | |
36 | sprintf(filename, "%s/%s", path, de->d_name); | |
37 | if (stat(filename, &st) == 0) { | |
38 | sprintf(tmp, "%ld", st.st_size); | |
39 | TFT_print(tmp, RIGHT, y); | |
40 | } | |
41 | de = readdir(dir); | |
42 | y += 16; | |
43 | } | |
44 | closedir(dir); | |
45 | } | |
46 | ||
47 | Buttons_Add(130, 200, 60, 40, "Ok", 0); | |
48 | Buttons[0].dark = true; | |
49 | Buttons_Show(); | |
50 | ||
51 | while (true) { | |
52 | if (Buttons_Scan() == 0) { | |
53 | Buttons_Clear(); | |
54 | return; | |
55 | } | |
56 | vTaskDelay(50 / portTICK_PERIOD_MS); | |
57 | } | |
58 | } | |
59 | ||
60 | ||
61 | ||
62 | /* | |
63 | * Files init function, only runs once a new screen is entered. | |
64 | */ | |
65 | void Files_Init(void) | |
66 | { | |
67 | switch (Main_Screen) { | |
68 | case MAIN_TOOLS_FILES: | |
69 | break; | |
70 | ||
71 | default: break; | |
72 | } | |
73 | } | |
74 | ||
75 | ||
76 | ||
77 | /* | |
78 | * Recipes management loop, non-blocking. | |
79 | */ | |
80 | void Files_Loop(void) | |
81 | { | |
82 | switch (Main_Screen) { | |
83 | ||
84 | case MAIN_TOOLS_FILES: | |
85 | Files_Dir("/sdcard/recipe"); | |
86 | Files_Dir("/sdcard/w/log"); | |
87 | Main_Screen = MAIN_TOOLS; | |
88 | break; | |
89 | ||
90 | default: break; | |
91 | } | |
92 | } | |
93 | ||
94 |