@@ -16,6 +16,7 @@ typedef struct {
16
16
uint32_t file_read_bytes ;
17
17
uint32_t file_size ;
18
18
bool mode ;
19
+ uint32_t dbg ;
19
20
} HexViewerStartscreenModel ;
20
21
21
22
void hex_viewer_startscreen_set_callback (
@@ -95,6 +96,10 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
95
96
canvas_set_font (canvas , FontKeyboard );
96
97
canvas_draw_str (canvas , LEFT_OFFSET + 41 , TOP_OFFSET + i * ROW_HEIGHT , temp_buf );
97
98
}
99
+
100
+ // Poor man's debug
101
+ // snprintf(temp_buf, 32, "D %02lX", model->dbg);
102
+ // elements_button_right(canvas, temp_buf);
98
103
}
99
104
}
100
105
@@ -104,6 +109,7 @@ static void hex_viewer_startscreen_model_init(HexViewerStartscreenModel* const m
104
109
model -> file_read_bytes = 0 ;
105
110
model -> file_size = 0 ;
106
111
model -> mode = false;
112
+ model -> dbg = 0 ;
107
113
}
108
114
109
115
static void
@@ -118,6 +124,7 @@ static void
118
124
bool hex_viewer_startscreen_input (InputEvent * event , void * context ) {
119
125
furi_assert (context );
120
126
HexViewerStartscreen * instance = context ;
127
+ HexViewer * app = instance -> context ; // TO so good, but works
121
128
// TODO InputTypeShort?
122
129
if (event -> type == InputTypeRelease || event -> type == InputTypeRepeat ) {
123
130
switch (event -> key ) {
@@ -135,20 +142,17 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
135
142
with_view_model (
136
143
instance -> view ,
137
144
HexViewerStartscreenModel * model ,
138
- {
139
- //instance->callback(HexViewerCustomEventStartscreenLeft, instance->context);
140
- //update_local_model_from_app(instance->context, model);
141
- model -> mode = !model -> mode ;
142
- },
145
+ { model -> mode = !model -> mode ; },
143
146
true);
144
147
break ;
145
148
case InputKeyRight :
146
149
with_view_model (
147
150
instance -> view ,
148
151
HexViewerStartscreenModel * model ,
149
152
{
150
- instance -> callback (HexViewerCustomEventStartscreenRight , instance -> context );
151
- update_local_model_from_app (instance -> context , model );
153
+ // instance->callback(HexViewerCustomEventStartscreenRight, instance->context);
154
+ // update_local_model_from_app(instance->context, model);
155
+ // model->dbg = 0;
152
156
},
153
157
true);
154
158
break ;
@@ -157,7 +161,11 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
157
161
instance -> view ,
158
162
HexViewerStartscreenModel * model ,
159
163
{
160
- instance -> callback (HexViewerCustomEventStartscreenUp , instance -> context );
164
+ if (app -> model -> file_offset > 0 ) {
165
+ app -> model -> file_offset -= HEX_VIEWER_BYTES_PER_LINE ;
166
+ if (!hex_viewer_read_file (app )) break ; // TODO Do smth
167
+ }
168
+
161
169
update_local_model_from_app (instance -> context , model );
162
170
},
163
171
true);
@@ -167,7 +175,13 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
167
175
instance -> view ,
168
176
HexViewerStartscreenModel * model ,
169
177
{
170
- instance -> callback (HexViewerCustomEventStartscreenDown , instance -> context );
178
+ uint32_t last_byte_on_screen =
179
+ app -> model -> file_offset + app -> model -> file_read_bytes ;
180
+ if (app -> model -> file_size > last_byte_on_screen ) {
181
+ app -> model -> file_offset += HEX_VIEWER_BYTES_PER_LINE ;
182
+ if (!hex_viewer_read_file (app )) break ; // TODO Do smth
183
+ }
184
+
171
185
update_local_model_from_app (instance -> context , model );
172
186
},
173
187
true);
0 commit comments