enhancing the seven segments display

This commit is contained in:
Tonton Th 2019-01-27 11:36:51 +01:00
parent ace7312470
commit 5e0d33cfe1

View File

@ -25,41 +25,48 @@ for (foo=0; foo<9; foo++) {
mvwhline(win, lig+foo, col, '~', 6); mvwhline(win, lig+foo, col, '~', 6);
} }
#define KC '+'
#define KS "++++"
wstandout(win); wstandout(win);
for (numbit=0; numbit<8; numbit++) { for (numbit=0; numbit<8; numbit++) {
mask = 1 << numbit; mask = 1 << numbit;
switch(mask & bits) { switch(mask & bits) {
case 0x01: case 0x01:
mvwaddstr(win, lig, col+1, " "); mvwaddstr(win, lig, col+1, KS);
break; break;
case 0x02: case 0x02:
mvwaddch(win, lig+1, col+5, ' '); mvwaddch(win, lig+1, col+5, KC);
mvwaddch(win, lig+2, col+5, ' '); mvwaddch(win, lig+2, col+5, KC);
mvwaddch(win, lig+3, col+5, ' '); mvwaddch(win, lig+3, col+5, KC);
break; break;
case 0x04: case 0x04:
mvwaddch(win, lig+5, col+5, ' '); mvwaddch(win, lig+5, col+5, KC);
mvwaddch(win, lig+6, col+5, ' '); mvwaddch(win, lig+6, col+5, KC);
mvwaddch(win, lig+7, col+5, ' '); mvwaddch(win, lig+7, col+5, KC);
break; break;
case 0x08: case 0x08:
mvwaddstr(win, lig+8, col+1, " "); mvwaddstr(win, lig+8, col+1, KS);
break; break;
case 0x10: case 0x10:
mvwaddch(win, lig+5, col, ' '); mvwaddch(win, lig+5, col, KC);
mvwaddch(win, lig+6, col, ' '); mvwaddch(win, lig+6, col, KC);
mvwaddch(win, lig+7, col, ' '); mvwaddch(win, lig+7, col, KC);
break; break;
case 0x20: case 0x20:
mvwaddch(win, lig+1, col , ' '); mvwaddch(win, lig+1, col , KC);
mvwaddch(win, lig+2, col , ' '); mvwaddch(win, lig+2, col , KC);
mvwaddch(win, lig+3, col , ' '); mvwaddch(win, lig+3, col , KC);
break; break;
case 0x40: case 0x40:
mvwaddstr(win, lig+4, col+1, " "); mvwaddstr(win, lig+4, col+1, KS);
break; break;
case 0x80: case 0x80:
/* decimal point */ /* decimal point */
mvwaddch(win, lig+7, col+2 , KC);
mvwaddch(win, lig+7, col+3 , KC);
mvwaddch(win, lig+8, col+2 , KC);
mvwaddch(win, lig+8, col+3 , KC);
break; break;
} }
@ -79,10 +86,6 @@ fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__,
win, lig, col, digit); win, lig, col, digit);
#endif #endif
if (!isdigit(digit)) {
return -1;
}
switch (digit) { switch (digit) {
case '0': bits = 0x3f; break; case '0': bits = 0x3f; break;
case '1': bits = 0x06; break; case '1': bits = 0x06; break;
@ -95,9 +98,10 @@ switch (digit) {
case '8': bits = 0x7f; break; case '8': bits = 0x7f; break;
case '9': bits = 0x6f; break; case '9': bits = 0x6f; break;
default: case ' ': bits = 0; break;
bits = 0x40; case '.': bits = 0x80; break;
break;
default: bits = 0x09; break;
} }
aff7segs_base(win, lig, col, bits, 0); aff7segs_base(win, lig, col, bits, 0);