diff --git a/hex_viewer.c b/hex_viewer.c index 5be549c3fe0..4d731558812 100644 --- a/hex_viewer.c +++ b/hex_viewer.c @@ -71,13 +71,7 @@ HexViewer* hex_viewer_app_alloc() { hex_viewer_startscreen_get_view(app->hex_viewer_startscreen)); view_dispatcher_add_view( - app->view_dispatcher, HexViewerViewIdScene1, text_input_get_view(app->text_input)); - - app->hex_viewer_scene_2 = hex_viewer_scene_2_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - HexViewerViewIdScene2, - hex_viewer_scene_2_get_view(app->hex_viewer_scene_2)); + app->view_dispatcher, HexViewerViewIdScroll, text_input_get_view(app->text_input)); app->variable_item_list = variable_item_list_alloc(); view_dispatcher_add_view( @@ -100,8 +94,7 @@ void hex_viewer_app_free(HexViewer* app) { // View Dispatcher view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdMenu); - view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdScene1); - view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdScene2); + view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdScroll); view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdSettings); submenu_free(app->submenu); diff --git a/hex_viewer.h b/hex_viewer.h index c94d8a5f8d0..72f3247876d 100644 --- a/hex_viewer.h +++ b/hex_viewer.h @@ -18,8 +18,6 @@ #include #include "scenes/hex_viewer_scene.h" #include "views/hex_viewer_startscreen.h" -#include "views/hex_viewer_scene_1.h" -#include "views/hex_viewer_scene_2.h" #include "helpers/hex_viewer_storage.h" #include @@ -29,9 +27,6 @@ #define TAG "HexViewer" -// #define SUBGHZ_APP_EXTENSION ".sub" -// #define SUBGHZ_APP_FOLDER ANY_PATH("subghz") - #define HEX_VIEWER_APP_PATH_FOLDER "/any" // TODO ANY_PATH #define HEX_VIEWER_APP_EXTENSION "*" #define HEX_VIEWER_PERCENT_INPUT 16 @@ -40,37 +35,30 @@ #define HEX_VIEWER_LINES_ON_SCREEN 4u #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]; uint32_t file_offset; uint32_t file_read_bytes; uint32_t file_size; - Stream *stream; + Stream* stream; } HexViewerModel; // TODO Clean -typedef struct -{ - HexViewerModel *model; - - Gui *gui; - Storage *storage; - NotificationApp *notification; - ViewDispatcher *view_dispatcher; - Submenu *submenu; - TextInput *text_input; - 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 +typedef struct { + HexViewerModel* model; + + Gui* gui; + Storage* storage; + NotificationApp* notification; + ViewDispatcher* view_dispatcher; + Submenu* submenu; + TextInput* text_input; + SceneManager* scene_manager; + VariableItemList* variable_item_list; + HexViewerStartscreen* hex_viewer_startscreen; + DialogsApp* dialogs; // File Browser + FuriString* file_path; // File Browser uint32_t haptic; uint32_t speaker; uint32_t led; @@ -78,38 +66,29 @@ typedef struct char percent_buf[HEX_VIEWER_PERCENT_INPUT]; } HexViewer; -typedef enum -{ +typedef enum { HexViewerViewIdStartscreen, HexViewerViewIdMenu, - HexViewerViewIdScene1, - HexViewerViewIdScene2, - HexViewerViewIdScene3, - HexViewerViewIdScene4, - HexViewerViewIdScene5, + HexViewerViewIdScroll, HexViewerViewIdSettings, } HexViewerViewId; -typedef enum -{ +typedef enum { HexViewerHapticOff, HexViewerHapticOn, } HexViewerHapticState; -typedef enum -{ +typedef enum { HexViewerSpeakerOff, HexViewerSpeakerOn, } HexViewerSpeakerState; -typedef enum -{ +typedef enum { HexViewerLedOff, HexViewerLedOn, } HexViewerLedState; -typedef enum -{ +typedef enum { HexViewerSettingsOff, HexViewerSettingsOn, } HexViewerSettingsStoreState; diff --git a/scenes/hex_viewer_scene_config.h b/scenes/hex_viewer_scene_config.h index eafe88d5c23..7db382bc522 100644 --- a/scenes/hex_viewer_scene_config.h +++ b/scenes/hex_viewer_scene_config.h @@ -1,6 +1,6 @@ ADD_SCENE(hex_viewer, startscreen, Startscreen) ADD_SCENE(hex_viewer, menu, Menu) -ADD_SCENE(hex_viewer, scene_1, Scene_1) -ADD_SCENE(hex_viewer, scene_2, Scene_2) -ADD_SCENE(hex_viewer, scene_4, Scene_4) +ADD_SCENE(hex_viewer, scroll, Scroll) +ADD_SCENE(hex_viewer, info, Info) +ADD_SCENE(hex_viewer, open, Open) ADD_SCENE(hex_viewer, settings, Settings) \ No newline at end of file diff --git a/scenes/hex_viewer_scene_scene_2.c b/scenes/hex_viewer_scene_info.c similarity index 75% rename from scenes/hex_viewer_scene_scene_2.c rename to scenes/hex_viewer_scene_info.c index 4c5f3bb7c07..39d51b8c57f 100644 --- a/scenes/hex_viewer_scene_scene_2.c +++ b/scenes/hex_viewer_scene_info.c @@ -1,10 +1,6 @@ #include "../hex_viewer.h" -#include "../helpers/hex_viewer_custom_event.h" -#include "../helpers/hex_viewer_haptic.h" -#include "../helpers/hex_viewer_led.h" -#include "../views/hex_viewer_scene_2.h" -void hex_viewer_scene_scene_2_on_enter(void* context) { +void hex_viewer_scene_info_on_enter(void* context) { furi_assert(context); HexViewer* app = context; @@ -31,7 +27,7 @@ void hex_viewer_scene_scene_2_on_enter(void* context) { app->scene_manager, HexViewerViewIdStartscreen); } -bool hex_viewer_scene_scene_2_on_event(void* context, SceneManagerEvent event) { +bool hex_viewer_scene_info_on_event(void* context, SceneManagerEvent event) { HexViewer* app = context; UNUSED(app); UNUSED(event); @@ -40,7 +36,7 @@ bool hex_viewer_scene_scene_2_on_event(void* context, SceneManagerEvent event) { return consumed; } -void hex_viewer_scene_scene_2_on_exit(void* context) { +void hex_viewer_scene_info_on_exit(void* context) { HexViewer* app = context; UNUSED(app); } diff --git a/scenes/hex_viewer_scene_menu.c b/scenes/hex_viewer_scene_menu.c index 68d21c34dc4..50e0b55ba91 100644 --- a/scenes/hex_viewer_scene_menu.c +++ b/scenes/hex_viewer_scene_menu.c @@ -1,11 +1,9 @@ #include "../hex_viewer.h" enum SubmenuIndex { - SubmenuIndexScene1 = 10, - SubmenuIndexScene2, - // SubmenuIndexScene3, - SubmenuIndexScene4, - // SubmenuIndexScene5, + SubmenuIndexScroll = 10, + SubmenuIndexInfo, + SubmenuIndexOpen, // SubmenuIndexSettings, }; @@ -21,21 +19,19 @@ void hex_viewer_scene_menu_on_enter(void* context) { submenu_add_item( app->submenu, "Open file ...", - SubmenuIndexScene4, + SubmenuIndexOpen, hex_viewer_scene_menu_submenu_callback, app); - // submenu_add_item(app->submenu, "Scene 2 (Inputs/Effects)", SubmenuIndexScene2, hex_viewer_scene_menu_submenu_callback, app); - // submenu_add_item(app->submenu, "Scene 3 (Buttonmenu)", SubmenuIndexScene3, hex_viewer_scene_menu_submenu_callback, app); submenu_add_item( app->submenu, "Scroll to ...", - SubmenuIndexScene1, + SubmenuIndexScroll, hex_viewer_scene_menu_submenu_callback, app); submenu_add_item( app->submenu, "Show info ...", - SubmenuIndexScene2, + SubmenuIndexInfo, hex_viewer_scene_menu_submenu_callback, app); // submenu_add_item(app->submenu, "Settings", SubmenuIndexSettings, hex_viewer_scene_menu_submenu_callback, app); @@ -56,20 +52,20 @@ bool hex_viewer_scene_menu_on_event(void* context, SceneManagerEvent event) { scene_manager_previous_scene(app->scene_manager); return true; } else if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexScene1) { + if(event.event == SubmenuIndexScroll) { scene_manager_set_scene_state( - app->scene_manager, HexViewerSceneMenu, SubmenuIndexScene1); - scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_1); + app->scene_manager, HexViewerSceneMenu, SubmenuIndexScroll); + scene_manager_next_scene(app->scene_manager, HexViewerSceneScroll); return true; - } else if(event.event == SubmenuIndexScene2) { + } else if(event.event == SubmenuIndexInfo) { scene_manager_set_scene_state( - app->scene_manager, HexViewerSceneMenu, SubmenuIndexScene2); - scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_2); + app->scene_manager, HexViewerSceneMenu, SubmenuIndexInfo); + scene_manager_next_scene(app->scene_manager, HexViewerSceneInfo); return true; - } else if(event.event == SubmenuIndexScene4) { + } else if(event.event == SubmenuIndexOpen) { scene_manager_set_scene_state( - app->scene_manager, HexViewerSceneMenu, SubmenuIndexScene4); - scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_4); + app->scene_manager, HexViewerSceneMenu, SubmenuIndexOpen); + scene_manager_next_scene(app->scene_manager, HexViewerSceneOpen); // } else if (event.event == SubmenuIndexSettings) { // scene_manager_set_scene_state( // app->scene_manager, HexViewerSceneMenu, SubmenuIndexSettings); diff --git a/scenes/hex_viewer_scene_scene_4.c b/scenes/hex_viewer_scene_open.c similarity index 84% rename from scenes/hex_viewer_scene_scene_4.c rename to scenes/hex_viewer_scene_open.c index 406fec06a9d..cd9e90b7f73 100644 --- a/scenes/hex_viewer_scene_scene_4.c +++ b/scenes/hex_viewer_scene_open.c @@ -1,6 +1,6 @@ #include "../hex_viewer.h" -void hex_viewer_scene_scene_4_on_enter(void* context) { +void hex_viewer_scene_open_on_enter(void* context) { furi_assert(context); HexViewer* app = context; @@ -29,7 +29,7 @@ void hex_viewer_scene_scene_4_on_enter(void* context) { } } -bool hex_viewer_scene_scene_4_on_event(void* context, SceneManagerEvent event) { +bool hex_viewer_scene_open_on_event(void* context, SceneManagerEvent event) { UNUSED(context); UNUSED(event); bool consumed = true; @@ -37,6 +37,6 @@ bool hex_viewer_scene_scene_4_on_event(void* context, SceneManagerEvent event) { return consumed; } -void hex_viewer_scene_scene_4_on_exit(void* context) { +void hex_viewer_scene_open_on_exit(void* context) { UNUSED(context); } diff --git a/scenes/hex_viewer_scene_scene_1.c b/scenes/hex_viewer_scene_scroll.c similarity index 84% rename from scenes/hex_viewer_scene_scene_1.c rename to scenes/hex_viewer_scene_scroll.c index bdf34dcde2b..d20e9cfcb8b 100644 --- a/scenes/hex_viewer_scene_scene_1.c +++ b/scenes/hex_viewer_scene_scroll.c @@ -1,14 +1,13 @@ #include "../hex_viewer.h" #include "../helpers/hex_viewer_custom_event.h" -#include "../views/hex_viewer_scene_1.h" -void hex_viewer_scene_scene_1_callback(void* context) { +void hex_viewer_scene_scroll_callback(void* context) { HexViewer* app = (HexViewer*)context; view_dispatcher_send_custom_event( app->view_dispatcher, HexViewerCustomEventMenuPercentEntered); } -void hex_viewer_scene_scene_1_on_enter(void* context) { +void hex_viewer_scene_scroll_on_enter(void* context) { furi_assert(context); HexViewer* app = context; @@ -17,16 +16,16 @@ void hex_viewer_scene_scene_1_on_enter(void* context) { text_input_set_header_text(text_input, "Scroll to percent (0..100)"); text_input_set_result_callback( text_input, - hex_viewer_scene_scene_1_callback, + hex_viewer_scene_scroll_callback, app, app->percent_buf, HEX_VIEWER_PERCENT_INPUT, false); - view_dispatcher_switch_to_view(app->view_dispatcher, HexViewerSceneScene_1); + view_dispatcher_switch_to_view(app->view_dispatcher, HexViewerSceneScroll); } -bool hex_viewer_scene_scene_1_on_event(void* context, SceneManagerEvent event) { +bool hex_viewer_scene_scroll_on_event(void* context, SceneManagerEvent event) { HexViewer* app = (HexViewer*)context; bool consumed = false; @@ -57,6 +56,6 @@ bool hex_viewer_scene_scene_1_on_event(void* context, SceneManagerEvent event) { return consumed; } -void hex_viewer_scene_scene_1_on_exit(void* context) { +void hex_viewer_scene_scroll_on_exit(void* context) { UNUSED(context); } diff --git a/scenes/hex_viewer_scene_startscreen.c b/scenes/hex_viewer_scene_startscreen.c index cbe6f33d071..6793655af4d 100644 --- a/scenes/hex_viewer_scene_startscreen.c +++ b/scenes/hex_viewer_scene_startscreen.c @@ -27,7 +27,6 @@ bool hex_viewer_scene_startscreen_on_event(void* context, SceneManagerEvent even consumed = true; break; case HexViewerCustomEventStartscreenRight: - // TODO Dialog consumed = true; break; case HexViewerCustomEventStartscreenUp: @@ -38,7 +37,7 @@ bool hex_viewer_scene_startscreen_on_event(void* context, SceneManagerEvent even break; case HexViewerCustomEventStartscreenOk: if(!app->model->file_size) - scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_4); + scene_manager_next_scene(app->scene_manager, HexViewerSceneOpen); else scene_manager_next_scene(app->scene_manager, HexViewerSceneMenu); consumed = true; diff --git a/views/hex_viewer_scene_1.c b/views/hex_viewer_scene_1.c deleted file mode 100644 index ca961c9987d..00000000000 --- a/views/hex_viewer_scene_1.c +++ /dev/null @@ -1,136 +0,0 @@ -#include "../hex_viewer.h" -#include -#include -#include -#include -#include - -struct HexViewerScene1 { - View* view; - HexViewerScene1Callback callback; - void* context; -}; - - -typedef struct { - int some_value; -} HexViewerScene1Model; - -void hex_viewer_scene_1_set_callback( - HexViewerScene1* instance, - HexViewerScene1Callback callback, - void* context) { - furi_assert(instance); - furi_assert(callback); - instance->callback = callback; - instance->context = context; -} - -void hex_viewer_scene_1_draw(Canvas* canvas, HexViewerScene1Model* model) { - UNUSED(model); - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 0, 10, AlignLeft, AlignTop, "This is Scene 1"); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 0, 22, AlignLeft, AlignTop, "An empty scene to be"); - canvas_draw_str_aligned(canvas, 0, 32, AlignLeft, AlignTop, "used as hex_viewer"); -} - -static void hex_viewer_scene_1_model_init(HexViewerScene1Model* const model) { - model->some_value = 1; -} - -bool hex_viewer_scene_1_input(InputEvent* event, void* context) { - furi_assert(context); - HexViewerScene1* instance = context; - if (event->type == InputTypeRelease) { - switch(event->key) { - case InputKeyBack: - with_view_model( - instance->view, - HexViewerScene1Model * model, - { - UNUSED(model); - instance->callback(HexViewerCustomEventScene1Back, instance->context); - }, - true); - break; - case InputKeyLeft: - case InputKeyRight: - case InputKeyUp: - case InputKeyDown: - case InputKeyOk: - with_view_model( - instance->view, - HexViewerScene1Model* model, - { - UNUSED(model); - }, - true); - break; - case InputKeyMAX: - break; - } - } - return true; -} - -void hex_viewer_scene_1_exit(void* context) { - furi_assert(context); -} - -void hex_viewer_scene_1_enter(void* context) { - furi_assert(context); - HexViewerScene1* instance = (HexViewerScene1*)context; - with_view_model( - instance->view, - HexViewerScene1Model * model, - { - hex_viewer_scene_1_model_init(model); - }, - true - ); -} - -HexViewerScene1* hex_viewer_scene_1_alloc() { - HexViewerScene1* instance = malloc(sizeof(HexViewerScene1)); - instance->view = view_alloc(); - view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(HexViewerScene1Model)); - view_set_context(instance->view, instance); // furi_assert crashes in events without this - view_set_draw_callback(instance->view, (ViewDrawCallback)hex_viewer_scene_1_draw); - view_set_input_callback(instance->view, hex_viewer_scene_1_input); - view_set_enter_callback(instance->view, hex_viewer_scene_1_enter); - view_set_exit_callback(instance->view, hex_viewer_scene_1_exit); - - with_view_model( - instance->view, - HexViewerScene1Model * model, - { - hex_viewer_scene_1_model_init(model); - }, - true - ); - - return instance; -} - -void hex_viewer_scene_1_free(HexViewerScene1* instance) { - furi_assert(instance); - - with_view_model( - instance->view, - HexViewerScene1Model * model, - { - UNUSED(model); - }, - true); - view_free(instance->view); - free(instance); -} - -View* hex_viewer_scene_1_get_view(HexViewerScene1* instance) { - furi_assert(instance); - return instance->view; -} - diff --git a/views/hex_viewer_scene_1.h b/views/hex_viewer_scene_1.h deleted file mode 100644 index 0f87194ac49..00000000000 --- a/views/hex_viewer_scene_1.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include "../helpers/hex_viewer_custom_event.h" - -typedef struct HexViewerScene1 HexViewerScene1; - -typedef void (*HexViewerScene1Callback)(HexViewerCustomEvent event, void* context); - -void hex_viewer_scene_1_set_callback( - HexViewerScene1* hex_viewer_scene_1, - HexViewerScene1Callback callback, - void* context); - -View* hex_viewer_scene_1_get_view(HexViewerScene1* hex_viewer_static); - -HexViewerScene1* hex_viewer_scene_1_alloc(); - -void hex_viewer_scene_1_free(HexViewerScene1* hex_viewer_static); \ No newline at end of file diff --git a/views/hex_viewer_scene_2.c b/views/hex_viewer_scene_2.c deleted file mode 100644 index baa618228a5..00000000000 --- a/views/hex_viewer_scene_2.c +++ /dev/null @@ -1,254 +0,0 @@ -#include "../hex_viewer.h" -#include -#include -#include -#include -#include -#include "../helpers/hex_viewer_haptic.h" -#include "../helpers/hex_viewer_speaker.h" -#include "../helpers/hex_viewer_led.h" - -struct HexViewerScene2 { - View* view; - HexViewerScene2Callback callback; - void* context; -}; - -typedef struct { - int screen_text; -} HexViewerScene2Model; - -char buttonText[11][14] = { - "", - "Press Up", - "Press Down", - "Press Left", - "Press Right", - "Press Ok", - "Release Up", - "Release Down", - "Release Left", - "Release Right", - "Release Ok", -}; - -void hex_viewer_scene_2_set_callback( - HexViewerScene2* instance, - HexViewerScene2Callback callback, - void* context) { - furi_assert(instance); - furi_assert(callback); - instance->callback = callback; - instance->context = context; -} - -void hex_viewer_scene_2_draw(Canvas* canvas, HexViewerScene2Model* model) { - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 0, 10, AlignLeft, AlignTop, "Scene 2: Input Examples"); - canvas_set_font(canvas, FontSecondary); - char *strInput = malloc(15); - strcpy(strInput, buttonText[model->screen_text]); - canvas_draw_str_aligned(canvas, 0, 22, AlignLeft, AlignTop, strInput); - free(strInput); -} - -static void hex_viewer_scene_2_model_init(HexViewerScene2Model* const model) { - model->screen_text = 0; -} - -bool hex_viewer_scene_2_input(InputEvent* event, void* context) { - furi_assert(context); - HexViewerScene2* instance = context; - if (event->type == InputTypeRelease) { - switch(event->key) { - case InputKeyBack: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - UNUSED(model); - hex_viewer_stop_all_sound(instance->context); - instance->callback(HexViewerCustomEventScene2Back, instance->context); - hex_viewer_play_long_bump(instance->context); - }, - true); - break; - case InputKeyUp: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 6; - hex_viewer_play_bad_bump(instance->context); - hex_viewer_stop_all_sound(instance->context); - hex_viewer_led_set_rgb(instance->context, 255, 0, 255); - }, - true); - break; - case InputKeyDown: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 7; - hex_viewer_play_bad_bump(instance->context); - hex_viewer_stop_all_sound(instance->context); - hex_viewer_led_set_rgb(instance->context, 255, 255, 0); - }, - true); - break; - case InputKeyLeft: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 8; - hex_viewer_play_bad_bump(instance->context); - hex_viewer_stop_all_sound(instance->context); - hex_viewer_led_set_rgb(instance->context, 0, 255, 255); - }, - true); - break; - case InputKeyRight: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 9; - hex_viewer_play_bad_bump(instance->context); - hex_viewer_stop_all_sound(instance->context); - hex_viewer_led_set_rgb(instance->context, 255, 0, 0); - }, - true); - break; - case InputKeyOk: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 10; - hex_viewer_play_bad_bump(instance->context); - hex_viewer_stop_all_sound(instance->context); - hex_viewer_led_set_rgb(instance->context, 255, 255, 255); - }, - true); - break; - case InputKeyMAX: - break; - } - } else if (event->type == InputTypePress) { - switch(event->key) { - case InputKeyUp: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 1; - hex_viewer_play_happy_bump(instance->context); - hex_viewer_play_input_sound(instance->context); - }, - true); - break; - case InputKeyDown: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 2; - hex_viewer_play_happy_bump(instance->context); - hex_viewer_play_input_sound(instance->context); - }, - true); - break; - case InputKeyLeft: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 3; - hex_viewer_play_happy_bump(instance->context); - hex_viewer_play_input_sound(instance->context); - }, - true); - break; - case InputKeyRight: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 4; - hex_viewer_play_happy_bump(instance->context); - hex_viewer_play_input_sound(instance->context); - }, - true); - break; - case InputKeyOk: - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - model->screen_text = 5; - hex_viewer_play_happy_bump(instance->context); - hex_viewer_play_input_sound(instance->context); - }, - true); - break; - case InputKeyBack: - case InputKeyMAX: - break; - } - } - - return true; -} - -void hex_viewer_scene_2_exit(void* context) { - furi_assert(context); - HexViewer* app = context; - hex_viewer_stop_all_sound(app); - //hex_viewer_led_reset(app); -} - -void hex_viewer_scene_2_enter(void* context) { - furi_assert(context); - dolphin_deed(DolphinDeedPluginStart); -} - -HexViewerScene2* hex_viewer_scene_2_alloc() { - HexViewerScene2* instance = malloc(sizeof(HexViewerScene2)); - instance->view = view_alloc(); - view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(HexViewerScene2Model)); - view_set_context(instance->view, instance); - view_set_draw_callback(instance->view, (ViewDrawCallback)hex_viewer_scene_2_draw); - view_set_input_callback(instance->view, hex_viewer_scene_2_input); - //view_set_enter_callback(instance->view, hex_viewer_scene_2_enter); - view_set_exit_callback(instance->view, hex_viewer_scene_2_exit); - - with_view_model( - instance->view, - HexViewerScene2Model * model, - { - hex_viewer_scene_2_model_init(model); - }, - true); - - return instance; -} - -void hex_viewer_scene_2_free(HexViewerScene2* instance) { - furi_assert(instance); - - - view_free(instance->view); - free(instance); -} - -View* hex_viewer_scene_2_get_view(HexViewerScene2* instance) { - furi_assert(instance); - - - return instance->view; -} - diff --git a/views/hex_viewer_scene_2.h b/views/hex_viewer_scene_2.h deleted file mode 100644 index 299e0b17a41..00000000000 --- a/views/hex_viewer_scene_2.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include "../helpers/hex_viewer_custom_event.h" - -typedef struct HexViewerScene2 HexViewerScene2; - -typedef void (*HexViewerScene2Callback)(HexViewerCustomEvent event, void* context); - -void hex_viewer_scene_2_set_callback( - HexViewerScene2* instance, - HexViewerScene2Callback callback, - void * context); - -HexViewerScene2* hex_viewer_scene_2_alloc(); - -void hex_viewer_scene_2_free(HexViewerScene2* hex_viewer_static); - -View* hex_viewer_scene_2_get_view(HexViewerScene2* boilerpate_static); diff --git a/views/hex_viewer_startscreen.c b/views/hex_viewer_startscreen.c index 841d1419a4c..ed40de8a7da 100644 --- a/views/hex_viewer_startscreen.c +++ b/views/hex_viewer_startscreen.c @@ -147,14 +147,7 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) { break; case InputKeyRight: with_view_model( - instance->view, - HexViewerStartscreenModel * model, - { - // instance->callback(HexViewerCustomEventStartscreenRight, instance->context); - // update_local_model_from_app(instance->context, model); - model->dbg = 0; - }, - true); + instance->view, HexViewerStartscreenModel * model, { model->dbg = 0; }, true); break; case InputKeyUp: with_view_model(