From 66c611795e1e5ff2226c0b6de9e1c2fe4886e545 Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Fri, 5 Apr 2019 00:47:21 -0400 Subject: [PATCH] allow printing unknown characters in lcd emulator --- src/lcd_emulator.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/lcd_emulator.c b/src/lcd_emulator.c index 78841e4..87278fb 100644 --- a/src/lcd_emulator.c +++ b/src/lcd_emulator.c @@ -92,26 +92,29 @@ short TERMIO_PutChar(unsigned char letter) { } else { to_row(0); } - } else if (is_valid_character(letter)) { - if (letter == CGRAM_EXP){ - lcd_buf[lcd_row][lcd_col] = 'E'; - } else if (letter == CGRAM_EXP_NEG) { - lcd_buf[lcd_row][lcd_col] = '-'; - } else { - lcd_buf[lcd_row][lcd_col] = letter; - } - lcd_col++; - if (lcd_col >= MAX_CHARS_PER_LINE) { - if (lcd_row == 0) { - to_row(1); - } else { - to_row(0); - } - } - } else { + } + //warn if unknown character + if (!is_valid_character(letter)) { printf("\nerror @%d,%d, invalid character %d\n", lcd_row, lcd_col, letter); } + //add character to buf + if (letter == CGRAM_EXP){ + lcd_buf[lcd_row][lcd_col] = 'E'; + } else if (letter == CGRAM_EXP_NEG) { + lcd_buf[lcd_row][lcd_col] = '-'; + } else { + lcd_buf[lcd_row][lcd_col] = letter; + } + lcd_col++; + //check if new line + if (lcd_col >= MAX_CHARS_PER_LINE) { + if (lcd_row == 0) { + to_row(1); + } else { + to_row(0); + } + } return 1; }