From 58af8c275c2fcf4907351e1d2609e24f431ae64a Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 27 Oct 2009 00:09:15 +0000 Subject: more chars --- 7seg.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/7seg.c b/7seg.c index f2dcc77..8e4dae9 100644 --- a/7seg.c +++ b/7seg.c @@ -15,13 +15,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include #include -char allowed[] = "0123456789:.-ABCDEFabcdef"; +char allowed[] = " 0123456789:;.,-ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *seg[][3] = { + [' '] = { " ", " ", " " }, ['0'] = { " _ ", "| |", "|_|" }, ['1'] = { " ", " |", " |" }, ['2'] = { " _ ", " _|", "|_ " }, @@ -33,7 +35,9 @@ char *seg[][3] = { ['8'] = { " _ ", "|_|", "|_|" }, ['9'] = { " _ ", "|_|", " _|" }, [':'] = { " ", " * ", " * " }, + [';'] = { " ", " * ", " / " }, ['.'] = { " ", " ", " * " }, + [','] = { " ", " ", " / " }, ['-'] = { " ", " _ ", " " }, ['A'] = { " _ ", "|_|", "| |" }, ['B'] = { " ", "|_ ", "|_|" }, @@ -41,12 +45,26 @@ char *seg[][3] = { ['D'] = { " ", " _|", "|_|" }, ['E'] = { " _ ", "|_ ", "|_ " }, ['F'] = { " _ ", "|_ ", "| " }, - ['a'] = { " _ ", "|_|", "| |" }, - ['b'] = { " ", "|_ ", "|_|" }, - ['c'] = { " _ ", "| ", "|_ " }, - ['d'] = { " ", " _|", "|_|" }, - ['e'] = { " _ ", "|_ ", "|_ " }, - ['f'] = { " _ ", "|_ ", "| " }, + ['G'] = { " _ ", "| ", "|_|" }, + ['H'] = { " ", "|_ ", "| |" }, + ['I'] = { " ", " ", " |" }, + ['J'] = { " ", " |", "|_|" }, + ['K'] = { " _ ", "|_ ", "| |" }, + ['L'] = { " ", "| ", "|_ " }, + ['M'] = { " _ ", "| |", "| |" }, + ['N'] = { " ", " _ ", "| |" }, + ['O'] = { " ", " _ ", "|_|" }, + ['P'] = { " _ ", "|_|", "| " }, + ['Q'] = { " _ ", "|_|", " |" }, + ['R'] = { " ", " _ ", "| " }, + ['S'] = { " ", "|_ ", " _|" }, + ['T'] = { " ", "|_ ", "|_ " }, + ['U'] = { " ", " ", "|_|" }, + ['V'] = { " ", "| |", "|_|" }, + ['W'] = { " ", "| |", " _ " }, + ['X'] = { " ", "|_|", "| |" }, + ['Y'] = { " ", "|_|", " _|" }, + ['Z'] = { " _ ", " |", "|_ " }, }; char ** @@ -54,7 +72,7 @@ sevenseg(char *s) { size_t sz; char **t, *p; - int i; + int i, c; sz = 3 * strlen(s) + 1; @@ -62,8 +80,9 @@ sevenseg(char *s) for (i = 0; i < 3; i++) { t[i] = calloc(sz, sizeof(char)); for (p = s; *p; p++) { - if (strchr(allowed, *p) != NULL) - strlcat(t[i], seg[(int)*p][i], sz); + c = toupper(*p); + if (strchr(allowed, c) != NULL) + strlcat(t[i], seg[c][i], sz); } } -- cgit v1.2.3