Skip to content

Commit e2cbd73

Browse files
committed
refactor: drop useless extra variables far callbacks
1 parent e0722b7 commit e2cbd73

File tree

5 files changed

+15
-50
lines changed

5 files changed

+15
-50
lines changed

src/pages/about.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,10 @@ void about_loop(uint8_t *current_loop_count, uint8_t keys) {
4040
}
4141

4242
// Allow scrolling by one row by pressing up or down
43-
void (*about_me_scroll_row_up_handler)(void);
44-
about_me_scroll_row_up_handler = &handle_about_me_scroll_row_up;
45-
throttlekey(keys, J_UP, about_me_scroll_row_up_handler);
46-
47-
void (*about_me_scroll_row_down_handler)(void);
48-
about_me_scroll_row_down_handler = &handle_about_me_scroll_row_down;
49-
throttlekey(keys, J_DOWN, about_me_scroll_row_down_handler);
50-
43+
throttlekey(keys, J_UP, &handle_about_me_scroll_row_up);
44+
throttlekey(keys, J_DOWN, &handle_about_me_scroll_row_down);
5145
// Allow scrolling by one page by pressing A
52-
void (*about_me_scroll_page_down_handler)(void);
53-
about_me_scroll_page_down_handler = &handle_about_me_scroll_page_down;
54-
throttlekey(keys, J_A, about_me_scroll_page_down_handler);
46+
throttlekey(keys, J_A, &handle_about_me_scroll_page_down);
5547
}
5648

5749
#endif

src/pages/home_menu.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,10 @@ void home_menu_loop(uint8_t *current_loop_count, uint8_t keys) {
160160
set_page(current_menu_option + 2);
161161
}
162162

163-
void (*menu_navigation_up_handler)(void);
164-
menu_navigation_up_handler = &handle_menu_navigation_up;
165-
throttlekey(keys, J_UP, menu_navigation_up_handler);
166-
167-
void (*menu_navigation_right_handler)(void);
168-
menu_navigation_right_handler = &handle_menu_navigation_right;
169-
throttlekey(keys, J_RIGHT, menu_navigation_right_handler);
170-
171-
void (*menu_navigation_down_handler)(void);
172-
menu_navigation_down_handler = &handle_menu_navigation_down;
173-
throttlekey(keys, J_DOWN, menu_navigation_down_handler);
174-
175-
void (*menu_navigation_left_handler)(void);
176-
menu_navigation_left_handler = &handle_menu_navigation_left;
177-
throttlekey(keys, J_LEFT, menu_navigation_left_handler);
163+
throttlekey(keys, J_UP, &handle_menu_navigation_up);
164+
throttlekey(keys, J_RIGHT, &handle_menu_navigation_right);
165+
throttlekey(keys, J_DOWN, &handle_menu_navigation_down);
166+
throttlekey(keys, J_LEFT, &handle_menu_navigation_left);
178167
}
179168

180169
#endif

src/pages/projects.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,10 @@ void projects_loop(uint8_t *current_loop_count, uint8_t keys) {
5151
set_page(HOME_MENU);
5252
}
5353

54-
void (*projects_navigation_prev_handler)(void);
55-
projects_navigation_prev_handler = &handle_projects_navigation_prev;
56-
57-
void (*projects_navigation_next_handler)(void);
58-
projects_navigation_next_handler = &handle_projects_navigation_next;
59-
60-
throttlekey(keys, J_UP, projects_navigation_prev_handler);
61-
throttlekey(keys, J_RIGHT, projects_navigation_next_handler);
62-
throttlekey(keys, J_DOWN, projects_navigation_next_handler);
63-
throttlekey(keys, J_LEFT, projects_navigation_prev_handler);
54+
throttlekey(keys, J_UP, &handle_projects_navigation_prev);
55+
throttlekey(keys, J_RIGHT, &handle_projects_navigation_next);
56+
throttlekey(keys, J_DOWN, &handle_projects_navigation_next);
57+
throttlekey(keys, J_LEFT, &handle_projects_navigation_prev);
6458
}
6559

6660
#endif

src/pages/skills.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,10 @@ void skills_loop(uint8_t *current_loop_count, uint8_t keys) {
4242
}
4343

4444
// Allow scrolling by one row by pressing up or down
45-
void (*skills_scroll_row_up_handler)(void);
46-
skills_scroll_row_up_handler = &handle_skills_scroll_row_up;
47-
throttlekey(keys, J_UP, skills_scroll_row_up_handler);
48-
49-
void (*skills_scroll_row_down_handler)(void);
50-
skills_scroll_row_down_handler = &handle_skills_scroll_row_down;
51-
throttlekey(keys, J_DOWN, skills_scroll_row_down_handler);
52-
45+
throttlekey(keys, J_UP, &handle_skills_scroll_row_up);
46+
throttlekey(keys, J_DOWN, &handle_skills_scroll_row_down);
5347
// Allow scrolling by one page by pressing A
54-
void (*skills_scroll_page_down_handler)(void);
55-
skills_scroll_page_down_handler = &handle_skills_scroll_page_down;
56-
throttlekey(keys, J_A, skills_scroll_page_down_handler);
48+
throttlekey(keys, J_A, &handle_skills_scroll_page_down);
5749
}
5850

5951
#endif

src/portfolio.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ void main() {
2828
uint8_t keys = joypad();
2929

3030
// Allow switching theme by pressing Select
31-
void (*theme_change_handler)(void);
32-
theme_change_handler = &handle_theme_change;
33-
throttlekey(keys, J_SELECT, theme_change_handler);
31+
throttlekey(keys, J_SELECT, &handle_theme_change);
3432

3533
// Allow going back to the home header from any page
3634
// by pressing Start

0 commit comments

Comments
 (0)