/* * Display the current menu in the context */ void menu_display(menu_context_t *context) { uint8_t i; menu_t *menu = context->menu; menu_entry_t *disp_entry; uint8_t dindex = 0; #ifndef CONFIG_TINYMENU_USE_CLEAR uint8_t j; #else menu_clear(); #endif // Display only those entries that will fit on the display for (i = 0; i < context->height; i++) { #ifndef CONFIG_TINYMENU_COMPACT // Don't display hidden menu entries do { disp_entry = &menu->entry[menu->top_entry + dindex]; if (dindex++ >= menu->num_entries - menu->top_entry) goto entries_done; } while (disp_entry->flags & MENU_FLAG_HIDDEN); #else disp_entry = &menu->entry[menu->top_entry + dindex]; if (dindex++ >= menu->num_entries - menu->top_entry) return; #endif // Go to correct x,y locations and print the entry menu_set_pos(context->x_loc, context->y_loc + i); menu_print_entry(disp_entry, context->width, (menu->current_entry == dindex - 1)); } entries_done: #ifndef CONFIG_TINYMENU_USE_CLEAR // Fill rest of menu screen space with spaces for (; i < context->height; i++) { menu_set_pos(context->x_loc, context->y_loc + i); for (j = 0; j < context->width; j++) { menu_putchar(' '); } } #endif }
void benchmark(void) { unsigned long i; int row, col; menu_settings_t* mset = &_menu_settings; menu_items_t * mitems = &_menu_items; int menu_selected; /* Init timer stuff. */ sc_tmr_start(); menu_reset_settings(mset); menu_reset_items(mitems); menu_set_title(mset, "Saturn Memory Benchmark"); menu_set_item(mitems, 0/*id*/, "Start Benchmarking ", 0/*tag*/); menu_set_item(mitems, 1/*id*/, "Init DRAM ", 1/*tag*/); menu_set_item(mitems, 2/*id*/, "Select test pattern ", 2/*tag*/); menu_set_item(mitems, 3/*id*/, "Hexedit on error ", 3/*tag*/); menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 7/*h*/, 1/*cols*/); menu_set_erase_on_exit(mset, 0); menu_set_callback_redraw(mset, display_bench_settings); menu_selected = 0; do { menu_selected = menu_start(mitems, mset, menu_selected/*selected_tag*/); if(mset->exit_code == MENU_EXIT_CANCEL) { return; } switch(menu_selected) { default: case(0): break; case(1): menu_clear_display(mset); my_RB_CartRAM_init(0/*CS0*/); bench_display_clear(); break; case(2): test_pattern = (test_pattern+1)%PATTERN_CNT; break; case(3): hexedit_on_error = hexedit_on_error ? 0 : 1; break; } } while(menu_selected != 0); /* User requested benchmark start, so clear settings menu. */ menu_clear_display(mset); /* Execute benchmarks. */ bench_display_clear(); row = 5, col = 2; for(i = 0; i < nBenches; i++) { unsigned short color; conio_printf(2, 4, COLOR_GREEN, "[%3d%%]Benchmarking \"%s\" ...", (100*i)/nBenches, benches[i].name); /* Perform bench. */ benches[i].function(benches + i); /* Display some data in order to keep user waiting ... */ display_bench_result(i); color = benches[i].status ? COLOR_YELLOW : COLOR_RED; conio_printf(col+ 0, row, color, "%s", benches[i].name); if(col==2) { col = 9; } else if(col==9) { col = 16; } else if(col==16) { col = 23; } else if(col==23) { col = 30; } else { col = 2; row++; } if(row >= BENCH_RESULT_STARTROW) { bench_display_clear(); row = 5; col = 2; } } prompt_start();//TMP? /* Display benchmark results. */ bench_display_clear(); menu_reset_settings(mset); menu_reset_items(mitems); menu_set_title(mset, "Benchmark Results"); menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 12/*h*/, 1/*cols*/); menu_set_erase_on_exit(mset, 1); menu_set_features(mset, MENU_FEATURES_TEXTCENTER); menu_set_callback_getstr(mset, get_bench_name); menu_set_callback_redraw(mset, display_bench_result); menu_selected = 0; menu_selected = menu_list_start(NULL/*Items Array*/, nBenches, mset, menu_selected, NULL/*selection*/); }