X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/2f7e8f0d886a19a7407e80fa8e5e7b064237b3fc..0b162010a8ae6d401564797c5122394857965ab9:/badge/ui/menu.c diff --git a/badge/ui/menu.c b/badge/ui/menu.c index 79e2e8a..3235838 100644 --- a/badge/ui/menu.c +++ b/badge/ui/menu.c @@ -19,8 +19,8 @@ static badge_sprite const arrows[] = { }; enum { - MENU_MARGIN_TOP = 2, - MENU_MARGIN_BOTTOM = 3, + MENU_MARGIN_TOP = 3, + MENU_MARGIN_BOTTOM = 2, MENU_MARGIN_LEFT = 3, MENU_ENTRIES_HEIGHT = 1 + BADGE_FONT_HEIGHT, MENU_ENTRIES_VISIBLE = (BADGE_DISPLAY_HEIGHT - MENU_MARGIN_TOP - MENU_MARGIN_BOTTOM) / MENU_ENTRIES_HEIGHT @@ -39,6 +39,10 @@ static void badge_menu_show(char const *const *menu, size_t first_used_row = 0; size_t used_rows = MENU_ENTRIES_VISIBLE; + if(selected >= n) { + selected = n - 1; + } + if(n <= MENU_ENTRIES_VISIBLE) { *first_visible = 0; used_rows = n;