diff --git a/ui.c b/ui.c index 981fa53..32096a5 100644 --- a/ui.c +++ b/ui.c @@ -70,6 +70,18 @@ void ui_msg(const char *txt) static uint8_t display_cur_v = 0; static uint8_t menu_selection = 0; +void ui_menu_autoscroll(void) +{ + int lines = CurrentMenu->entry_n; + if ((lines < 5) || (menu_selection < 2)) + display_cur_v = 0; + else if (menu_selection > lines - 2) + display_cur_v = 0x40 - ((lines - 4) * 8); + else + display_cur_v = 0x40 - ((menu_selection - 2) * 8); + display_scroll(NULL, display_cur_v); +} + static void ui_display_menu_refresh(void) { const struct display_menu *menu = CurrentMenu; @@ -78,8 +90,8 @@ static void ui_display_menu_refresh(void) display_scroll(NULL, display_cur_v); display_clear(NULL); - for (i = menu->entry_n - 1; i >= 0; i--) { - vline = i + 5; + for (i = 0; i < menu->entry_n; i++) { + vline = i + 4; if (vline > 7) vline -= 8; if (i == menu_selection) @@ -118,30 +130,17 @@ void ui_button_press(uint8_t b, int hold) if (b == '-') { if (menu_selection > 0) { menu_selection--; - if ((display_cur_v / 8) - (menu_selection > 2)) { - int s; - s = display_cur_v + 8; - if (s > 0x3f) - s = 0; - display_cur_v = (uint8_t)s; - display_scroll(NULL, display_cur_v); - } + ui_menu_autoscroll(); + ui_display_menu_refresh(); } } if (b == '+') { if (menu_selection < CurrentMenu->entry_n - 1) { menu_selection++; - if ((menu_selection - display_cur_v / 8) > 2) { - int s; - s = display_cur_v - 8; - if (s < 0) - s = 0x40 - 8; - display_cur_v = (uint8_t)s; - display_scroll(NULL, display_cur_v); - } + ui_menu_autoscroll(); + ui_display_menu_refresh(); } } - ui_display_menu_refresh(); } void ui_init(void) diff --git a/user_settings.h b/user_settings.h deleted file mode 100644 index c61dbc7..0000000 --- a/user_settings.h +++ /dev/null @@ -1,56 +0,0 @@ -/* user_settings.h - */ - -#ifndef H_USER_SETTINGS_ -#define H_USER_SETTINGS_ - -/* System */ -#define WOLFSSL_GENERAL_ALIGNMENT 4 -#define SINGLE_THREADED -//#define WOLFSSL_SMALL_STACK -#define WOLFCRYPT_ONLY -#define TFM_TIMING_RESISTANT -#define HAVE_CHACHA -#define HAVE_SHA256 -#define HAVE_PBKDF2 -#define HAVE_AES -#define HAVE_AES_CBC -#define HAVE_AES_DECRYPT - -#define CUSTOM_RAND_GENERATE random_uint32 -#define CUSTOM_RAND_TYPE uint32_t - - -#define WOLFSSL_SP -#define WOLFSSL_SP_SMALL -#define WOLFSSL_SP_MATH -#define SP_WORD_SIZE 32 -#define SINGLE_THREADED - -/* Disables - For minimum wolfCrypt build */ -#define NO_CMAC -#define NO_CODING -#define NO_RSA -#define NO_BIG_INT -#define NO_ASN -#define NO_RC4 -#define NO_SHA -#define NO_DH -#define NO_DSA -#define NO_MD4 -#define NO_RABBIT -#define NO_MD5 -#define NO_SIG_WRAPPER -#define NO_CERT -#define NO_SESSION_CACHE -#define NO_HC128 -#define NO_DES3 -#define NO_WRITEV -#define NO_DEV_RANDOM -#define NO_FILESYSTEM -#define NO_MAIN_DRIVER -#define NO_OLD_RNGNAME -#define NO_WOLFSSL_DIR -#define WOLFSSL_NO_SOCK - -#endif /* !H_USER_SETTINGS_ */