Browse Source

introdicing the so cute minidigits !

tth 1 year ago
parent
commit
f29c8c330c
7 changed files with 133 additions and 3 deletions
  1. 0
    0
      storage/Makefile
  2. 0
    0
      storage/t.c
  3. 6
    1
      viz/curses/Makefile
  4. 1
    1
      viz/curses/ecran.c
  5. 2
    0
      viz/curses/ecran.h
  6. 88
    0
      viz/curses/minidigits.c
  7. 36
    1
      viz/curses/t.c

+ 0
- 0
storage/Makefile View File


+ 0
- 0
storage/t.c View File


+ 6
- 1
viz/curses/Makefile View File

@@ -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 25
 vumetre.o:	vumetre.c Makefile ecran.h
24 26
 	gcc $(COPT) -c $< 
25 27
 
28
+minidigits.o:	minidigits.c Makefile ecran.h
29
+	gcc $(COPT) -c $< 
30
+
26 31
 # ---------------				***
27 32
 
28 33
 t:	t.c Makefile $(ALIB) ecran.h

+ 1
- 1
viz/curses/ecran.c View File

@@ -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();

+ 2
- 0
viz/curses/ecran.h View File

@@ -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]);

+ 88
- 0
viz/curses/minidigits.c View File

@@ -0,0 +1,88 @@
1
+/*
2
+ *		DD2 Monitoring
3
+ *
4
+ *	mini digits
5
+ */
6
+
7
+#include  <stdio.h>
8
+#include  <stdlib.h>
9
+#include  <string.h>
10
+#include  <ctype.h>
11
+#include  <getopt.h>
12
+#include  <ncurses.h>
13
+
14
+#include  "ecran.h"
15
+
16
+extern int	verbosity;
17
+
18
+/* ---------------------------------------------------------------- */
19
+static void makedot(WINDOW *win, int li, int col, int ch)
20
+{
21
+if ('_'==ch) {
22
+	mvwaddch(win, li, col,   ' ');
23
+	mvwaddch(win, li, col+1, ' ');
24
+	}
25
+else	{
26
+	wstandout(win);
27
+	mvwaddch(win, li, col,   ' ');
28
+	mvwaddch(win, li, col+1, ' ');
29
+	wstandend(win);
30
+	}
31
+}
32
+/* ---------------------------------------------------------------- */
33
+
34
+int minidigit_0(WINDOW *win, int lig, int col, char digit, int k)
35
+{
36
+static char LX[]    = "_X_X_X_X_X_X_X_";
37
+static char L0[]    = "XXXX_XX_XX_XXXX";
38
+static char L1[]    = "__X__X__X__X__X";
39
+static char L2[]    = "XXX__XXXXX__XXX";
40
+static char L3[]    = "XXX__XXXX__XXXX";
41
+static char L4[]    = "X_XX_XXXX__X__X";
42
+static char L5[]    = "XXXX__XXX__XXXX";
43
+static char L6[]    = "XXXX__XXXX_XXXX";
44
+static char L7[]    = "XXX__X__X__X__X";
45
+static char L8[]    = "XXXX_XXXXX_XXXX";
46
+static char L9[]    = "XXXX_XXXX__XXXX";
47
+
48
+static char Lsp[]   = "_______________";		/* space */
49
+static char Lmo[]   = "______XXX______";		/* moins */
50
+static char Lco[]   = "____X_____X____";
51
+
52
+char		*cptr;
53
+int	l, c;
54
+
55
+switch (digit) {
56
+	
57
+	case '0':	cptr = L0;		break;
58
+	case '1':	cptr = L1;		break;
59
+	case '2':	cptr = L2;		break;
60
+	case '3':	cptr = L3;		break;
61
+	case '4':	cptr = L4;		break;
62
+	case '5':	cptr = L5;		break;
63
+	case '6':	cptr = L6;		break;
64
+	case '7':	cptr = L7;		break;
65
+	case '8':	cptr = L8;		break;
66
+	case '9':	cptr = L9;		break;
67
+
68
+	case ' ':	cptr = Lsp;		break;
69
+	case '-':	cptr = Lmo;		break;
70
+	case ':':	cptr = Lco;		break;
71
+
72
+	default:	cptr = LX;		break;
73
+
74
+	}
75
+
76
+for (l=0; l<5; l++) {
77
+	for (c=0; c<3; c++) {
78
+		
79
+		makedot(win, l+lig, (c*2)+col, *cptr++);
80
+
81
+		}
82
+	}
83
+
84
+wrefresh(win);
85
+
86
+return 0;
87
+}
88
+/* ---------------------------------------------------------------- */

+ 36
- 1
viz/curses/t.c View File

@@ -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 66
 	fval = fabs(fval);
33 67
 	foo = vumetre_0(stdscr, 29, 5, fval, COLS-10);
34 68
 
35
-
36 69
 	sprintf(ligne, "%04x", loop);
37 70
 	mvaddstr(2, 1, ligne);
38 71
 	refresh();
@@ -194,6 +227,8 @@ switch (demonum) {
194 227
 	case 1:		demo_waterfall(nb_loops, 0);		break;
195 228
 	case 2:		demo_7segments(nb_loops, 0);		break;
196 229
 	case 3:		demo_composite(nb_loops, 0);		break;
230
+	case 4:		demo_minidigits(nb_loops, 0);		break;
231
+
197 232
 	default:
198 233
 		fprintf(stderr, "eyecandy #%d don't exist\n", demonum);
199 234
 		break;

Loading…
Cancel
Save