Browse code

introdicing the so cute minidigits !

tth authored on 05/02/2019 11:16:27
Showing 7 changed files
1 1
new file mode 100644
2 2
new file mode 100644
... ...
@@ -1,7 +1,9 @@
1 1
 # ---------------				***
2 2
 
3 3
 COPT = -Wall -g -fpic -DTRACE=0 
4
-OBJS = ecran.o 7segments.o waterfall.o vumetre.o
4
+OBJS = ecran.o 7segments.o waterfall.o vumetre.o \
5
+	minidigits.o
6
+
5 7
 ALIB = ../libdd2m-viz.a
6 8
 
7 9
 # ---------------				***
... ...
@@ -23,6 +25,9 @@ waterfall.o:	waterfall.c Makefile ecran.h
23 23
 vumetre.o:	vumetre.c Makefile ecran.h
24 24
 	gcc $(COPT) -c $< 
25 25
 
26
+minidigits.o:	minidigits.c Makefile ecran.h
27
+	gcc $(COPT) -c $< 
28
+
26 29
 # ---------------				***
27 30
 
28 31
 t:	t.c Makefile $(ALIB) ecran.h
... ...
@@ -21,7 +21,7 @@ fprintf(stderr, "%s [%s]\n", __func__, txt);
21 21
 #endif
22 22
 
23 23
 standout();
24
-mvhline(LINES-1, 0, '~', COLS);
24
+mvhline(LINES-1, 0, ' ', COLS);
25 25
 mvaddch(LINES-1, 0, "\\|/-"[(pass++)%4]);
26 26
 mvaddstr(LINES-1, 2, txt);
27 27
 standend();
... ...
@@ -10,6 +10,8 @@ int aff7segs_digit(WINDOW * win, int lig, int col, char digit);
10 10
 int aff7segs_short(WINDOW * win, int lig, int col, short value);
11 11
 int aff7segs_float(WINDOW * win, int lig, int col, float value);
12 12
 
13
+int minidigit_0(WINDOW *win, int lig, int col, char digit, int k);
14
+
13 15
 
14 16
 WINDOW * open_waterfall(char *title, int flags);
15 17
 int plot_waterfall(WINDOW *wf, int flags, float values[4]);
16 18
new file mode 100644
... ...
@@ -0,0 +1,88 @@
0
+/*
1
+ *		DD2 Monitoring
2
+ *
3
+ *	mini digits
4
+ */
5
+
6
+#include  <stdio.h>
7
+#include  <stdlib.h>
8
+#include  <string.h>
9
+#include  <ctype.h>
10
+#include  <getopt.h>
11
+#include  <ncurses.h>
12
+
13
+#include  "ecran.h"
14
+
15
+extern int	verbosity;
16
+
17
+/* ---------------------------------------------------------------- */
18
+static void makedot(WINDOW *win, int li, int col, int ch)
19
+{
20
+if ('_'==ch) {
21
+	mvwaddch(win, li, col,   ' ');
22
+	mvwaddch(win, li, col+1, ' ');
23
+	}
24
+else	{
25
+	wstandout(win);
26
+	mvwaddch(win, li, col,   ' ');
27
+	mvwaddch(win, li, col+1, ' ');
28
+	wstandend(win);
29
+	}
30
+}
31
+/* ---------------------------------------------------------------- */
32
+
33
+int minidigit_0(WINDOW *win, int lig, int col, char digit, int k)
34
+{
35
+static char LX[]    = "_X_X_X_X_X_X_X_";
36
+static char L0[]    = "XXXX_XX_XX_XXXX";
37
+static char L1[]    = "__X__X__X__X__X";
38
+static char L2[]    = "XXX__XXXXX__XXX";
39
+static char L3[]    = "XXX__XXXX__XXXX";
40
+static char L4[]    = "X_XX_XXXX__X__X";
41
+static char L5[]    = "XXXX__XXX__XXXX";
42
+static char L6[]    = "XXXX__XXXX_XXXX";
43
+static char L7[]    = "XXX__X__X__X__X";
44
+static char L8[]    = "XXXX_XXXXX_XXXX";
45
+static char L9[]    = "XXXX_XXXX__XXXX";
46
+
47
+static char Lsp[]   = "_______________";		/* space */
48
+static char Lmo[]   = "______XXX______";		/* moins */
49
+static char Lco[]   = "____X_____X____";
50
+
51
+char		*cptr;
52
+int	l, c;
53
+
54
+switch (digit) {
55
+	
56
+	case '0':	cptr = L0;		break;
57
+	case '1':	cptr = L1;		break;
58
+	case '2':	cptr = L2;		break;
59
+	case '3':	cptr = L3;		break;
60
+	case '4':	cptr = L4;		break;
61
+	case '5':	cptr = L5;		break;
62
+	case '6':	cptr = L6;		break;
63
+	case '7':	cptr = L7;		break;
64
+	case '8':	cptr = L8;		break;
65
+	case '9':	cptr = L9;		break;
66
+
67
+	case ' ':	cptr = Lsp;		break;
68
+	case '-':	cptr = Lmo;		break;
69
+	case ':':	cptr = Lco;		break;
70
+
71
+	default:	cptr = LX;		break;
72
+
73
+	}
74
+
75
+for (l=0; l<5; l++) {
76
+	for (c=0; c<3; c++) {
77
+		
78
+		makedot(win, l+lig, (c*2)+col, *cptr++);
79
+
80
+		}
81
+	}
82
+
83
+wrefresh(win);
84
+
85
+return 0;
86
+}
87
+/* ---------------------------------------------------------------- */
... ...
@@ -11,6 +11,40 @@
11 11
 
