X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/d684c21619905153eff68c43927207248925f6c2..5f7f3586b0444116d5c1340465ecae8d6daa2461:/avr/con-utils.c?ds=inline diff --git a/avr/con-utils.c b/avr/con-utils.c index 430ba98..f20dbfe 100644 --- a/avr/con-utils.c +++ b/avr/con-utils.c @@ -1,30 +1,39 @@ +/* + * (C) Copyright 2014 Leo C. + * + * SPDX-License-Identifier: GPL-2.0+ + */ #include -#include +#include "common.h" #include "serial.h" +#include "background.h" #include "con-utils.h" - uint_fast8_t tstc(void) { + bg_shed(); return serial_tstc(); } -int my_getchar(void) +int my_getchar(uint_fast8_t waitforchar) { int c; - - while((c = serial_getc()) < 0) - ; + + do { + bg_shed(); + c = serial_getc(); + } while ((c < 0) && waitforchar); + return c; } /* test if ctrl-c was pressed */ -static uint_fast8_t ctrlc_disabled = 0; /* see disable_ctrl() */ -static uint_fast8_t ctrlc_was_pressed = 0; +static uint_fast8_t ctrlc_disabled; /* see disable_ctrl() */ +static uint_fast8_t ctrlc_was_pressed; uint_fast8_t ctrlc(void) { @@ -53,7 +62,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; @@ -88,4 +97,3 @@ void clear_ctrlc(void) { ctrlc_was_pressed = 0; } -