Browse Source

more debug

phyto 1 year ago
parent
commit
9379253d16
8 changed files with 68 additions and 20 deletions
  1. 13
    8
      essai.c
  2. 3
    3
      serial/essai.sh
  3. 27
    3
      serial/funcs.c
  4. 3
    2
      serial/serial.h
  5. 1
    1
      simulator/rdtemp/rdtemp.ino
  6. 1
    0
      viz/curses/ecran.h
  7. 14
    2
      viz/curses/minidigits.c
  8. 6
    1
      viz/curses/t.c

+ 13
- 8
essai.c View File

@@ -20,27 +20,32 @@ int	verbosity;
20 20
 int affiche_valeurs(int sfd, int nbloops)
21 21
 {
22 22
 int		idx, foo;
23
-char		ligne[200], buff[200];
24
-float		datas[4];
23
+char		ligne[200];
24
+int		Idatas[4];
25
+float		Fdatas[4];
25 26
 
26 27
 for (idx=0; idx<nbloops; idx++) {
27 28
 
28 29
 	foo = getline_to(sfd, ligne, 100, 0);
30
+	if (verbosity) message(ligne);
31
+	
29 32
 #if DEBUG_LEVEL
30 33
 	if (foo) fprintf(stderr, "get values -> %d\n", foo);
31 34
 #endif
32 35
 
33
-	foo = parse4values(ligne, 'T', datas);
36
+	foo = parse4_Ivalues(ligne, 'T', Idatas);
34 37
 #if DEBUG_LEVEL
35
-	if (foo) fprintf(stderr, "parse -> %d\n", foo); 
38
+	if (foo) fprintf(stderr, "parse I val -> %d\n", foo); 
36 39
 #endif
37 40
 
38
-	values2temperature(datas);
41
+	values2temperature(Idatas, Fdatas);
39 42
 
40
-	foo = aff7segs_float(stdscr,  3, 5, datas[0]);
41
-	foo = aff7segs_float(stdscr, 14, 5, datas[1]);
42
-	foo = aff7segs_float(stdscr, 25, 5, datas[2]);
43
+	for (foo=0; foo<3; foo++) {
44
+		sprintf(ligne, "%4d", Idatas[foo]);
45
+		minidigit_affstr(stdscr, 3+(12*foo), 4, ligne);
43 46
 
47
+		aff7segs_float(stdscr, 3+(12*foo), 55, Fdatas[foo]);
48
+		}
44 49
 	}
45 50
 return 0;
46 51
 }

+ 3
- 3
serial/essai.sh View File

@@ -1,16 +1,16 @@
1 1
 #!/bin/bash
2 2
 
3
-DEVICE="/dev/ttyACM0"
3
+DEVICE="/dev/ttyACM1"
4 4
 DATAFILE="foo.dat"
5 5
 TMPFILE="/tmp/dd2data"
6 6
 
7 7
 IMAGE="graphe.png"
8
-NB_READ=10
8
+NB_READ=500
9 9
 
10 10
 ./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
11 11
 
12 12
 gnuplot << __EOC__
13
-set term png 	size 1600,640
13
+set term png 	size 3200,640
14 14
 set output 	"${IMAGE}"
15 15
 set grid
16 16
 set title	"Temperature dans le Double Dragon 2"

+ 27
- 3
serial/funcs.c View File

@@ -52,16 +52,40 @@ return value;
52 52
  *   Arduino !
53 53
  *
54 54
  */
55
-int values2temperature(float array[4])
55
+int values2temperature(int raw[4], float array[4])
56 56
 {
57 57
 int	foo;
58 58
 for (foo=0; foo<4; foo++) {
59
- 	array[foo] *= (1.1 / 1023.0 * 100.0);
59
+ 	array[foo] = (float)raw[foo] * (1.1 / 1023.0 * 100.0);
60 60
 	}
61 61
 return 0;
62 62
 }
63 63
 /* ---------------------------------------------------------------- */
