QtRoS 2 лет назад
Родитель
Сommit
025d25a500

+ 4 - 2
helpers/hex_viewer_storage.c

@@ -120,7 +120,8 @@ void hex_viewer_read_settings(void* context) {
 }
 }
 
 
 
 
-bool hex_viewer_open_file(HexViewer* hex_viewer, const char* file_path) {
+bool hex_viewer_open_file(void* context, const char* file_path) {
+    HexViewer* hex_viewer = context;
     furi_assert(hex_viewer);
     furi_assert(hex_viewer);
     furi_assert(file_path);
     furi_assert(file_path);
 
 
@@ -141,7 +142,8 @@ bool hex_viewer_open_file(HexViewer* hex_viewer, const char* file_path) {
     return isOk;
     return isOk;
 }
 }
 
 
-bool hex_viewer_read_file(HexViewer* hex_viewer) {
+bool hex_viewer_read_file(void* context) {
+    HexViewer* hex_viewer = context;
     furi_assert(hex_viewer);
     furi_assert(hex_viewer);
     furi_assert(hex_viewer->model->stream);
     furi_assert(hex_viewer->model->stream);
     furi_assert(hex_viewer->model->file_offset % HEX_VIEWER_BYTES_PER_LINE == 0);
     furi_assert(hex_viewer->model->file_offset % HEX_VIEWER_BYTES_PER_LINE == 0);

+ 2 - 2
helpers/hex_viewer_storage.h

@@ -18,5 +18,5 @@ void hex_viewer_save_settings(void* context);
 void hex_viewer_read_settings(void* context);
 void hex_viewer_read_settings(void* context);
 
 
 
 
-bool hex_viewer_open_file(HexViewer* hex_viewer, const char* file_path);
-bool hex_viewer_read_file(HexViewer* hex_viewer);
+bool hex_viewer_open_file(void* context, const char* file_path);
+bool hex_viewer_read_file(void* context);

+ 42 - 0
hex_viewer.c

@@ -1,6 +1,42 @@
 #include "hex_viewer.h"
 #include "hex_viewer.h"
 
 
 
 
+// typedef struct {
+//     uint8_t file_bytes[HEX_VIEWER_LINES_ON_SCREEN][HEX_VIEWER_BYTES_PER_LINE];
+//     uint32_t file_offset;
+//     uint32_t file_read_bytes;
+//     uint32_t file_size;
+//     bool mode; // Print address or content
+    
+//     Stream* stream;
+// } HexViewerModel;
+
+
+// // TODO Clean
+// typedef struct {
+//     HexViewerModel* model;
+//     FuriMutex** mutex; // TODO Don't need?
+
+//     Gui* gui;
+//     Storage* storage;
+//     NotificationApp* notification;
+//     ViewDispatcher* view_dispatcher;
+//     Submenu* submenu;
+//     SceneManager* scene_manager;
+//     VariableItemList* variable_item_list;
+//     HexViewerStartscreen* hex_viewer_startscreen;
+//     HexViewerScene1* hex_viewer_scene_1;
+//     HexViewerScene2* hex_viewer_scene_2;
+//     DialogsApp* dialogs; // File Browser
+//     FuriString* file_path; // File Browser
+//     uint32_t haptic; 
+//     uint32_t speaker;
+//     uint32_t led;
+//     uint32_t save_settings;
+//     ButtonMenu* button_menu; // Button Menu
+// } HexViewer;
+
+
 bool hex_viewer_custom_event_callback(void* context, uint32_t event) {
 bool hex_viewer_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
     furi_assert(context);
     HexViewer* app = context;
     HexViewer* app = context;
@@ -22,6 +58,10 @@ bool hex_viewer_navigation_event_callback(void* context) {
 
 
 HexViewer* hex_viewer_app_alloc() {
 HexViewer* hex_viewer_app_alloc() {
     HexViewer* app = malloc(sizeof(HexViewer));
     HexViewer* app = malloc(sizeof(HexViewer));
+
+    app->model = malloc(sizeof(HexViewerModel));
+    memset(app->model, 0, sizeof(HexViewerModel));
+
     app->gui = furi_record_open(RECORD_GUI);
     app->gui = furi_record_open(RECORD_GUI);
     app->storage = furi_record_open(RECORD_STORAGE);
     app->storage = furi_record_open(RECORD_STORAGE);
     app->notification = furi_record_open(RECORD_NOTIFICATION);
     app->notification = furi_record_open(RECORD_NOTIFICATION);
@@ -98,6 +138,8 @@ void hex_viewer_app_free(HexViewer* app) {
     furi_record_close(RECORD_DIALOGS);
     furi_record_close(RECORD_DIALOGS);
     furi_string_free(app->file_path);
     furi_string_free(app->file_path);
 
 
+    free(app->model);
+
     //Remove whatever is left
     //Remove whatever is left
     free(app);
     free(app);
 }
 }

+ 4 - 0
hex_viewer.h

@@ -38,6 +38,9 @@
 #define HEX_VIEWER_BUF_SIZE (HEX_VIEWER_LINES_ON_SCREEN * HEX_VIEWER_BYTES_PER_LINE)
 #define HEX_VIEWER_BUF_SIZE (HEX_VIEWER_LINES_ON_SCREEN * HEX_VIEWER_BYTES_PER_LINE)
 
 
 
 
+// typedef struct HexViewerModel HexViewerModel;
+// typedef struct HexViewer HexViewer;
+
 typedef struct {
 typedef struct {
     uint8_t file_bytes[HEX_VIEWER_LINES_ON_SCREEN][HEX_VIEWER_BYTES_PER_LINE];
     uint8_t file_bytes[HEX_VIEWER_LINES_ON_SCREEN][HEX_VIEWER_BYTES_PER_LINE];
     uint32_t file_offset;
     uint32_t file_offset;
@@ -73,6 +76,7 @@ typedef struct {
     ButtonMenu* button_menu; // Button Menu
     ButtonMenu* button_menu; // Button Menu
 } HexViewer;
 } HexViewer;
 
 
+
 typedef enum {
 typedef enum {
     HexViewerViewIdStartscreen,
     HexViewerViewIdStartscreen,
     HexViewerViewIdMenu,
     HexViewerViewIdMenu,

+ 2 - 3
scenes/hex_viewer_scene_scene_4.c

@@ -4,8 +4,7 @@
 void hex_viewer_scene_scene_4_on_enter(void* context) {
 void hex_viewer_scene_scene_4_on_enter(void* context) {
     furi_assert(context);
     furi_assert(context);
     HexViewer* app = context;
     HexViewer* app = context;
-    DialogsFileBrowserOptions browser_options;
-    
+    // DialogsFileBrowserOptions browser_options;
     // This will filter the browser to only show one file type and also add an icon
     // This will filter the browser to only show one file type and also add an icon
     // dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px);
     // dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px);
     // Get the Folder you want to browse
     // Get the Folder you want to browse
@@ -23,7 +22,7 @@ void hex_viewer_scene_scene_4_on_enter(void* context) {
 
 
     DialogsFileBrowserOptions browser_options;
     DialogsFileBrowserOptions browser_options;
     dialog_file_browser_set_basic_options(
     dialog_file_browser_set_basic_options(
-        &browser_options, HEX_VIEWER_APP_EXTENSION, &I_hex_10px);
+        &browser_options, HEX_VIEWER_APP_EXTENSION, &I_u2f_10px); // I_u2f_10px I_hex_10px
     browser_options.hide_ext = false;
     browser_options.hide_ext = false;
 
 
     bool success = dialog_file_browser_show(app->dialogs, app->file_path, initial_path, &browser_options);
     bool success = dialog_file_browser_show(app->dialogs, app->file_path, initial_path, &browser_options);

+ 2 - 0
scenes/hex_viewer_scene_startscreen.c

@@ -39,6 +39,7 @@ bool hex_viewer_scene_startscreen_on_event(void* context, SceneManagerEvent even
                 //furi_mutex_release(hex_viewer->mutex);
                 //furi_mutex_release(hex_viewer->mutex);
                 break;
                 break;
             case HexViewerCustomEventStartscreenDown:
             case HexViewerCustomEventStartscreenDown:
+            {
                 //furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
                 //furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
                 uint32_t last_byte_on_screen =
                 uint32_t last_byte_on_screen =
                     app->model->file_offset + app->model->file_read_bytes;
                     app->model->file_offset + app->model->file_read_bytes;
@@ -50,6 +51,7 @@ bool hex_viewer_scene_startscreen_on_event(void* context, SceneManagerEvent even
                 consumed = true;
                 consumed = true;
                 //furi_mutex_release(hex_viewer->mutex);
                 //furi_mutex_release(hex_viewer->mutex);
                 break;
                 break;
+            }
             case HexViewerCustomEventStartscreenOk:
             case HexViewerCustomEventStartscreenOk:
                 if (!app->model->file_size) // TODO
                 if (!app->model->file_size) // TODO
                     scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_4);
                     scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_4);

+ 1 - 7
views/hex_viewer_startscreen.c

@@ -30,7 +30,6 @@ void hex_viewer_startscreen_set_callback(
 }
 }
 
 
 void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* model) {
 void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* model) {
-    UNUSED(model);
     canvas_clear(canvas);
     canvas_clear(canvas);
 
 
     if (!model->file_size) {
     if (!model->file_size) {
@@ -139,18 +138,16 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
                     instance->view,
                     instance->view,
                     HexViewerStartscreenModel * model,
                     HexViewerStartscreenModel * model,
                     {
                     {
-                        UNUSED(model);
                         instance->callback(HexViewerCustomEventStartscreenLeft, instance->context);
                         instance->callback(HexViewerCustomEventStartscreenLeft, instance->context);
                         update_local_model_from_app(instance->context, model);
                         update_local_model_from_app(instance->context, model);
                     },
                     },
                     true);
                     true);
-                    break;
+                break;
             case InputKeyRight:
             case InputKeyRight:
                 with_view_model(
                 with_view_model(
                     instance->view,
                     instance->view,
                     HexViewerStartscreenModel * model,
                     HexViewerStartscreenModel * model,
                     {
                     {
-                        UNUSED(model);
                         instance->callback(HexViewerCustomEventStartscreenRight, instance->context);
                         instance->callback(HexViewerCustomEventStartscreenRight, instance->context);
                         update_local_model_from_app(instance->context, model);
                         update_local_model_from_app(instance->context, model);
                     },
                     },
@@ -161,7 +158,6 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
                     instance->view,
                     instance->view,
                     HexViewerStartscreenModel * model,
                     HexViewerStartscreenModel * model,
                     {
                     {
-                        UNUSED(model);
                         instance->callback(HexViewerCustomEventStartscreenUp, instance->context);
                         instance->callback(HexViewerCustomEventStartscreenUp, instance->context);
                         update_local_model_from_app(instance->context, model);
                         update_local_model_from_app(instance->context, model);
                     },
                     },
@@ -172,7 +168,6 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
                     instance->view,
                     instance->view,
                     HexViewerStartscreenModel * model,
                     HexViewerStartscreenModel * model,
                     {
                     {
-                        UNUSED(model);
                         instance->callback(HexViewerCustomEventStartscreenDown, instance->context);
                         instance->callback(HexViewerCustomEventStartscreenDown, instance->context);
                         update_local_model_from_app(instance->context, model);
                         update_local_model_from_app(instance->context, model);
                     },
                     },
@@ -183,7 +178,6 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
                     instance->view,
                     instance->view,
                     HexViewerStartscreenModel* model,
                     HexViewerStartscreenModel* model,
                     {
                     {
-                        UNUSED(model);
                         instance->callback(HexViewerCustomEventStartscreenOk, instance->context);
                         instance->callback(HexViewerCustomEventStartscreenOk, instance->context);
                         update_local_model_from_app(instance->context, model);
                         update_local_model_from_app(instance->context, model);
                     },
                     },