From 22bb227bc70e51ef999d7bc696cb3a7595dcf7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 24 Oct 2021 14:50:07 +0200 Subject: [PATCH] Add a few comments --- stm-firmware/shell.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/stm-firmware/shell.c b/stm-firmware/shell.c index 432ea72..87c8ed9 100644 --- a/stm-firmware/shell.c +++ b/stm-firmware/shell.c @@ -484,7 +484,7 @@ static shellmatta_retCode_t shell_cmd_ui_emulation(const shellmatta_handle_t han char *buff; uint8_t row; uint8_t col; - bool differs = false; + bool disp_content_differs = false; static char IN_SECTION(.ccm.bss) display_buffer[4][21] = {0}; const char (*current_display)[21]; @@ -516,6 +516,10 @@ static shellmatta_retCode_t shell_cmd_ui_emulation(const shellmatta_handle_t han button_override_event(BUTTON_LONG_RELEASED); break; case '\x03': + /* CTRL-C received. Delete the display buffer so it will be updated the next time + * This function is called. + * Otherwise the diplay might not be printed to the console if nothing has changed + */ display_buffer[0][0] = 0; display_buffer[1][0] = 0; display_buffer[2][0] = 0; @@ -531,16 +535,17 @@ static shellmatta_retCode_t shell_cmd_ui_emulation(const shellmatta_handle_t han for (col = 0; col < 21; col++) { if (current_display[row][col] != display_buffer[row][col]) { display_buffer[row][col] = current_display[row][col]; - differs = true; + disp_content_differs = true; } } display_buffer[row][20] = 0; } - - if (differs) { + if (disp_content_differs) { /* Clear the display */ shellmatta_printf(handle, "\e[2J\e[H"); + + /* Print out the rows of the LCD to console */ for (row = 0; row < 4; row++) { shellmatta_printf(handle, "%s\r\n", &display_buffer[row][0]); }