Skip to content

Commit dc7cd6f

Browse files
committed
Move apps from flipperzero firmware into separate repository
0 parents  commit dc7cd6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5718
-0
lines changed

application.fam

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
App(
2+
appid="avr_isp",
3+
name="AVR Flasher",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="avr_isp_app",
6+
requires=["gui"],
7+
stack_size=4 * 1024,
8+
order=20,
9+
fap_icon="avr_app_icon_10x10.png",
10+
fap_category="GPIO",
11+
fap_icon_assets="images",
12+
fap_private_libs=[
13+
Lib(
14+
name="driver",
15+
),
16+
],
17+
)

avr_app_icon_10x10.png

3.53 KB
Loading

avr_isp_app.c

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#include "avr_isp_app_i.h"
2+
3+
static bool avr_isp_app_custom_event_callback(void* context, uint32_t event) {
4+
furi_assert(context);
5+
AvrIspApp* app = context;
6+
return scene_manager_handle_custom_event(app->scene_manager, event);
7+
}
8+
9+
static bool avr_isp_app_back_event_callback(void* context) {
10+
furi_assert(context);
11+
AvrIspApp* app = context;
12+
return scene_manager_handle_back_event(app->scene_manager);
13+
}
14+
15+
static void avr_isp_app_tick_event_callback(void* context) {
16+
furi_assert(context);
17+
AvrIspApp* app = context;
18+
scene_manager_handle_tick_event(app->scene_manager);
19+
}
20+
21+
AvrIspApp* avr_isp_app_alloc() {
22+
AvrIspApp* app = malloc(sizeof(AvrIspApp));
23+
24+
app->file_path = furi_string_alloc();
25+
furi_string_set(app->file_path, STORAGE_APP_DATA_PATH_PREFIX);
26+
app->error = AvrIspErrorNoError;
27+
28+
// GUI
29+
app->gui = furi_record_open(RECORD_GUI);
30+
31+
// View Dispatcher
32+
app->view_dispatcher = view_dispatcher_alloc();
33+
app->scene_manager = scene_manager_alloc(&avr_isp_scene_handlers, app);
34+
view_dispatcher_enable_queue(app->view_dispatcher);
35+
36+
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
37+
view_dispatcher_set_custom_event_callback(
38+
app->view_dispatcher, avr_isp_app_custom_event_callback);
39+
view_dispatcher_set_navigation_event_callback(
40+
app->view_dispatcher, avr_isp_app_back_event_callback);
41+
view_dispatcher_set_tick_event_callback(
42+
app->view_dispatcher, avr_isp_app_tick_event_callback, 100);
43+
44+
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
45+
46+
// Open Notification record
47+
app->notifications = furi_record_open(RECORD_NOTIFICATION);
48+
49+
// SubMenu
50+
app->submenu = submenu_alloc();
51+
view_dispatcher_add_view(
52+
app->view_dispatcher, AvrIspViewSubmenu, submenu_get_view(app->submenu));
53+
54+
// Widget
55+
app->widget = widget_alloc();
56+
view_dispatcher_add_view(app->view_dispatcher, AvrIspViewWidget, widget_get_view(app->widget));
57+
58+
// Text Input
59+
app->text_input = text_input_alloc();
60+
view_dispatcher_add_view(
61+
app->view_dispatcher, AvrIspViewTextInput, text_input_get_view(app->text_input));
62+
63+
// Popup
64+
app->popup = popup_alloc();
65+
view_dispatcher_add_view(app->view_dispatcher, AvrIspViewPopup, popup_get_view(app->popup));
66+
67+
//Dialog
68+
app->dialogs = furi_record_open(RECORD_DIALOGS);
69+
70+
// Programmer view
71+
app->avr_isp_programmer_view = avr_isp_programmer_view_alloc();
72+
view_dispatcher_add_view(
73+
app->view_dispatcher,
74+
AvrIspViewProgrammer,
75+
avr_isp_programmer_view_get_view(app->avr_isp_programmer_view));
76+
77+
// Reader view
78+
app->avr_isp_reader_view = avr_isp_reader_view_alloc();
79+
view_dispatcher_add_view(
80+
app->view_dispatcher,
81+
AvrIspViewReader,
82+
avr_isp_reader_view_get_view(app->avr_isp_reader_view));
83+
84+
// Writer view
85+
app->avr_isp_writer_view = avr_isp_writer_view_alloc();
86+
view_dispatcher_add_view(
87+
app->view_dispatcher,
88+
AvrIspViewWriter,
89+
avr_isp_writer_view_get_view(app->avr_isp_writer_view));
90+
91+
// Chip detect view
92+
app->avr_isp_chip_detect_view = avr_isp_chip_detect_view_alloc();
93+
view_dispatcher_add_view(
94+
app->view_dispatcher,
95+
AvrIspViewChipDetect,
96+
avr_isp_chip_detect_view_get_view(app->avr_isp_chip_detect_view));
97+
98+
// Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering
99+
uint8_t attempts = 0;
100+
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
101+
furi_hal_power_enable_otg();
102+
furi_delay_ms(10);
103+
}
104+
105+
scene_manager_next_scene(app->scene_manager, AvrIspSceneStart);
106+
107+
return app;
108+
} //-V773
109+
110+
void avr_isp_app_free(AvrIspApp* app) {
111+
furi_assert(app);
112+
113+
// Disable 5v power
114+
if(furi_hal_power_is_otg_enabled()) {
115+
furi_hal_power_disable_otg();
116+
}
117+
118+
// Submenu
119+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewSubmenu);
120+
submenu_free(app->submenu);
121+
122+
// Widget
123+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewWidget);
124+
widget_free(app->widget);
125+
126+
// TextInput
127+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewTextInput);
128+
text_input_free(app->text_input);
129+
130+
// Popup
131+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewPopup);
132+
popup_free(app->popup);
133+
134+
//Dialog
135+
furi_record_close(RECORD_DIALOGS);
136+
137+
// Programmer view
138+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewProgrammer);
139+
avr_isp_programmer_view_free(app->avr_isp_programmer_view);
140+
141+
// Reader view
142+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewReader);
143+
avr_isp_reader_view_free(app->avr_isp_reader_view);
144+
145+
// Writer view
146+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewWriter);
147+
avr_isp_writer_view_free(app->avr_isp_writer_view);
148+
149+
// Chip detect view
150+
view_dispatcher_remove_view(app->view_dispatcher, AvrIspViewChipDetect);
151+
avr_isp_chip_detect_view_free(app->avr_isp_chip_detect_view);
152+
153+
// View dispatcher
154+
view_dispatcher_free(app->view_dispatcher);
155+
scene_manager_free(app->scene_manager);
156+
157+
// Notifications
158+
furi_record_close(RECORD_NOTIFICATION);
159+
app->notifications = NULL;
160+
161+
// Close records
162+
furi_record_close(RECORD_GUI);
163+
164+
// Path strings
165+
furi_string_free(app->file_path);
166+
167+
free(app);
168+
}
169+
170+
int32_t avr_isp_app(void* p) {
171+
UNUSED(p);
172+
AvrIspApp* avr_isp_app = avr_isp_app_alloc();
173+
174+
view_dispatcher_run(avr_isp_app->view_dispatcher);
175+
176+
avr_isp_app_free(avr_isp_app);
177+
178+
return 0;
179+
}

