|
6 | 6 | #include <gui/modules/popup.h>
|
7 | 7 | #include <gui/modules/submenu.h>
|
8 | 8 | #include <gui/modules/text_input.h>
|
| 9 | +#include <gui/modules/byte_input.h> |
9 | 10 | #include <gui/modules/widget.h>
|
10 | 11 | #include <gui/modules/variable_item_list.h>
|
11 | 12 | #include <notification/notification.h>
|
@@ -34,58 +35,69 @@ typedef enum {
|
34 | 35 | T5577WriterSubmenuIndexAbout,
|
35 | 36 | } T5577WriterSubmenuIndex;
|
36 | 37 |
|
| 38 | +// Each view is a screen we show the user. |
37 | 39 | typedef enum {
|
38 |
| - T5577WriterViewSubmenu, |
39 |
| - T5577WriterViewTextInput, |
| 40 | + T5577WriterViewSubmenu, // The menu when the app starts |
| 41 | + T5577WriterViewTextInput, // Input for configuring text settings |
| 42 | + T5577WriterViewByteInput, |
40 | 43 | T5577WriterViewLoad,
|
41 | 44 | T5577WriterViewSave,
|
42 |
| - T5577WriterViewConfigure_i, // The configuration screen that's recreated every time we enter it |
43 |
| - T5577WriterViewConfigure_e, // The configuration screen store front that's constantly there |
44 |
| - T5577WriterViewWrite, |
45 |
| - T5577WriterViewAbout, |
| 45 | + T5577WriterViewPopup, |
| 46 | + T5577WriterViewConfigure_i, // The configuration screen |
| 47 | + T5577WriterViewConfigure_e, // The configuration screen |
| 48 | + T5577WriterViewWrite, // The main screen |
| 49 | + T5577WriterViewAbout, // The about screen with directions, link to social channel, etc. |
46 | 50 | } T5577WriterView;
|
47 | 51 |
|
48 | 52 | typedef enum {
|
49 |
| - T5577WriterEventIdRepeatWriting = 0, // Custom event to repeat sending writing commands |
50 |
| - T5577WriterEventIdMaxWriteRep = 42, // Custom event to exit writing view |
| 53 | + T5577WriterEventIdRepeatWriting = 0, // Custom event to redraw the screen |
| 54 | + T5577WriterEventIdMaxWriteRep = 42, // Custom event to process OK button getting pressed down |
51 | 55 | } T5577WriterEventId;
|
52 | 56 |
|
53 | 57 | typedef struct {
|
54 | 58 | ViewDispatcher* view_dispatcher; // Switches between our views
|
55 | 59 | NotificationApp* notifications; // Used for controlling the backlight
|
56 | 60 | Submenu* submenu; // The application menu
|
| 61 | + |
57 | 62 | TextInput* text_input; // The text input screen
|
58 |
| - VariableItemList* variable_item_list_config; // The internal configuration view |
59 |
| - View* view_config_e; // The external configuration view |
60 |
| - View* view_save; // The save view |
61 |
| - View* view_write; // The writing view |
| 63 | + Popup* popup; |
| 64 | + VariableItemList* variable_item_list_config; // The configuration screen |
| 65 | + View* view_config_e; // The configuration screen |
| 66 | + View* view_save; |
| 67 | + View* view_write; // The main screen |
62 | 68 | Widget* widget_about; // The about screen
|
63 | 69 | View* view_load; // The load view
|
64 | 70 |
|
65 |
| - VariableItem* mod_item; |
66 |
| - VariableItem* clock_item; |
67 |
| - VariableItem* block_num_item; |
68 |
| - VariableItem* block_slc_item; |
| 71 | + VariableItem* mod_item; // |
| 72 | + VariableItem* clock_item; // |
| 73 | + VariableItem* block_num_item; // |
| 74 | + VariableItem* block_slc_item; // |
| 75 | + VariableItem* byte_buffer_item; // |
| 76 | + ByteInput* byte_input; // The byte input view |
| 77 | + uint8_t* bytes_buffer[4]; |
| 78 | + uint8_t bytes_count; |
| 79 | + |
69 | 80 | char* temp_buffer; // Temporary buffer for text input
|
70 | 81 | uint32_t temp_buffer_size; // Size of temporary buffer
|
71 | 82 |
|
72 |
| - DialogsApp* dialogs; // dialog for file browser |
73 |
| - FuriString* file_path; // apps_data/t5577_writer |
| 83 | + DialogsApp* dialogs; |
| 84 | + FuriString* file_path; |
74 | 85 | FuriTimer* timer; // Timer for redrawing the screen
|
| 86 | + ViewNavigationCallback config_enter_callback; |
75 | 87 | } T5577WriterApp;
|
76 | 88 |
|
77 | 89 |
|
78 | 90 | typedef struct {
|
79 |
| - uint8_t modulation_index; // The index for modulation |
80 |
| - uint8_t rf_clock_index; // The index for RF clock |
| 91 | + uint8_t modulation_index; // The index for total number of pins |
| 92 | + uint8_t rf_clock_index; // The index for total number of pins |
81 | 93 | FuriString* tag_name_str; // The name setting
|
82 |
| - uint8_t user_block_num; // The total number of blocks to be used, i.e. signal length |
83 |
| - uint32_t* content; // The content, 8 blocks of uint32 |
| 94 | + uint8_t user_block_num; // The total number of pins we are adjusting |
| 95 | + uint32_t* content; // The cutting content |
84 | 96 | t5577_modulation modulation;
|
85 | 97 | t5577_rf_clock rf_clock;
|
86 |
| - bool data_loaded[3]; // The on/off knobs recording whether the config screen is showing loaded data |
87 |
| - uint8_t edit_block_slc; // Select the block to edit |
88 |
| - uint8_t writing_repeat_times; // How many times have the write command been sent |
| 98 | + bool data_loaded[3]; |
| 99 | + uint8_t edit_block_slc; |
| 100 | + uint8_t writing_repeat_times; |
89 | 101 | } T5577WriterModel;
|
90 | 102 |
|
91 | 103 | void initialize_config(T5577WriterModel* model) {
|
@@ -687,7 +699,12 @@ static T5577WriterApp* t5577_writer_app_alloc() {
|
687 | 699 | T5577WriterViewSave,
|
688 | 700 | app->view_save);
|
689 | 701 |
|
690 |
| - |
| 702 | + app->bytes_count = 4; |
| 703 | + memset(app->bytes_buffer, 0, sizeof(app->bytes_buffer)); |
| 704 | + |
| 705 | + app->byte_input = byte_input_alloc(); |
| 706 | + view_dispatcher_add_view( |
| 707 | + app->view_dispatcher, T5577WriterViewByteInput, byte_input_get_view(app->byte_input)); |
691 | 708 | app->variable_item_list_config = variable_item_list_alloc();
|
692 | 709 |
|
693 | 710 | app->view_config_e = view_alloc();
|
@@ -761,6 +778,7 @@ static void t5577_writer_app_free(T5577WriterApp* app) {
|
761 | 778 | view_free(app->view_load);
|
762 | 779 | view_dispatcher_remove_view(app->view_dispatcher, T5577WriterViewConfigure_i);
|
763 | 780 | view_dispatcher_remove_view(app->view_dispatcher, T5577WriterViewConfigure_e);
|
| 781 | + view_dispatcher_remove_view(app->view_dispatcher,T5577WriterViewByteInput); |
764 | 782 | variable_item_list_free(app->variable_item_list_config);
|
765 | 783 | view_dispatcher_remove_view(app->view_dispatcher, T5577WriterViewSave);
|
766 | 784 | view_free(app->view_save);
|
|
0 commit comments