From 424b184a9bab3b1b8fe93fbc9e8a6e9d566904c8 Mon Sep 17 00:00:00 2001 From: Leo C Date: Thu, 23 Oct 2014 02:15:50 +0200 Subject: my_getchar() parameter: allow return without new character --- avr/cli_readline.c | 4 ++-- avr/con-utils.c | 6 +++--- avr/main.c | 2 +- include/con-utils.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/avr/cli_readline.c b/avr/cli_readline.c index 17d5494..6b5f47e 100644 --- a/avr/cli_readline.c +++ b/avr/cli_readline.c @@ -74,7 +74,7 @@ static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen) #define CREAD_HIST_CHAR ('!') #define getcmd_putch(ch) putchar(ch) -#define getcmd_getch() my_getchar() +#define getcmd_getch() my_getchar(1) #define getcmd_cbeep() getcmd_putch('\a') #define HIST_MAX 5 @@ -500,7 +500,7 @@ static int cli_readline_into_buffer(const FLASH char *const prompt, char *buffer for (;;) { - c = my_getchar(); + c = my_getchar(1); /* * Special character handling diff --git a/avr/con-utils.c b/avr/con-utils.c index 02657b9..b8017ed 100644 --- a/avr/con-utils.c +++ b/avr/con-utils.c @@ -12,14 +12,14 @@ uint_fast8_t tstc(void) return serial_tstc(); } -int my_getchar(void) +int my_getchar(uint_fast8_t waitforchar) { int c; do { bg_shed(); c = serial_getc(); - } while (c < 0); + } while ((c < 0) && waitforchar); return c; } @@ -57,7 +57,7 @@ uint_fast8_t confirm_yesno(void) ; i = 0; while (i < sizeof(str_input)) { - str_input[i] = my_getchar(); + str_input[i] = my_getchar(1); putchar(str_input[i]); if (str_input[i] == '\r') break; diff --git a/avr/main.c b/avr/main.c index 2955630..2a1ecd3 100644 --- a/avr/main.c +++ b/avr/main.c @@ -144,7 +144,7 @@ static int abortboot(int bootdelay) */ if (bootdelay >= 0) { if (tstc()) { /* we got a key press */ - (void) my_getchar(); /* consume input */ + (void) my_getchar(1); /* consume input */ my_puts_P(PSTR("\b\b\b 0")); abort = 1; /* don't auto boot */ } diff --git a/include/con-utils.h b/include/con-utils.h index f03dfb3..15a3ce8 100644 --- a/include/con-utils.h +++ b/include/con-utils.h @@ -3,7 +3,7 @@ uint_fast8_t tstc(void); -int my_getchar(void); +int my_getchar(uint_fast8_t waitforchar); /* test if ctrl-c was pressed */ uint_fast8_t ctrlc(void); -- cgit v1.2.3