Browse Source

deux vumetres, est-ce assez ?

master
tth 3 years 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
viz/curses/t
viz/gnuplot/*.png
viz/*.a

+ 13
- 8
viz/curses/Makefile View File

@ -1,26 +1,31 @@
# --------------- ***
COPT = -Wall -g -DTRACE=0
COPT = -Wall -g -fpic -DTRACE=0
OBJS = ecran.o 7segments.o waterfall.o vumetre.o
ALIB = ../libdd2m-viz.a
# --------------- ***
${ALIB}: ${OBJS}
ar r $@ $?
# --------------- ***
ecran.o: ecran.c Makefile ecran.h
gcc $(COPT) -c $<
7segments.o: 7segments.c Makefile
7segments.o: 7segments.c Makefile ecran.h
gcc $(COPT) -c $<
waterfall.o: waterfall.c Makefile
waterfall.o: waterfall.c Makefile ecran.h
gcc $(COPT) -c $<
vumetre.o: vumetre.c Makefile
vumetre.o: vumetre.c Makefile ecran.h
gcc $(COPT) -c $<
# --------------- ***
OBJ = ecran.o waterfall.o 7segments.o vumetre.o
t: t.c Makefile $(OBJ) ecran.h
gcc $(COPT) $< $(OBJ) -lncurses -o $@
t: t.c Makefile $(ALIB) ecran.h
gcc $(COPT) $< $(ALIB) -lncurses -o $@
# --------------- ***

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

@ -10,4 +10,6 @@ WINDOW * open_waterfall(char *title, int flags);
int plot_waterfall(WINDOW *wf, int flags, float values[4]);
int close_waterfall(WINDOW *wf, int notused);
int vumetre_0(WINDOW * win, int lig, int col, float val, int larg);
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++) {
value = (float)loop / (float)nbl;
for (idx=0; idx<4; idx++) {
for (idx=0; idx<8; idx++) {
hpos = 5 * (idx+1);
hpos = 4 * (idx+1);
value = drand48();
sprintf(ligne, "%6.3f", value);
mvwaddstr(stdscr, hpos, 2, ligne);
vumetre_0(stdscr, hpos, 12, value, 60);
if (idx<4) vumetre_0(stdscr, hpos, 12, value, 60);
else vumetre_1(stdscr, hpos, 12, value, 60);
}


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

@ -18,6 +18,7 @@ int verbosity;
int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
{
int foo, posc;
char ligne[100];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
@ -26,8 +27,11 @@ fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
posc = (int)(val * (float)larg);
sprintf(ligne, "%6.3f", val);
mvwaddstr(win, lig, 2, ligne);
for (foo=0; foo<larg; foo++) {
mvwaddch(win, lig, col+foo, "-*"[foo < posc]);
mvwaddch(win, lig, col+foo, " #"[foo < posc]);
if (foo & 1) {
mvwaddch(win, lig-1, col+foo, '\\');
mvwaddch(win, lig+1, col+foo, '/');
@ -35,6 +39,40 @@ for (foo=0; foo<larg; foo++) {
}
wrefresh(win);
return 0;
}
/* ---------------------------------------------------------------- */
int vumetre_1(WINDOW *win, int lig, int col, float val, int larg)
{
int foo, posc;
char ligne[100];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
__func__, win, lig, col, val, larg);
#endif
posc = (int)(val * (float)larg);
sprintf(ligne, "%6.3f", val);
mvwaddstr(win, lig, 2, ligne);
for (foo=0; foo<larg; foo++) {
if (foo < posc) {
wstandout(win);
mvwaddch(win, lig, col+foo, '|');
wstandend(win);
}
else {
mvwaddch(win, lig, col+foo, '|');
}
if (foo & 2) {
mvwaddch(win, lig-1, col+foo, '|');
mvwaddch(win, lig+1, col+foo, '|');
}
}
wrefresh(win);
return 0;
}
/* ---------------------------------------------------------------- */


Loading…
Cancel
Save