Skip to content

Commit eb28dc2

Browse files
authored
Merge pull request RogueMaster#50 from darmiel/fix/infrared-buttons
fix[infrared]: fixed crash if button out of bounds and sending wrong signals
2 parents 66e3617 + 92db5e1 commit eb28dc2

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

applications/gui/modules/button_panel.c

+9
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ ButtonPanel* button_panel_alloc() {
8383
return button_panel;
8484
}
8585

86+
void button_panel_reset_selection(ButtonPanel* button_panel) {
87+
with_view_model(
88+
button_panel->view, (ButtonPanelModel * model) {
89+
model->selected_item_x = 0;
90+
model->selected_item_y = 0;
91+
return true;
92+
});
93+
}
94+
8695
void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t reserve_y) {
8796
furi_check(reserve_x > 0);
8897
furi_check(reserve_y > 0);

applications/gui/modules/button_panel.h

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ void button_panel_free(ButtonPanel* button_panel);
3535
*/
3636
void button_panel_reset(ButtonPanel* button_panel);
3737

38+
/** Resets selected_item_x and selected_item_y.
39+
*
40+
* @param button_panel ButtonPanel instance
41+
*/
42+
void button_panel_reset_selection(ButtonPanel* button_panel);
43+
3844
/** Reserve space for adding items.
3945
*
4046
* One does not simply use button_panel_add_item() without this function. It

applications/infrared/infrared_brute_force.c

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ InfraredBruteForce* infrared_brute_force_alloc() {
3535
return brute_force;
3636
}
3737

38+
void infrared_brute_force_clear_records(InfraredBruteForce* brute_force) {
39+
InfraredBruteForceRecordDict_reset(brute_force->records);
40+
}
41+
3842
void infrared_brute_force_free(InfraredBruteForce* brute_force) {
3943
furi_assert(!brute_force->ff);
4044
InfraredBruteForceRecordDict_clear(brute_force->records);

applications/infrared/infrared_brute_force.h

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ bool infrared_brute_force_start(
1616
bool infrared_brute_force_is_started(InfraredBruteForce* brute_force);
1717
void infrared_brute_force_stop(InfraredBruteForce* brute_force);
1818
bool infrared_brute_force_send_next(InfraredBruteForce* brute_force);
19+
void infrared_brute_force_clear_records(InfraredBruteForce* brute_force);
1920
void infrared_brute_force_add_record(
2021
InfraredBruteForce* brute_force,
2122
uint32_t index,

applications/infrared/scenes/common/infrared_scene_universal_common.c

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static void infrared_scene_universal_common_hide_popup(Infrared* infrared) {
3333

3434
void infrared_scene_universal_common_on_enter(void* context) {
3535
Infrared* infrared = context;
36+
infrared_brute_force_clear_records(infrared->brute_force);
37+
button_panel_reset_selection(infrared->button_panel);
3638
view_stack_add_view(infrared->view_stack, button_panel_get_view(infrared->button_panel));
3739
}
3840

0 commit comments

Comments
 (0)