Skip to content

Commit d03af8c

Browse files
feat: Pre-commit
1 parent 5b859a7 commit d03af8c

File tree

2 files changed

+154
-163
lines changed

2 files changed

+154
-163
lines changed

Canbus_app/app_user.c

+88-79
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,138 @@
11
#include "app_user.h"
22

33
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+
}
1113
}
1214

1315
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);
1719
}
1820

1921
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);
2325
}
2426

2527
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);
2931
}
3032

3133
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);
4045

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));
4349

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));
4653

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));
5057

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));
5361

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));
5765

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);
6169

62-
app->text = furi_string_alloc();
63-
app->data = furi_string_alloc();
70+
app->text = furi_string_alloc();
71+
app->data = furi_string_alloc();
6472

65-
app->mcp_can = mcp_alloc(MCP_NORMAL, MCP_16MHZ, MCP_500KBPS);
73+
app->mcp_can = mcp_alloc(MCP_NORMAL, MCP_16MHZ, MCP_500KBPS);
6674

67-
app->frameArray = (CANFRAME*)malloc(100 * sizeof(CANFRAME));
75+
app->frameArray = (CANFRAME*) malloc(100 * sizeof(CANFRAME));
6876

69-
app->log_file_path = (char*)malloc(100 * sizeof(char));
77+
app->log_file_path = (char*) malloc(100 * sizeof(char));
7078

71-
app->frame_to_send = malloc(sizeof(CANFRAME));
79+
app->frame_to_send = malloc(sizeof(CANFRAME));
7280

73-
makePaths(app);
81+
makePaths(app);
7482

75-
return app;
83+
return app;
7684
}
7785

7886
static void app_free(App* app) {
79-
furi_assert(app);
87+
furi_assert(app);
8088

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);
8694

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);
8997

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);
94102

95-
furi_string_free(app->text);
96-
furi_string_free(app->data);
103+
furi_string_free(app->text);
104+
furi_string_free(app->data);
97105

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+
}
101109

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);
105113

106-
free(app->log_file_path);
107-
free(app->frameArray);
114+
free(app->log_file_path);
115+
free(app->frameArray);
108116

109-
free(app);
117+
free(app);
110118
}
111119

112120
int app_main(void* p) {
113-
UNUSED(p);
121+
UNUSED(p);
114122

115-
App* app = app_alloc();
123+
App* app = app_alloc();
116124

117-
Gui* gui = furi_record_open(RECORD_GUI);
125+
Gui* gui = furi_record_open(RECORD_GUI);
118126

119-
view_dispatcher_attach_to_gui(app->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
127+
view_dispatcher_attach_to_gui(app->view_dispatcher, gui,
128+
ViewDispatcherTypeFullscreen);
120129

121-
scene_manager_next_scene(app->scene_manager, app_scene_main_menu);
130+
scene_manager_next_scene(app->scene_manager, app_scene_main_menu);
122131

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);
125134

126-
app_free(app);
135+
app_free(app);
127136

128-
return 0;
137+
return 0;
129138
}

Canbus_app/app_user.h

+66-84
Original file line numberDiff line numberDiff line change
@@ -24,115 +24,97 @@
2424
#define DEVICE_NO_CONNECTED (0xFF)
2525

2626
typedef enum {
27-
WorkerflagStop = (1 << 0),
28-
WorkerflagReceived = (1 << 1),
27+
WorkerflagStop = (1 << 0),
28+
WorkerflagReceived = (1 << 1),
2929
} WorkerEvtFlags;
3030

3131
#define WORKER_ALL_RX_EVENTS (WorkerflagStop | WorkerflagReceived)
3232

