From 034372f4bfd01d37f0749108564ca09ca58a51fe Mon Sep 17 00:00:00 2001 From: Sam Demeulemeester <38105886+x86fr@users.noreply.github.com> Date: Sun, 17 Jul 2022 20:20:52 +0200 Subject: [PATCH] Add much bigger PASS/FAIL banner (#113) The goal is to see the actual test result (PASS or FAIL) far away. --- app/display.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++- app/display.h | 8 +++++-- app/error.c | 4 ++++ app/main.c | 7 +++--- 4 files changed, 78 insertions(+), 6 deletions(-) diff --git a/app/display.c b/app/display.c index 71ac182..5b27186 100644 --- a/app/display.c +++ b/app/display.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2020-2022 Martin Whitaker. +// Copyright (C) 2004-2022 Sam Demeulemeester. #include #include @@ -31,6 +32,17 @@ // Constants //------------------------------------------------------------------------------ +#define POP_STAT_R 12 +#define POP_STAT_C 18 + +#define POP_STAT_W 44 +#define POP_STAT_H 9 + +#define POP_STAT_LAST_R (POP_STAT_R + POP_STAT_H - 1) +#define POP_STAT_LAST_C (POP_STAT_C + POP_STAT_W - 1) + +#define POP_STATUS_REGION POP_STAT_R, POP_STAT_C, POP_STAT_LAST_R, POP_STAT_LAST_C + #define SPINNER_PERIOD 100 // milliseconds #define NUM_SPIN_STATES 4 @@ -60,6 +72,9 @@ static uint64_t next_spin_time = 0; // TSC time stamp static int prev_sec = -1; // previous second static bool timed_update_done = false; // update cycle status +bool big_status_displayed = false; +static uint16_t popup_status_save_buffer[POP_STAT_W * POP_STAT_H]; + //------------------------------------------------------------------------------ // Variables //------------------------------------------------------------------------------ @@ -339,9 +354,57 @@ void display_temperature(void) printf(1, 20-offset, "%2i/%2i%cC", actual_cpu_temp, max_cpu_temp, 0xF8); } +void display_big_status(bool pass) +{ + if (big_status_displayed) { + return; + } + + save_screen_region(POP_STATUS_REGION, popup_status_save_buffer); + + set_background_colour(BLACK); + set_foreground_colour(pass ? GREEN : RED); + clear_screen_region(POP_STATUS_REGION); + + if (pass) { + prints(POP_STAT_R+1, POP_STAT_C+5, "###### ## ##### ##### "); + prints(POP_STAT_R+2, POP_STAT_C+5, "## ## #### ## ## ## ## "); + prints(POP_STAT_R+3, POP_STAT_C+5, "## ## ## ## ## ## "); + prints(POP_STAT_R+4, POP_STAT_C+5, "###### ## ## ##### ##### "); + prints(POP_STAT_R+5, POP_STAT_C+5, "## ######## ## ## "); + prints(POP_STAT_R+6, POP_STAT_C+5, "## ## ## ## ## ## ## "); + prints(POP_STAT_R+7, POP_STAT_C+5, "## ## ## ##### ##### "); + } else { + prints(POP_STAT_R+1, POP_STAT_C+5, "####### ## ###### ## "); + prints(POP_STAT_R+2, POP_STAT_C+5, "## #### ## ## "); + prints(POP_STAT_R+3, POP_STAT_C+5, "## ## ## ## ## "); + prints(POP_STAT_R+4, POP_STAT_C+5, "##### ## ## ## ## "); + prints(POP_STAT_R+5, POP_STAT_C+5, "## ######## ## ## "); + prints(POP_STAT_R+6, POP_STAT_C+5, "## ## ## ## ## "); + prints(POP_STAT_R+7, POP_STAT_C+5, "## ## ## ###### ###### "); + } + set_background_colour(BLUE); + set_foreground_colour(WHITE); + big_status_displayed = true; +} + +void restore_big_status(void) +{ + restore_screen_region(POP_STATUS_REGION, popup_status_save_buffer); + big_status_displayed = false; +} + void check_input(void) { - switch (get_key()) { + char input_key = get_key(); + + if (input_key == '\0') { + return; + } else if (big_status_displayed) { + restore_big_status(); + } + + switch (input_key) { case ESC: clear_message_area(); display_notice("Rebooting..."); diff --git a/app/display.h b/app/display.h index 16c5b7b..fc63401 100644 --- a/app/display.h +++ b/app/display.h @@ -200,10 +200,10 @@ typedef enum { printf(scroll_message_row, col, __VA_ARGS__) #define display_notice(str) \ - prints(ROW_MESSAGE_T + 6, (SCREEN_WIDTH - strlen(str)) / 2, str) + prints(ROW_MESSAGE_T + 8, (SCREEN_WIDTH - strlen(str)) / 2, str) #define display_notice_with_args(length, ...) \ - printf(ROW_MESSAGE_T + 6, (SCREEN_WIDTH - length) / 2, __VA_ARGS__) + printf(ROW_MESSAGE_T + 8, (SCREEN_WIDTH - length) / 2, __VA_ARGS__) #define clear_footer_message() \ { \ @@ -240,6 +240,10 @@ void display_start_test(void); void display_temperature(void); +void display_big_status(bool pass); + +void restore_big_status(void); + void check_input(void); void set_scroll_lock(bool enabled); diff --git a/app/error.c b/app/error.c index 8224147..af6fe83 100644 --- a/app/error.c +++ b/app/error.c @@ -369,6 +369,10 @@ void error_update(void) display_error_count(error_count); display_status("Failed!"); + if (error_count == 1) { + display_big_status(false); + } + if (enable_tty) { tty_error_redraw(); } diff --git a/app/main.c b/app/main.c index ab4e8db..e7fcbbd 100644 --- a/app/main.c +++ b/app/main.c @@ -4,8 +4,8 @@ // Derived from memtest86+ main.c: // // MemTest86+ V5 Specific code (GPL V2.0) -// By Samuel DEMEULEMEESTER, sdemeule@memtest.org -// http://www.canardpc.com - http://www.memtest.org +// By Samuel DEMEULEMEESTER, memtest@memtest.org +// https://www.memtest.org // ------------------------------------------------ // main.c - MemTest-86 Version 3.5 // @@ -664,7 +664,8 @@ void main(void) display_pass_count(pass_num); if (error_count == 0) { display_status("Pass "); - display_notice("** Pass completed, no errors **"); + display_big_status(true); + //display_notice("** Pass completed, no errors **"); } } }