64
-int parse4values(char *line, char cflag, float array[4])
64
+int parse4_Ivalues(char *line, char cflag, int array[4])
65
+{
66
+int		foo, raw[4];
67
+
68
+if ( cflag != *line ) {
69
+	if (verbosity) {
70
+		fprintf(stderr, "%s : line[0] 0x%x bad\n",
71
+					__func__, *line);
72
+		}
73
+	return -776;
74
+	}
75
+
76
+foo = sscanf(line+1, "%d %d %d %d", raw, raw+1, raw+2, raw+3);
77
+if (4 != foo) {
78
+	fprintf(stderr, "%s : sscanf -> %d\n", __func__, foo);
79
+	return -665;
80
+	}
81
+	
82
+memcpy(array, raw, 4*sizeof(int));
83
+
84
+return 4;
85
+}
86
+/* ---------------------------------------------------------------- */
87
+
88
+int parse4_Fvalues(char *line, char cflag, float array[4])
65 89
 {
66 90
 float		ftmp[4];
67 91
 int		foo;

+ 3
- 2
serial/serial.h View File

@@ -17,8 +17,9 @@ int getline_to(int fd, char *where, int szm, int to_ms);
17 17
 /* auxiliary and test functions */
18 18
 
19 19
 int parseXvalue(char *asciidatas, char id);
20
-int values2temperature(float array[4]);
20
+int values2temperature(int raw[4], float array[4]);
21 21
 
22
-int parse4values(char *line, char cflag, float array[4]);
22
+int parse4_Ivalues(char *line, char cflag,   int array[4]);
23
+int parse4_Fvalues(char *line, char cflag, float array[4]);
23 24
 
24 25
 

+ 1
- 1
simulator/rdtemp/rdtemp.ino View File

@@ -33,7 +33,7 @@ void updatevalues(short *ptr)
33 33
   digitalWrite(LED_BUILTIN, HIGH);
34 34
   for (foo=0; foo<NBVAL; foo++) {
35 35
     ptr[foo] = analogRead(adc_pins[foo]);
36
-    delay(100);
36
+    delay(200);
37 37
     }
38 38
   digitalWrite(LED_BUILTIN, LOW);
39 39
 }

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

@@ -11,6 +11,7 @@ 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 13
 int minidigit_0(WINDOW *win, int lig, int col, char digit, int k);
14
+int minidigit_affstr(WINDOW *win, int lig, int col, char *str);
14 15
 int minidigit_HMS(WINDOW *win, int lig, int col, int k);
15 16
 
16 17
 

+ 14
- 2
viz/curses/minidigits.c View File

@@ -78,14 +78,26 @@ switch (digit) {
78 78
 
79 79
 for (l=0; l<5; l++) {
80 80
 	for (c=0; c<3; c++) {
81
-		
82 81
 		makedot(win, l+lig, (c*2)+col, *cptr++);
83
-
84 82
 		}
85 83
 	}
86 84
 
87 85
 wrefresh(win);
88 86
 
87
+return 0;
88
+}
89
+/* ---------------------------------------------------------------- */
90
+int minidigit_affstr(WINDOW *win, int lig, int col, char *str)
91
+{
92
+int	foo, len;
93
+
94
+len = strlen(str);
95
+
96
+for (foo=0; foo<len; foo++) {
97
+	minidigit_0(win, lig, col, str[foo], 0);
98
+	col += 8;
99
+	}
100
+
89 101
 return 0;
90 102
 }
91 103
 /* ---------------------------------------------------------------- */

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

@@ -24,15 +24,20 @@ for (loop=0; loop<nbl; loop++) {
24 24
 
25 25
 	sprintf(chaine, ".%08d.", rand()%1000000);
26 26
 
27
+	/***
27 28
 	for (foo=0; foo<10; foo++) {
28 29
 		minidigit_0(stdscr, 5, 2+foo*8, chaine[foo], 0);
29 30
 		}
31
+	***/
32
+	minidigit_affstr(stdscr, 5, 2, chaine);
30 33
 	wrefresh(stdscr);
31 34
 	usleep(350*1000);
32 35
 
36
+/***
33 37
 	for (foo=0; foo<10; foo++) {
34 38
 		minidigit_0(stdscr, 5, 2+foo*8, ' ', 0);
35 39
 		}
40
+***/
36 41
 
37 42
 	minidigit_HMS(stdscr, 15, 9, 0);
38 43
 
@@ -216,7 +221,7 @@ nonl();         cbreak();       noecho();
216 221
 
217 222
 keypad(stdscr, TRUE);           /* acces aux touches 'curseur' */
218 223
 
219
-fond_ecran(" Demonstrator ");
224
+fond_ecran(" Ncurses Eyecandy ");
220 225
 
221 226
 switch (demonum) {
222 227
 	case 0:		demo_vumetres(nb_loops, 0);		break;

Loading…
Cancel
Save