12 12
 int	verbosity;
13 13
 
14
+/* ---------------------------------------------------------------- */
15
+int demo_minidigits(int nbl, int k)
16
+{
17
+int		loop, foo;
18
+char		chaine[100];
19
+struct tm       *p_tms;
20
+time_t		temps;
21
+
22
+for (loop=0; loop<nbl; loop++) {
23
+
24
+	sprintf(chaine, "== %06X ==", loop);
25
+	message(chaine);
26
+
27
+	for (foo=0; foo<10; foo++) {
28
+		minidigit_0(stdscr, 5, 2+foo*8, '0'+foo, 0);
29
+		}
30
+	wrefresh(stdscr);
31
+	usleep(350*1000);
32
+
33
+	for (foo=0; foo<10; foo++) {
34
+		minidigit_0(stdscr, 5, 2+foo*8, ' ', 0);
35
+		}
36
+	wrefresh(stdscr);
37
+	usleep(250*1000);
38
+
39
+	temps = time(NULL);
40
+	p_tms = localtime(&temps);
41
+	(void)strftime(chaine, 100, "%H:%M", p_tms);
42
+	for (foo=0; foo<strlen(chaine); foo++) {
43
+		minidigit_0(stdscr, 15, 8+foo*8, chaine[foo], 0);
44
+		}
45
+	}
46
+return -1;
47
+}
14 48
 /* ---------------------------------------------------------------- */
15 49
 int demo_composite(int nbl, int k)
16 50
 {
... ...
@@ -32,7 +66,6 @@ for (loop=0; loop<nbl; loop++) {
32 32
 	fval = fabs(fval);
33 33
 	foo = vumetre_0(stdscr, 29, 5, fval, COLS-10);
34 34
 
35
-
36 35
 	sprintf(ligne, "%04x", loop);
37 36
 	mvaddstr(2, 1, ligne);
38 37
 	refresh();
... ...
@@ -194,6 +227,8 @@ switch (demonum) {
194 194
 	case 1:		demo_waterfall(nb_loops, 0);		break;
195 195
 	case 2:		demo_7segments(nb_loops, 0);		break;
196 196
 	case 3:		demo_composite(nb_loops, 0);		break;
197
+	case 4:		demo_minidigits(nb_loops, 0);		break;
198
+
197 199
 	default:
198 200
 		fprintf(stderr, "eyecandy #%d don't exist\n", demonum);
199 201
 		break;