Skip to content

Commit 1060f59

Browse files
committed
fix: Major bugs fixe
1 parent 1fba658 commit 1060f59

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

hex_viewer.h

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ typedef struct {
5353
// TODO Clean
5454
typedef struct {
5555
HexViewerModel* model;
56-
//FuriMutex** mutex; // TODO Don't need?
5756

5857
Gui* gui;
5958
Storage* storage;

scenes/hex_viewer_scene_startscreen.c

+1-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ void hex_viewer_scene_startscreen_on_enter(void* context) {
1919
bool hex_viewer_scene_startscreen_on_event(void* context, SceneManagerEvent event) {
2020
HexViewer* app = context;
2121
bool consumed = false;
22-
uint32_t last_byte_on_screen;
2322

2423
if(event.type == SceneManagerEventTypeCustom) {
2524
switch(event.event) {
@@ -32,27 +31,13 @@ bool hex_viewer_scene_startscreen_on_event(void* context, SceneManagerEvent even
3231
consumed = true;
3332
break;
3433
case HexViewerCustomEventStartscreenUp:
35-
//furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
36-
if(app->model->file_offset > 0) {
37-
app->model->file_offset -= HEX_VIEWER_BYTES_PER_LINE;
38-
if(!hex_viewer_read_file(app)) break; // TODO Do smth
39-
}
4034
consumed = true;
41-
//furi_mutex_release(hex_viewer->mutex);
4235
break;
4336
case HexViewerCustomEventStartscreenDown:
44-
//furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
45-
last_byte_on_screen = app->model->file_offset + app->model->file_read_bytes;
46-
47-
if(app->model->file_size > last_byte_on_screen) {
48-
app->model->file_offset += HEX_VIEWER_BYTES_PER_LINE;
49-
if(!hex_viewer_read_file(app)) break; // TODO Do smth
50-
}
5137
consumed = true;
52-
//furi_mutex_release(hex_viewer->mutex);
5338
break;
5439
case HexViewerCustomEventStartscreenOk:
55-
if(!app->model->file_size) // TODO
40+
if(!app->model->file_size)
5641
scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_4);
5742
else
5843
scene_manager_next_scene(app->scene_manager, HexViewerSceneMenu);

views/hex_viewer_startscreen.c

+23-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ typedef struct {
1616
uint32_t file_read_bytes;
1717
uint32_t file_size;
1818
bool mode;
19+
uint32_t dbg;
1920
} HexViewerStartscreenModel;
2021

2122
void hex_viewer_startscreen_set_callback(
@@ -95,6 +96,10 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
9596
canvas_set_font(canvas, FontKeyboard);
9697
canvas_draw_str(canvas, LEFT_OFFSET + 41, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
9798
}
99+
100+
// Poor man's debug
101+
// snprintf(temp_buf, 32, "D %02lX", model->dbg);
102+
// elements_button_right(canvas, temp_buf);
98103
}
99104
}
100105

@@ -104,6 +109,7 @@ static void hex_viewer_startscreen_model_init(HexViewerStartscreenModel* const m
104109
model->file_read_bytes = 0;
105110
model->file_size = 0;
106111
model->mode = false;
112+
model->dbg = 0;
107113
}
108114

109115
static void
@@ -118,6 +124,7 @@ static void
118124
bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
119125
furi_assert(context);
120126
HexViewerStartscreen* instance = context;
127+
HexViewer* app = instance->context; // TO so good, but works
121128
// TODO InputTypeShort?
122129
if(event->type == InputTypeRelease || event->type == InputTypeRepeat) {
123130
switch(event->key) {
@@ -135,20 +142,17 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
135142
with_view_model(
136143
instance->view,
137144
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; },
143146
true);
144147
break;
145148
case InputKeyRight:
146149
with_view_model(
147150
instance->view,
148151
HexViewerStartscreenModel * model,
149152
{
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;
152156
},
153157
true);
154158
break;
@@ -157,7 +161,11 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
157161
instance->view,
158162
HexViewerStartscreenModel * model,
159163
{
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+
161169
update_local_model_from_app(instance->context, model);
162170
},
163171
true);
@@ -167,7 +175,13 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
167175
instance->view,
168176
HexViewerStartscreenModel * model,
169177
{
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+
171185
update_local_model_from_app(instance->context, model);
172186
},
173187
true);

0 commit comments

Comments
 (0)