more debug

This commit is contained in:
phyto 2019-04-03 16:25:38 +02:00
parent b47e467d21
commit 9379253d16
8 changed files with 68 additions and 20 deletions

21
essai.c
View File

@ -20,27 +20,32 @@ int verbosity;
int affiche_valeurs(int sfd, int nbloops) int affiche_valeurs(int sfd, int nbloops)
{ {
int idx, foo; int idx, foo;
char ligne[200], buff[200]; char ligne[200];
float datas[4]; int Idatas[4];
float Fdatas[4];
for (idx=0; idx<nbloops; idx++) { for (idx=0; idx<nbloops; idx++) {
foo = getline_to(sfd, ligne, 100, 0); foo = getline_to(sfd, ligne, 100, 0);
if (verbosity) message(ligne);
#if DEBUG_LEVEL #if DEBUG_LEVEL
if (foo) fprintf(stderr, "get values -> %d\n", foo); if (foo) fprintf(stderr, "get values -> %d\n", foo);
#endif #endif
foo = parse4values(ligne, 'T', datas); foo = parse4_Ivalues(ligne, 'T', Idatas);
#if DEBUG_LEVEL #if DEBUG_LEVEL
if (foo) fprintf(stderr, "parse -> %d\n", foo); if (foo) fprintf(stderr, "parse I val -> %d\n", foo);
#endif #endif
values2temperature(datas); values2temperature(Idatas, Fdatas);
foo = aff7segs_float(stdscr, 3, 5, datas[0]); for (foo=0; foo<3; foo++) {
foo = aff7segs_float(stdscr, 14, 5, datas[1]); sprintf(ligne, "%4d", Idatas[foo]);
foo = aff7segs_float(stdscr, 25, 5, datas[2]); minidigit_affstr(stdscr, 3+(12*foo), 4, ligne);
aff7segs_float(stdscr, 3+(12*foo), 55, Fdatas[foo]);
}
} }
return 0; return 0;
} }

View File

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

View File

@ -52,16 +52,40 @@ return value;
* Arduino ! * Arduino !
* *
*/ */
int values2temperature(float array[4]) int values2temperature(int raw[4], float array[4])
{ {
int foo; int foo;
for (foo=0; foo<4; foo++) { for (foo=0; foo<4; foo++) {
array[foo] *= (1.1 / 1023.0 * 100.0); array[foo] = (float)raw[foo] * (1.1 / 1023.0 * 100.0);
} }
return 0; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int parse4values(char *line, char cflag, float array[4]) int parse4_Ivalues(char *line, char cflag, int array[4])
{
int foo, raw[4];
if ( cflag != *line ) {
if (verbosity) {
fprintf(stderr, "%s : line[0] 0x%x bad\n",
__func__, *line);
}
return -776;
}
foo = sscanf(line+1, "%d %d %d %d", raw, raw+1, raw+2, raw+3);
if (4 != foo) {
fprintf(stderr, "%s : sscanf -> %d\n", __func__, foo);
return -665;
}
memcpy(array, raw, 4*sizeof(int));
return 4;
}
/* ---------------------------------------------------------------- */
int parse4_Fvalues(char *line, char cflag, float array[4])
{ {
float ftmp[4]; float ftmp[4];
int foo; int foo;

View File

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

View File

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

View File

@ -11,6 +11,7 @@ int aff7segs_short(WINDOW * win, int lig, int col, short value);
int aff7segs_float(WINDOW * win, int lig, int col, float value); int aff7segs_float(WINDOW * win, int lig, int col, float value);
int minidigit_0(WINDOW *win, int lig, int col, char digit, int k); int minidigit_0(WINDOW *win, int lig, int col, char digit, int k);
int minidigit_affstr(WINDOW *win, int lig, int col, char *str);
int minidigit_HMS(WINDOW *win, int lig, int col, int k); int minidigit_HMS(WINDOW *win, int lig, int col, int k);

View File

@ -78,14 +78,26 @@ switch (digit) {
for (l=0; l<5; l++) { for (l=0; l<5; l++) {
for (c=0; c<3; c++) { for (c=0; c<3; c++) {
makedot(win, l+lig, (c*2)+col, *cptr++); makedot(win, l+lig, (c*2)+col, *cptr++);
} }
} }
wrefresh(win); wrefresh(win);
return 0;
}
/* ---------------------------------------------------------------- */
int minidigit_affstr(WINDOW *win, int lig, int col, char *str)
{
int foo, len;
len = strlen(str);
for (foo=0; foo<len; foo++) {
minidigit_0(win, lig, col, str[foo], 0);
col += 8;
}
return 0; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */

View File

@ -24,15 +24,20 @@ for (loop=0; loop<nbl; loop++) {
sprintf(chaine, ".%08d.", rand()%1000000); sprintf(chaine, ".%08d.", rand()%1000000);
/***
for (foo=0; foo<10; foo++) { for (foo=0; foo<10; foo++) {
minidigit_0(stdscr, 5, 2+foo*8, chaine[foo], 0); minidigit_0(stdscr, 5, 2+foo*8, chaine[foo], 0);
} }
***/
minidigit_affstr(stdscr, 5, 2, chaine);
wrefresh(stdscr); wrefresh(stdscr);
usleep(350*1000); usleep(350*1000);
/***
for (foo=0; foo<10; foo++) { for (foo=0; foo<10; foo++) {
minidigit_0(stdscr, 5, 2+foo*8, ' ', 0); minidigit_0(stdscr, 5, 2+foo*8, ' ', 0);
} }
***/
minidigit_HMS(stdscr, 15, 9, 0); minidigit_HMS(stdscr, 15, 9, 0);
@ -216,7 +221,7 @@ nonl(); cbreak(); noecho();
keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
fond_ecran(" Demonstrator "); fond_ecran(" Ncurses Eyecandy ");
switch (demonum) { switch (demonum) {
case 0: demo_vumetres(nb_loops, 0); break; case 0: demo_vumetres(nb_loops, 0); break;