Skip to content

Commit 13279fb

Browse files
committed
restart add manually. views added.
1 parent 47e7438 commit 13279fb

File tree

1 file changed

+44
-26
lines changed

1 file changed

+44
-26
lines changed

t5577_writer.c

+44-26
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <gui/modules/popup.h>
77
#include <gui/modules/submenu.h>
88
#include <gui/modules/text_input.h>
9+
#include <gui/modules/byte_input.h>
910
#include <gui/modules/widget.h>
1011
#include <gui/modules/variable_item_list.h>
1112
#include <notification/notification.h>
@@ -34,58 +35,69 @@ typedef enum {
3435
T5577WriterSubmenuIndexAbout,
3536
} T5577WriterSubmenuIndex;
3637

38+
// Each view is a screen we show the user.
3739
typedef enum {
38-
T5577WriterViewSubmenu,
39-
T5577WriterViewTextInput,
40+
T5577WriterViewSubmenu, // The menu when the app starts
41+
T5577WriterViewTextInput, // Input for configuring text settings
42+
T5577WriterViewByteInput,
4043
T5577WriterViewLoad,
4144
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.
4650
} T5577WriterView;
4751

4852
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
5155
} T5577WriterEventId;
5256

5357
typedef struct {
5458
ViewDispatcher* view_dispatcher; // Switches between our views
5559
NotificationApp* notifications; // Used for controlling the backlight
5660
Submenu* submenu; // The application menu
61+
5762
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
6268
Widget* widget_about; // The about screen
6369
View* view_load; // The load view
6470

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+
6980
char* temp_buffer; // Temporary buffer for text input
7081
uint32_t temp_buffer_size; // Size of temporary buffer
7182

72-
DialogsApp* dialogs; // dialog for file browser
73-
FuriString* file_path; // apps_data/t5577_writer
83+
DialogsApp* dialogs;
84+
FuriString* file_path;
7485
FuriTimer* timer; // Timer for redrawing the screen
86+
ViewNavigationCallback config_enter_callback;
7587
} T5577WriterApp;
7688

7789

7890
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
8193
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
8496
t5577_modulation modulation;
8597
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;
89101
} T5577WriterModel;
90102

91103
void initialize_config(T5577WriterModel* model) {
@@ -687,7 +699,12 @@ static T5577WriterApp* t5577_writer_app_alloc() {
687699
T5577WriterViewSave,
688700
app->view_save);
689701

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));
691708
app->variable_item_list_config = variable_item_list_alloc();
692709

693710
app->view_config_e = view_alloc();
@@ -761,6 +778,7 @@ static void t5577_writer_app_free(T5577WriterApp* app) {
761778
view_free(app->view_load);
762779
view_dispatcher_remove_view(app->view_dispatcher, T5577WriterViewConfigure_i);
763780
view_dispatcher_remove_view(app->view_dispatcher, T5577WriterViewConfigure_e);
781+
view_dispatcher_remove_view(app->view_dispatcher,T5577WriterViewByteInput);
764782
variable_item_list_free(app->variable_item_list_config);
765783
view_dispatcher_remove_view(app->view_dispatcher, T5577WriterViewSave);
766784
view_free(app->view_save);

0 commit comments

Comments
 (0)