Browse Source

more debug

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


+ 3
- 3
serial/essai.sh View File

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


+ 27
- 3
serial/funcs.c View File

@ -52,16 +52,40 @@ return value;
* Arduino !
*
*/
int values2temperature(float array[4])
int values2temperature(int raw[4], float array[4])
{
int 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;
}
/* ---------------------------------------------------------------- */
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];
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);
/* auxiliary and test functions */
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]);

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

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


+ 1
- 0
viz/curses/ecran.h 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 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);


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

@ -78,14 +78,26 @@ switch (digit) {
for (l=0; l<5; l++) {
for (c=0; c<3; c++) {
makedot(win, l+lig, (c*2)+col, *cptr++);
}
}
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;
}
/* ---------------------------------------------------------------- */


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

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


Loading…
Cancel
Save