3333
typedef struct {
34-
MCP2515* mcp_can;
35-
CANFRAME can_frame;
36-
CANFRAME* frameArray;
37-
CANFRAME* frame_to_send;
38-
39-
uint32_t time;
40-
uint32_t times[100];
41-
uint32_t current_time[100];
42-
43-
FuriThread* thread;
44-
SceneManager* scene_manager;
45-
ViewDispatcher* view_dispatcher;
46-
Widget* widget;
47-
Submenu* submenu;
48-
VariableItemList* varList;
49-
TextBox* textBox;
50-
ByteInput* input_byte_value;
51-
52-
FuriString* text;
53-
FuriString* data;
54-
55-
Storage* storage;
56-
DialogsApp* dialogs;
57-
File* log_file;
58-
char* log_file_path;
59-
bool log_file_ready;
60-
uint8_t save_logs;
61-
62-
uint32_t sniffer_index;
63-
uint32_t sniffer_index_aux;
64-
65-
uint8_t num_of_devices;
66-
uint8_t sender_selected_item;
67-
uint8_t sender_id_compose[4];
68-
69-
uint64_t size_of_storage;
34+
MCP2515* mcp_can;
35+
CANFRAME can_frame;
36+
CANFRAME* frameArray;
37+
CANFRAME* frame_to_send;
38+
39+
uint32_t time;
40+
uint32_t times[100];
41+
uint32_t current_time[100];
42+
43+
FuriThread* thread;
44+
SceneManager* scene_manager;
45+
ViewDispatcher* view_dispatcher;
46+
Widget* widget;
47+
Submenu* submenu;
48+
VariableItemList* varList;
49+
TextBox* textBox;
50+
ByteInput* input_byte_value;
51+
52+
FuriString* text;
53+
FuriString* data;
54+
55+
Storage* storage;
56+
DialogsApp* dialogs;
57+
File* log_file;
58+
char* log_file_path;
59+
bool log_file_ready;
60+
uint8_t save_logs;
61+
62+
uint32_t sniffer_index;
63+
uint32_t sniffer_index_aux;
64+
65+
uint8_t num_of_devices;
66+
uint8_t sender_selected_item;
67+
uint8_t sender_id_compose[4];
68+
69+
uint64_t size_of_storage;
7070
} App;
7171

7272
// This is for the menu Options
7373
typedef enum {
74-
SniffingTestOption,
75-
SenderOption,
76-
ReadLOGOption,
77-
SettingsOption,
78-
AboutUsOption,
74+
SniffingTestOption,
75+
SenderOption,
76+
ReadLOGOption,
77+
SettingsOption,
78+
AboutUsOption,
7979
} MainMenuOptions;
8080

8181
typedef enum {
82-
SniffingOptionEvent,
83-
SenderOptionEvent,
84-
SettingsOptionEvent,
85-
ReadLOGOptionEvent,
86-
AboutUsEvent,
82+
SniffingOptionEvent,
83+
SenderOptionEvent,
84+
SettingsOptionEvent,
85+
ReadLOGOptionEvent,
86+
AboutUsEvent,
8787
} MainMenuEvents;
8888

8989
// This is for the Setting Options
9090
typedef enum {
91-
BitrateOption,
92-
CristyalClkOption,
93-
SaveLogsOption
91+
BitrateOption,
92+
CristyalClkOption,
93+
SaveLogsOption
9494
} OptionSettings;
95-
typedef enum {
96-
BitrateOptionEvent,
97-
CristyalClkOptionEvent
98-
} SettingsMenuEvent;
99-
typedef enum {
100-
ChooseIdEvent,
101-
SetIdEvent,
102-
ReturnEvent
103-
} SenderEvents;
95+
typedef enum { BitrateOptionEvent, CristyalClkOptionEvent } SettingsMenuEvent;
96+
typedef enum { ChooseIdEvent, SetIdEvent, ReturnEvent } SenderEvents;
10497

10598
// These are the options to save
106-
typedef enum {
107-
NoSave,
108-
SaveAll,
109-
OnlyAddress
110-
} SaveOptions;
99+
typedef enum { NoSave, SaveAll, OnlyAddress } SaveOptions;
111100

112101
// This is for SniffingTest Options
113-
typedef enum {
114-
RefreshTest,
115-
EntryEvent,
116-
ShowData
117-
} SniffingTestEvents;
102+
typedef enum { RefreshTest, EntryEvent, ShowData } SniffingTestEvents;
118103

119104
// These are the events in AboutOption
120-
typedef enum {
121-
ButtonGetPressed
122-
} ButtonPressedEvent;
105+
typedef enum { ButtonGetPressed } ButtonPressedEvent;
123106

124107
// Views in the App
125108
typedef enum {
126-
SubmenuView,
127-
ViewWidget,
128-
VarListView,
129-
TextBoxView,
130-
DialogInfoView,
131-
InputByteView,
109+
SubmenuView,
110+
ViewWidget,
111+
VarListView,
112+
TextBoxView,
113+
DialogInfoView,
114+
InputByteView,
132115
} scenesViews;
133116

134-
char* sequential_file_resolve_path(
135-
Storage* storage,
136-
const char* dir,
137-
const char* prefix,
138-
const char* extension);
117+
char* sequential_file_resolve_path(Storage* storage,
118+
const char* dir,
119+
const char* prefix,
120+
const char* extension);

0 commit comments

Comments
 (0)