Browse code

ready for the next step ?

tth authored on 30/01/2019 15:44:43
Showing 4 changed files
... ...
@@ -81,7 +81,7 @@ int aff7segs_digit(WINDOW * win, int lig, int col, char digit)
81 81
 {
82 82
 int		bits;
83 83
 
84
-#if TRACE
84
+#if TRACE > 1
85 85
 fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__,
86 86
 			win, lig, col, digit);
87 87
 #endif
... ...
@@ -126,7 +126,7 @@ char	buff[10];
126 126
 int	idx;
127 127
 
128 128
 sprintf(buff, "%6d", value);
129
-mvwaddstr(win, lig-1, col, buff);
129
+// mvwaddstr(win, lig-1, col, buff);
130 130
 for (idx=0; idx<strlen(buff); idx++) {
131 131
 	aff7segs_digit(win, lig, col+(idx*9), buff[idx]);
132 132
 	}
... ...
@@ -141,7 +141,7 @@ char	buff[10];
141 141
 int	idx;
142 142
 
143 143
 sprintf(buff, "%6.2f", value);
144
-mvwaddstr(win, lig-1, col, buff);
144
+// mvwaddstr(win, lig-1, col, buff);
145 145
 for (idx=0; idx<strlen(buff); idx++) {
146 146
 	aff7segs_digit(win, lig, col+(idx*9), buff[idx]);
147 147
 	}
... ...
@@ -9,14 +9,16 @@
9 9
 
10 10
 #include  "ecran.h"
11 11
 
12
-int	verbosity;
12
+extern int	verbosity;
13 13
 
14 14
 /* ---------------------------------------------------------------- */
15 15
 int message(char *txt)
16 16
 {
17 17
 static	int	pass = 0;
18 18
 
19
+#if TRACE
19 20
 fprintf(stderr, "%s [%s]\n", __func__, txt);
21
+#endif
20 22
 
21 23
 standout();
22 24
 mvhline(LINES-1, 0, '~', COLS);
... ...
@@ -37,6 +39,7 @@ standend();
37 37
 /* refresh(); */
38 38
 }
39 39
 /* ---------------------------------------------------------------- */
40
+/*	make display on the standard screen (stdscr) */
40 41
 int fond_ecran(char *title)
41 42
 {
42 43
 char			*tp;
... ...
@@ -44,7 +47,7 @@ struct utsname		utsn;
44 44
 int			foo;
45 45
 char    		buffer[200];
46 46
 
47
-tp = " DD2 MONITORING by tTh 2019 ";
47
+tp = " DD2 Monitoring by tTh 2019 ";
48 48
 if (NULL != title)	tp = title;
49 49
 
50 50
 barre_inverse(' ', 0);
... ...
@@ -52,7 +55,8 @@ standout();
52 52
 mvaddstr(0, 2, tp);
53 53
 
54 54
 if (verbosity) {
55
-	sprintf(buffer, " ecran %dx%d ", COLS, LINES);
55
+	sprintf(buffer, " ecr: %dx%d ", COLS, LINES);
56
+	fprintf(stderr, "%s ==> %s\n", __func__, buffer);
56 57
 	foo = strlen(buffer);
57 58
 	mvaddstr(0, COLS-2-foo, buffer);
58 59
 	}
... ...
@@ -3,6 +3,7 @@
3 3
 #include  <stdlib.h>
4 4
 #include  <string.h>
5 5
 #include  <time.h>
6
+#include  <math.h>
6 7
 #include  <getopt.h>
7 8
 #include  <ncurses.h>
8 9
 
... ...
@@ -21,16 +22,21 @@ float		fval;
21 21
 for (loop=0; loop<nbl; loop++) {
22 22
 	sval = (short)((loop % 1024)-512);
23 23
 
24
-	foo = aff7segs_short(stdscr, 5, 5, sval);
25
-	if (foo) message("KRKRK");
24
+	foo = aff7segs_short(stdscr, 5, 3, sval);
25
+	if (foo) message("KRKRK aff7 short");
26
+
26 27
 	fval = (float)sval / 1024.0;
27
-	foo = aff7segs_float(stdscr, 16, 5, fval);
28
-	if (foo) message("KRKRK");
28
+	foo = aff7segs_float(stdscr, 16, 3, fval);
29
+	if (foo) message("KRKRK aff7 float");
30
+
31
+	fval = fabs(fval);
32
+	foo = vumetre_0(stdscr, 29, 5, fval, COLS-10);
33
+
29 34
 
30 35
 	sprintf(ligne, "%04x", loop);
31 36
 	mvaddstr(2, 1, ligne);
32 37
 	refresh();
33
-	usleep(400*1000);
38
+	usleep(200*1000);
34 39
 	}
35 40
 return 0;
36 41
 }
... ...
@@ -12,12 +12,12 @@
12 12
 
13 13
 #include  "ecran.h"
14 14
 
15
-int	verbosity;
15
+extern int	verbosity;
16 16
 
17 17
 /* ---------------------------------------------------------------- */
18 18
 int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
19 19
 {
20
-int		foo, posc;
20
+int		foo, posc, c;
21 21
 char		ligne[100];
22 22
 
23 23
 #if DEBUG_LEVEL
... ...
@@ -25,16 +25,24 @@ fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
25 25
 		__func__, win, lig, col, val, larg);
26 26
 #endif
27 27
 
28
-posc = (int)(val * (float)larg);
28
+posc = (int)(val * (float)(larg-5));
29 29
 
30 30
 sprintf(ligne, "%6.3f", val);
31
-mvwaddstr(win, lig, 2, ligne);
31
+mvwaddstr(win, lig, 0, ligne);
32 32
 
33 33
 for (foo=0; foo<larg; foo++) {
34
-	mvwaddch(win, lig, col+foo, " #"[foo < posc]);
35
-	if (foo & 1) {
36
-		mvwaddch(win, lig-1, col+foo, '\\');
37
-		mvwaddch(win, lig+1, col+foo, '/');
34
+	c = col + foo + 2;
35
+	if (foo<posc) {
36
+		wstandout(win);
37
+		mvwaddch(win, lig, c, '#');
38
+		wstandend(win);
39
+		}
40
+	else	{
41
+		mvwaddch(win, lig, c, ' ');
42
+		}
43
+	if (!(foo%4)) {
44
+		mvwaddch(win, lig-1, c, '\\');
45
+		mvwaddch(win, lig+1, c, '/');
38 46
 		}
39 47
 	}
40 48
 wrefresh(win);