7#define BIG_FONT &OLED_FONT_8x8
8#define MEDIUM_FONT &OLED_FONT_5x7
9#define SMALL_FONT &OLED_FONT_4x6
45 for (uint8_t i = 0; i <
menu->length; i++) {
105 for (uint8_t i = 0; i <
menu->length; i++) {
157 for (uint8_t i = 0; i <
menu->length; i++) {
159 if (i ==
menu->cursor_pos) {
163 for (uint8_t j = 0; j < 6; j++) {
181 static uint8_t prev_ND = 0;
182 static uint8_t prev_NU = 0;
188 if (
btn->ND && !prev_ND) {
191 if (
menu->cursor_pos >=
menu->length) {
192 menu->cursor_pos = 0;
196 else if (
btn->NU && !prev_NU) {
199 if (
menu->cursor_pos < 0) {
200 menu->cursor_pos =
menu->length - 1;
218 static uint8_t prev_NR = 0;
220 if(
btn->NR && !prev_NR) {
234 menu->cursor_pos = 0;
261 if (
menu->current_page == page) {
265 menu->current_page = page;
279 switch (
menu->current_page) {
304 static uint8_t prev_NL = 0;
306 if(
btn->NL && !prev_NL) {
313 menu->cursor_pos = 0;
316 if(
menu->items ==
menu->root_items) {
318 menu->parent_length = 0;
323 menu->parent_menu =
menu->root_items;
324 menu->parent_length =
menu->root_length;
342 static uint16_t game_over_timer = 0;
345 if(game_over_timer == 0) {
351 if(game_over_timer > 20) {
357 menu->cursor_pos = 0;
361 menu->parent_length = 0;
int io_oled_clear_all(struct io_oled_device *dev)
Clears all lines on the OLED (fills entire display with black).
int io_oled_clear_line(struct io_oled_device *dev, int line)
Clear specific line in OLED.
int io_oled_home(struct io_oled_device *dev)
Loads homescreen to OLED.
int io_oled_write_data(struct io_oled_device *dev, uint8_t data)
int io_oled_pos(struct io_oled_device *dev, int row, int column)
Set specific position in OLED.
int io_oled_print_with_font(struct io_oled_device *dev, const struct oled_font *font, char *text)
Prints an arrow at a specified postion.
int io_oled_init(struct io_oled_device *dev)
Initialise OLED.
int menu_init(struct menu_cfg *menu)
Initializes the menu struct and OLED display.
int cursor_update(struct menu_cfg *menu, struct io_avr_buttons *btn)
Updates the cursor position based on nav button from the IO board. Wraps around if going out of bound...
int menu_handler(struct menu_cfg *menu, struct io_avr_buttons *btn)
Handles menu logic based on current page and button inputs from the IO board.
int draw_cursor(struct menu_cfg *menu)
Draws the cursor (">") at the current cursor position in the menu.
int high_scores_display(struct menu_cfg *menu)
Displays the high scores page.
int welcome_display(struct menu_cfg *menu)
Displays the welcome page.
int game_over_display(struct menu_cfg *menu)
page_id
Menu page identifiers.
int set_page(struct menu_cfg *menu, enum page_id page)
Sets the current page field in the menu struct to a specified page and calls the page_dispatch functi...
int page_back(struct menu_cfg *menu, struct io_avr_buttons *btn)
int play_game_display(struct menu_cfg *menu)
Displays the play game page.
int brightness_display(struct menu_cfg *menu)
int page_select(struct menu_cfg *menu, struct io_avr_buttons *btn)
Selects the current menu item based on nav button from the IO board.
int page_dispatch(struct menu_cfg *menu)
Dispatches to the appropriate page display function based on the current page field in the menu struc...
int calibrate_joystick_display(struct menu_cfg *menu)
int settings_display(struct menu_cfg *menu)
Displays the settings page.
@ PAGE_CALIBRATE_JOYSTICK
Driver for joystick, buttons, and OLED.
struct io_avr_buttons btn
Utility and helper functions for joystick, LED debugging, and mapping.