1
+ #include "dtmf_dolphin_i.h"
2
+
3
+ #include <furi.h>
4
+ #include <furi_hal.h>
5
+
6
+ static bool dtmf_dolphin_app_custom_event_callback (void * context , uint32_t event ) {
7
+ furi_assert (context );
8
+ DTMFDolphinApp * app = context ;
9
+ return scene_manager_handle_custom_event (app -> scene_manager , event );
10
+ }
11
+
12
+ static bool dtmf_dolphin_app_back_event_callback (void * context ) {
13
+ furi_assert (context );
14
+ DTMFDolphinApp * app = context ;
15
+ return scene_manager_handle_back_event (app -> scene_manager );
16
+ }
17
+
18
+ static void dtmf_dolphin_app_tick_event_callback (void * context ) {
19
+ furi_assert (context );
20
+ DTMFDolphinApp * app = context ;
21
+
22
+ scene_manager_handle_tick_event (app -> scene_manager );
23
+ }
24
+
25
+ static DTMFDolphinApp * app_alloc () {
26
+ DTMFDolphinApp * app = malloc (sizeof (DTMFDolphinApp ));
27
+
28
+ app -> gui = furi_record_open (RECORD_GUI );
29
+ app -> view_dispatcher = view_dispatcher_alloc ();
30
+ app -> scene_manager = scene_manager_alloc (& dtmf_dolphin_scene_handlers , app );
31
+ view_dispatcher_enable_queue (app -> view_dispatcher );
32
+ view_dispatcher_set_event_callback_context (app -> view_dispatcher , app );
33
+
34
+ view_dispatcher_set_custom_event_callback (
35
+ app -> view_dispatcher , dtmf_dolphin_app_custom_event_callback );
36
+ view_dispatcher_set_navigation_event_callback (
37
+ app -> view_dispatcher , dtmf_dolphin_app_back_event_callback );
38
+ view_dispatcher_set_tick_event_callback (
39
+ app -> view_dispatcher , dtmf_dolphin_app_tick_event_callback , 100 );
40
+
41
+ view_dispatcher_attach_to_gui (app -> view_dispatcher , app -> gui , ViewDispatcherTypeFullscreen );
42
+
43
+ app -> main_menu_list = variable_item_list_alloc ();
44
+ view_dispatcher_add_view (
45
+ app -> view_dispatcher ,
46
+ DTMFDolphinViewMainMenu ,
47
+ variable_item_list_get_view (app -> main_menu_list ));
48
+
49
+ app -> dtmf_dolphin_dialer = dtmf_dolphin_dialer_alloc ();
50
+ view_dispatcher_add_view (
51
+ app -> view_dispatcher ,
52
+ DTMFDolphinViewDialer ,
53
+ dtmf_dolphin_dialer_get_view (app -> dtmf_dolphin_dialer ));
54
+
55
+ app -> notification = furi_record_open (RECORD_NOTIFICATION );
56
+ notification_message (app -> notification , & sequence_display_backlight_enforce_on );
57
+
58
+ scene_manager_next_scene (app -> scene_manager , DTMFDolphinSceneStart );
59
+
60
+ return app ;
61
+ }
62
+
63
+ static void app_free (DTMFDolphinApp * app ) {
64
+ furi_assert (app );
65
+ view_dispatcher_remove_view (app -> view_dispatcher , DTMFDolphinViewMainMenu );
66
+ view_dispatcher_remove_view (app -> view_dispatcher , DTMFDolphinViewDialer );
67
+ variable_item_list_free (app -> main_menu_list );
68
+
69
+ dtmf_dolphin_dialer_free (app -> dtmf_dolphin_dialer );
70
+
71
+ view_dispatcher_free (app -> view_dispatcher );
72
+ scene_manager_free (app -> scene_manager );
73
+
74
+ notification_message (app -> notification , & sequence_display_backlight_enforce_auto );
75
+
76
+ furi_record_close (RECORD_GUI );
77
+ furi_record_close (RECORD_NOTIFICATION );
78
+ free (app );
79
+ }
80
+
81
+ int32_t dtmf_dolphin_app (void * p ) {
82
+ UNUSED (p );
83
+ DTMFDolphinApp * app = app_alloc ();
84
+
85
+ view_dispatcher_run (app -> view_dispatcher );
86
+
87
+ app_free (app );
88
+ return 0 ;
89
+ }
0 commit comments