|
1 | 1 | #include "app_user.h"
|
2 | 2 |
|
3 | 3 | void makePaths(App* app) {
|
4 |
| - furi_assert(app); |
5 |
| - if(!storage_simply_mkdir(app->storage, PATHAPPEXT)) { |
6 |
| - dialog_message_show_storage_error(app->dialogs, "Cannot create\napp folder"); |
7 |
| - } |
8 |
| - if(!storage_simply_mkdir(app->storage, PATHLOGS)) { |
9 |
| - dialog_message_show_storage_error(app->dialogs, "Cannot create\nlogs folder"); |
10 |
| - } |
| 4 | + furi_assert(app); |
| 5 | + if (!storage_simply_mkdir(app->storage, PATHAPPEXT)) { |
| 6 | + dialog_message_show_storage_error(app->dialogs, |
| 7 | + "Cannot create\napp folder"); |
| 8 | + } |
| 9 | + if (!storage_simply_mkdir(app->storage, PATHLOGS)) { |
| 10 | + dialog_message_show_storage_error(app->dialogs, |
| 11 | + "Cannot create\nlogs folder"); |
| 12 | + } |
11 | 13 | }
|
12 | 14 |
|
13 | 15 | static bool app_scene_costum_callback(void* context, uint32_t costum_event) {
|
14 |
| - furi_assert(context); |
15 |
| - App* app = context; |
16 |
| - return scene_manager_handle_custom_event(app->scene_manager, costum_event); |
| 16 | + furi_assert(context); |
| 17 | + App* app = context; |
| 18 | + return scene_manager_handle_custom_event(app->scene_manager, costum_event); |
17 | 19 | }
|
18 | 20 |
|
19 | 21 | static bool app_scene_back_event(void* context) {
|
20 |
| - furi_assert(context); |
21 |
| - App* app = context; |
22 |
| - return scene_manager_handle_back_event(app->scene_manager); |
| 22 | + furi_assert(context); |
| 23 | + App* app = context; |
| 24 | + return scene_manager_handle_back_event(app->scene_manager); |
23 | 25 | }
|
24 | 26 |
|
25 | 27 | static void app_tick_event(void* context) {
|
26 |
| - furi_assert(context); |
27 |
| - App* app = context; |
28 |
| - UNUSED(app); |
| 28 | + furi_assert(context); |
| 29 | + App* app = context; |
| 30 | + UNUSED(app); |
29 | 31 | }
|
30 | 32 |
|
31 | 33 | static App* app_alloc() {
|
32 |
| - App* app = malloc(sizeof(App)); |
33 |
| - app->scene_manager = scene_manager_alloc(&app_scene_handlers, app); |
34 |
| - app->view_dispatcher = view_dispatcher_alloc(); |
35 |
| - view_dispatcher_enable_queue(app->view_dispatcher); |
36 |
| - view_dispatcher_set_custom_event_callback(app->view_dispatcher, app_scene_costum_callback); |
37 |
| - view_dispatcher_set_event_callback_context(app->view_dispatcher, app); |
38 |
| - view_dispatcher_set_navigation_event_callback(app->view_dispatcher, app_scene_back_event); |
39 |
| - view_dispatcher_set_tick_event_callback(app->view_dispatcher, app_tick_event, 100); |
| 34 | + App* app = malloc(sizeof(App)); |
| 35 | + app->scene_manager = scene_manager_alloc(&app_scene_handlers, app); |
| 36 | + app->view_dispatcher = view_dispatcher_alloc(); |
| 37 | + view_dispatcher_enable_queue(app->view_dispatcher); |
| 38 | + view_dispatcher_set_custom_event_callback(app->view_dispatcher, |
| 39 | + app_scene_costum_callback); |
| 40 | + view_dispatcher_set_event_callback_context(app->view_dispatcher, app); |
| 41 | + view_dispatcher_set_navigation_event_callback(app->view_dispatcher, |
| 42 | + app_scene_back_event); |
| 43 | + view_dispatcher_set_tick_event_callback(app->view_dispatcher, app_tick_event, |
| 44 | + 100); |
40 | 45 |
|
41 |
| - app->widget = widget_alloc(); |
42 |
| - view_dispatcher_add_view(app->view_dispatcher, ViewWidget, widget_get_view(app->widget)); |
| 46 | + app->widget = widget_alloc(); |
| 47 | + view_dispatcher_add_view(app->view_dispatcher, ViewWidget, |
| 48 | + widget_get_view(app->widget)); |
43 | 49 |
|
44 |
| - app->submenu = submenu_alloc(); |
45 |
| - view_dispatcher_add_view(app->view_dispatcher, SubmenuView, submenu_get_view(app->submenu)); |
| 50 | + app->submenu = submenu_alloc(); |
| 51 | + view_dispatcher_add_view(app->view_dispatcher, SubmenuView, |
| 52 | + submenu_get_view(app->submenu)); |
46 | 53 |
|
47 |
| - app->varList = variable_item_list_alloc(); |
48 |
| - view_dispatcher_add_view( |
49 |
| - app->view_dispatcher, VarListView, variable_item_list_get_view(app->varList)); |
| 54 | + app->varList = variable_item_list_alloc(); |
| 55 | + view_dispatcher_add_view(app->view_dispatcher, VarListView, |
| 56 | + variable_item_list_get_view(app->varList)); |
50 | 57 |
|
51 |
| - app->textBox = text_box_alloc(); |
52 |
| - view_dispatcher_add_view(app->view_dispatcher, TextBoxView, text_box_get_view(app->textBox)); |
| 58 | + app->textBox = text_box_alloc(); |
| 59 | + view_dispatcher_add_view(app->view_dispatcher, TextBoxView, |
| 60 | + text_box_get_view(app->textBox)); |
53 | 61 |
|
54 |
| - app->input_byte_value = byte_input_alloc(); |
55 |
| - view_dispatcher_add_view( |
56 |
| - app->view_dispatcher, InputByteView, byte_input_get_view(app->input_byte_value)); |
| 62 | + app->input_byte_value = byte_input_alloc(); |
| 63 | + view_dispatcher_add_view(app->view_dispatcher, InputByteView, |
| 64 | + byte_input_get_view(app->input_byte_value)); |
57 | 65 |
|
58 |
| - app->dialogs = furi_record_open(RECORD_DIALOGS); |
59 |
| - app->storage = furi_record_open(RECORD_STORAGE); |
60 |
| - app->log_file = storage_file_alloc(app->storage); |
| 66 | + app->dialogs = furi_record_open(RECORD_DIALOGS); |
| 67 | + app->storage = furi_record_open(RECORD_STORAGE); |
| 68 | + app->log_file = storage_file_alloc(app->storage); |
61 | 69 |
|
62 |
| - app->text = furi_string_alloc(); |
63 |
| - app->data = furi_string_alloc(); |
| 70 | + app->text = furi_string_alloc(); |
| 71 | + app->data = furi_string_alloc(); |
64 | 72 |
|
65 |
| - app->mcp_can = mcp_alloc(MCP_NORMAL, MCP_16MHZ, MCP_500KBPS); |
| 73 | + app->mcp_can = mcp_alloc(MCP_NORMAL, MCP_16MHZ, MCP_500KBPS); |
66 | 74 |
|
67 |
| - app->frameArray = (CANFRAME*)malloc(100 * sizeof(CANFRAME)); |
| 75 | + app->frameArray = (CANFRAME*) malloc(100 * sizeof(CANFRAME)); |
68 | 76 |
|
69 |
| - app->log_file_path = (char*)malloc(100 * sizeof(char)); |
| 77 | + app->log_file_path = (char*) malloc(100 * sizeof(char)); |
70 | 78 |
|
71 |
| - app->frame_to_send = malloc(sizeof(CANFRAME)); |
| 79 | + app->frame_to_send = malloc(sizeof(CANFRAME)); |
72 | 80 |
|
73 |
| - makePaths(app); |
| 81 | + makePaths(app); |
74 | 82 |
|
75 |
| - return app; |
| 83 | + return app; |
76 | 84 | }
|
77 | 85 |
|
78 | 86 | static void app_free(App* app) {
|
79 |
| - furi_assert(app); |
| 87 | + furi_assert(app); |
80 | 88 |
|
81 |
| - view_dispatcher_remove_view(app->view_dispatcher, SubmenuView); |
82 |
| - view_dispatcher_remove_view(app->view_dispatcher, ViewWidget); |
83 |
| - view_dispatcher_remove_view(app->view_dispatcher, TextBoxView); |
84 |
| - view_dispatcher_remove_view(app->view_dispatcher, VarListView); |
85 |
| - view_dispatcher_remove_view(app->view_dispatcher, InputByteView); |
| 89 | + view_dispatcher_remove_view(app->view_dispatcher, SubmenuView); |
| 90 | + view_dispatcher_remove_view(app->view_dispatcher, ViewWidget); |
| 91 | + view_dispatcher_remove_view(app->view_dispatcher, TextBoxView); |
| 92 | + view_dispatcher_remove_view(app->view_dispatcher, VarListView); |
| 93 | + view_dispatcher_remove_view(app->view_dispatcher, InputByteView); |
86 | 94 |
|
87 |
| - scene_manager_free(app->scene_manager); |
88 |
| - view_dispatcher_free(app->view_dispatcher); |
| 95 | + scene_manager_free(app->scene_manager); |
| 96 | + view_dispatcher_free(app->view_dispatcher); |
89 | 97 |
|
90 |
| - widget_free(app->widget); |
91 |
| - submenu_free(app->submenu); |
92 |
| - text_box_free(app->textBox); |
93 |
| - byte_input_free(app->input_byte_value); |
| 98 | + widget_free(app->widget); |
| 99 | + submenu_free(app->submenu); |
| 100 | + text_box_free(app->textBox); |
| 101 | + byte_input_free(app->input_byte_value); |
94 | 102 |
|
95 |
| - furi_string_free(app->text); |
96 |
| - furi_string_free(app->data); |
| 103 | + furi_string_free(app->text); |
| 104 | + furi_string_free(app->data); |
97 | 105 |
|
98 |
| - if(app->log_file && storage_file_is_open(app->log_file)) { |
99 |
| - storage_file_close(app->log_file); |
100 |
| - } |
| 106 | + if (app->log_file && storage_file_is_open(app->log_file)) { |
| 107 | + storage_file_close(app->log_file); |
| 108 | + } |
101 | 109 |
|
102 |
| - storage_file_free(app->log_file); |
103 |
| - furi_record_close(RECORD_STORAGE); |
104 |
| - furi_record_close(RECORD_DIALOGS); |
| 110 | + storage_file_free(app->log_file); |
| 111 | + furi_record_close(RECORD_STORAGE); |
| 112 | + furi_record_close(RECORD_DIALOGS); |
105 | 113 |
|
106 |
| - free(app->log_file_path); |
107 |
| - free(app->frameArray); |
| 114 | + free(app->log_file_path); |
| 115 | + free(app->frameArray); |
108 | 116 |
|
109 |
| - free(app); |
| 117 | + free(app); |
110 | 118 | }
|
111 | 119 |
|
112 | 120 | int app_main(void* p) {
|
113 |
| - UNUSED(p); |
| 121 | + UNUSED(p); |
114 | 122 |
|
115 |
| - App* app = app_alloc(); |
| 123 | + App* app = app_alloc(); |
116 | 124 |
|
117 |
| - Gui* gui = furi_record_open(RECORD_GUI); |
| 125 | + Gui* gui = furi_record_open(RECORD_GUI); |
118 | 126 |
|
119 |
| - view_dispatcher_attach_to_gui(app->view_dispatcher, gui, ViewDispatcherTypeFullscreen); |
| 127 | + view_dispatcher_attach_to_gui(app->view_dispatcher, gui, |
| 128 | + ViewDispatcherTypeFullscreen); |
120 | 129 |
|
121 |
| - scene_manager_next_scene(app->scene_manager, app_scene_main_menu); |
| 130 | + scene_manager_next_scene(app->scene_manager, app_scene_main_menu); |
122 | 131 |
|
123 |
| - view_dispatcher_run(app->view_dispatcher); |
124 |
| - furi_record_close(RECORD_GUI); |
| 132 | + view_dispatcher_run(app->view_dispatcher); |
| 133 | + furi_record_close(RECORD_GUI); |
125 | 134 |
|
126 |
| - app_free(app); |
| 135 | + app_free(app); |
127 | 136 |
|
128 |
| - return 0; |
| 137 | + return 0; |
129 | 138 | }
|
0 commit comments