From af8aedd1f6b467d9691399a93d4f0d55c02e8591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Wed, 20 Jan 2016 12:23:51 +0100 Subject: [PATCH] fix ascii check --- main.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/main.c b/main.c index 363b670..5f0f63a 100644 --- a/main.c +++ b/main.c @@ -239,14 +239,16 @@ static void vfd_digit(uint8_t nb, char c) if (false) { // add the comma (not encoded) vfd_data[1] |= (1<<(16)); } - - if (((c&0x7f)<' ') || ((c&0x7f)>' '+LENGTH(ascii_7segments)-1)) { // unknown ASCII character - vfd_data[1] = 0; // add empty segments to memory - } else { - vfd_data[1] |= (ascii_7segments[c-' ']<<(17)); // add encoded segments to memory - } - vfd_data[2] = 0; + c &= 0x7f; // only take the ASCII part + if (c>=' ') { // only take printable characters + uint8_t i = c-' '; // get index for character + if (i=' ')) { // only take printable characters + uint8_t i = c-' '; // get index for character if (i0x7f) { // the non ASCII character are used for pictures + uint8_t i = c-0x80; // get index for character if (i