summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2009-10-26 02:45:44 +0000
committerDimitri Sokolyuk <demon@dim13.org>2009-10-26 02:45:44 +0000
commitb8d8ee2340c82a2859dc2a55aa0c5fd31058790f (patch)
tree22eb752fb2593dcb50fc839a2906c0934bebd3c0
parent46671692abb78f943d5493168a7f69849b5b1d26 (diff)
add more chars
-rw-r--r--7seg.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/7seg.c b/7seg.c
index bc7a01c..280c459 100644
--- a/7seg.c
+++ b/7seg.c
@@ -18,17 +18,22 @@
#include <stdio.h>
#include <stdlib.h>
+char allowed[] = "0123456789:.-";
+
char *seg[][3] = {
- [0] = { " _ ", "| |", "|_|" },
- [1] = { " ", " |", " |" },
- [2] = { " _ ", " _|", "|_ " },
- [3] = { " _ ", " _|", " _|" },
- [4] = { " ", "|_|", " |" },
- [5] = { " _ ", "|_ ", " _|" },
- [6] = { " _ ", "|_ ", "|_|" },
- [7] = { " _ ", " |", " |" },
- [8] = { " _ ", "|_|", "|_|" },
- [9] = { " _ ", "|_|", " _|" }
+ ['0'] = { " _ ", "| |", "|_|" },
+ ['1'] = { " ", " |", " |" },
+ ['2'] = { " _ ", " _|", "|_ " },
+ ['3'] = { " _ ", " _|", " _|" },
+ ['4'] = { " ", "|_|", " |" },
+ ['5'] = { " _ ", "|_ ", " _|" },
+ ['6'] = { " _ ", "|_ ", "|_|" },
+ ['7'] = { " _ ", " |", " |" },
+ ['8'] = { " _ ", "|_|", "|_|" },
+ ['9'] = { " _ ", "|_|", " _|" },
+ [':'] = { " ", " * ", " * " },
+ ['.'] = { " ", " ", " * " },
+ ['-'] = { " ", " _ ", " " },
};
char **
@@ -44,9 +49,8 @@ sevenseg(char *s)
for (i = 0; i < 3; i++) {
t[i] = calloc(sz, sizeof(char));
for (p = s; *p; p++) {
- if (*p < '0' || *p > '9')
- continue;
- strlcat(t[i], seg[*p - '0'][i], sz);
+ if (strchr(allowed, *p) != NULL)
+ strlcat(t[i], seg[*p][i], sz);
}
}