Browse Source

deux vumetres, est-ce assez ?

tth 1 year ago
parent
commit
b43e3b0a1c
5 changed files with 59 additions and 14 deletions
  1. 1
    0
      .gitignore
  2. 13
    8
      viz/curses/Makefile
  3. 2
    0
      viz/curses/ecran.h
  4. 4
    5
      viz/curses/t.c
  5. 39
    1
      viz/curses/vumetre.c

+ 1
- 0
.gitignore View File

@@ -22,4 +22,5 @@ serial/*.png
22 22
 
23 23
 viz/curses/t
24 24
 viz/gnuplot/*.png
25
+viz/*.a
25 26
 

+ 13
- 8
viz/curses/Makefile View File

@@ -1,26 +1,31 @@
1 1
 # ---------------				***
2 2
 
3
-COPT = -Wall -g -DTRACE=0 
3
+COPT = -Wall -g -fpic -DTRACE=0 
4
+OBJS = ecran.o 7segments.o waterfall.o vumetre.o
5
+ALIB = ../libdd2m-viz.a
6
+
7
+# ---------------				***
8
+
9
+${ALIB}:	${OBJS}
10
+	ar r $@ $?
4 11
 
5 12
 # ---------------				***
6 13
 
7 14
 ecran.o:	ecran.c Makefile ecran.h
8 15
 	gcc $(COPT) -c $< 
9 16
 
10
-7segments.o:	7segments.c Makefile
17
+7segments.o:	7segments.c Makefile ecran.h
11 18
 	gcc $(COPT) -c $< 
12 19
 
13
-waterfall.o:	waterfall.c Makefile
20
+waterfall.o:	waterfall.c Makefile ecran.h
14 21
 	gcc $(COPT) -c $< 
15 22
 
16
-vumetre.o:	vumetre.c Makefile
23
+vumetre.o:	vumetre.c Makefile ecran.h
17 24
 	gcc $(COPT) -c $< 
18 25
 
19 26
 # ---------------				***
20 27
 
21
-OBJ = ecran.o waterfall.o 7segments.o vumetre.o
22
-
23
-t:	t.c Makefile $(OBJ) ecran.h
24
-	gcc $(COPT) $< $(OBJ) -lncurses -o $@
28
+t:	t.c Makefile $(ALIB) ecran.h
29
+	gcc $(COPT) $< $(ALIB) -lncurses -o $@
25 30
 
26 31
 # ---------------				***

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

@@ -10,4 +10,6 @@ WINDOW * open_waterfall(char *title, int flags);
10 10
 int plot_waterfall(WINDOW *wf, int flags, float values[4]);
11 11
 int close_waterfall(WINDOW *wf, int notused);
12 12
 
13
+
13 14
 int vumetre_0(WINDOW * win, int lig, int col, float val, int larg);
15
+int vumetre_1(WINDOW * win, int lig, int col, float val, int larg);

+ 4
- 5
viz/curses/t.c View File

@@ -22,14 +22,13 @@ for (loop=0; loop<nbl; loop++) {
22 22
 
23 23
 	value = (float)loop / (float)nbl;
24 24
 
25
-	for (idx=0; idx<4; idx++) {
25
+	for (idx=0; idx<8; idx++) {
26 26
 
27
-		hpos = 5 * (idx+1);
27
+		hpos = 4 * (idx+1);
28 28
 		value = drand48();
29
-		sprintf(ligne, "%6.3f", value);
30
-		mvwaddstr(stdscr, hpos, 2, ligne);
31 29
 		
32
-		vumetre_0(stdscr, hpos, 12, value, 60);
30
+		if (idx<4) vumetre_0(stdscr, hpos, 12, value, 60);
31
+		else       vumetre_1(stdscr, hpos, 12, value, 60);
33 32
 
34 33
 		}
35 34
 	

+ 39
- 1
viz/curses/vumetre.c View File

@@ -18,6 +18,7 @@ int	verbosity;
18 18
 int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
19 19
 {
20 20
 int		foo, posc;
21
+char		ligne[100];
21 22
 
22 23
 #if DEBUG_LEVEL
23 24
 fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
@@ -26,8 +27,11 @@ fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
26 27
 
27 28
 posc = (int)(val * (float)larg);
28 29
 
30
+sprintf(ligne, "%6.3f", val);
31
+mvwaddstr(win, lig, 2, ligne);
32
+
29 33
 for (foo=0; foo<larg; foo++) {
30
-	mvwaddch(win, lig, col+foo, "-*"[foo < posc]);
34
+	mvwaddch(win, lig, col+foo, " #"[foo < posc]);
31 35
 	if (foo & 1) {
32 36
 		mvwaddch(win, lig-1, col+foo, '\\');
33 37
 		mvwaddch(win, lig+1, col+foo, '/');
@@ -35,6 +39,40 @@ for (foo=0; foo<larg; foo++) {
35 39
 	}
36 40
 wrefresh(win);
37 41
 
42
+return 0;
43
+}
44
+/* ---------------------------------------------------------------- */
45
+int vumetre_1(WINDOW *win, int lig, int col, float val, int larg)
46
+{
47
+int		foo, posc;
48
+char		ligne[100];
49
+
50
+#if DEBUG_LEVEL
51
+fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
52
+		__func__, win, lig, col, val, larg);
53
+#endif
54
+
55
+posc = (int)(val * (float)larg);
56
+
57
+sprintf(ligne, "%6.3f", val);
58
+mvwaddstr(win, lig, 2, ligne);
59
+
60
+for (foo=0; foo<larg; foo++) {
61
+	if (foo < posc) {
62
+		wstandout(win);
63
+		mvwaddch(win, lig, col+foo, '|');
64
+		wstandend(win);
65
+		}
66
+	else	{
67
+		mvwaddch(win, lig, col+foo, '|');
68
+		}
69
+	if (foo & 2) {
70
+		mvwaddch(win, lig-1, col+foo, '|');
71
+		mvwaddch(win, lig+1, col+foo, '|');
72
+		}
73
+	}
74
+wrefresh(win);
75
+
38 76
 return 0;
39 77
 }
40 78
 /* ---------------------------------------------------------------- */

Loading…
Cancel
Save