avr_isp_app_i.c

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "avr_isp_app_i.h"
2+
#include <lib/toolbox/path.h>
3+
#include <flipper_format/flipper_format_i.h>
4+
5+
#define TAG "AvrIsp"
6+
7+
bool avr_isp_load_from_file(AvrIspApp* app) {
8+
furi_assert(app);
9+
10+
FuriString* file_path = furi_string_alloc();
11+
FuriString* file_name = furi_string_alloc();
12+
13+
DialogsFileBrowserOptions browser_options;
14+
dialog_file_browser_set_basic_options(
15+
&browser_options, AVR_ISP_APP_EXTENSION, &I_avr_app_icon_10x10);
16+
browser_options.base_path = STORAGE_APP_DATA_PATH_PREFIX;
17+
18+
// Input events and views are managed by file_select
19+
bool res = dialog_file_browser_show(app->dialogs, file_path, app->file_path, &browser_options);
20+
21+
if(res) {
22+
path_extract_dirname(furi_string_get_cstr(file_path), app->file_path);
23+
path_extract_filename(file_path, file_name, true);
24+
strncpy(app->file_name_tmp, furi_string_get_cstr(file_name), AVR_ISP_MAX_LEN_NAME);
25+
}
26+
27+
furi_string_free(file_name);
28+
furi_string_free(file_path);
29+
30+
return res;
31+
}

avr_isp_app_i.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#pragma once
2+
3+
#include "helpers/avr_isp_types.h"
4+
#include <avr_isp_icons.h>
5+
6+
#include "scenes/avr_isp_scene.h"
7+
#include <gui/gui.h>
8+
#include <gui/view_dispatcher.h>
9+
#include <gui/scene_manager.h>
10+
#include <gui/modules/submenu.h>
11+
#include <gui/modules/widget.h>
12+
#include <notification/notification_messages.h>
13+
#include <gui/modules/text_input.h>
14+
#include <dialogs/dialogs.h>
15+
#include <storage/storage.h>
16+
#include <gui/modules/popup.h>
17+
18+
#include "views/avr_isp_view_programmer.h"
19+
#include "views/avr_isp_view_reader.h"
20+
#include "views/avr_isp_view_writer.h"
21+
#include "views/avr_isp_view_chip_detect.h"
22+
23+
#define AVR_ISP_MAX_LEN_NAME 64
24+
25+
typedef struct {
26+
Gui* gui;
27+
ViewDispatcher* view_dispatcher;
28+
SceneManager* scene_manager;
29+
NotificationApp* notifications;
30+
DialogsApp* dialogs;
31+
Popup* popup;
32+
Submenu* submenu;
33+
Widget* widget;
34+
TextInput* text_input;
35+
FuriString* file_path;
36+
char file_name_tmp[AVR_ISP_MAX_LEN_NAME];
37+
AvrIspProgrammerView* avr_isp_programmer_view;
38+
AvrIspReaderView* avr_isp_reader_view;
39+
AvrIspWriterView* avr_isp_writer_view;
40+
AvrIspChipDetectView* avr_isp_chip_detect_view;
41+
AvrIspError error;
42+
} AvrIspApp;
43+
44+
bool avr_isp_load_from_file(AvrIspApp* app);

0 commit comments

Comments
 (0)