some work on the eyecandy curses display

This commit is contained in:
Tonton Th 2019-01-23 22:39:03 +01:00
parent 95b1022974
commit dce67b491d
7 changed files with 60 additions and 11 deletions

View File

@ -5,8 +5,12 @@
# --------------------------------------------------
# serial input from the control cpu
input_device s /dev/ttyACM0
input_speed i 9600
input_device s /dev/ttyACM0
input_speed i 9600
# --------------------------------------------------
# some values for the eyecandy displays
eyecandy_banner s hacked by tTh
# --------------------------------------------------

View File

@ -76,7 +76,6 @@ while (fgets(line, SZ_STRINGS, fp))
continue;
}
if (CMP("input_speed")) {
config.input_speed = atoi(strtok(NULL, " \t"));
#if DEBUG_LEVEL
@ -84,6 +83,11 @@ while (fgets(line, SZ_STRINGS, fp))
#endif
}
if (CMP("eyecandy_banner")) {
config.eyecandy_banner = strdup(strtok(NULL, " \t"));
continue;
}
}
fclose(fp);

View File

@ -13,9 +13,12 @@ ecran.o: ecran.c Makefile ecran.h
waterfall.o: waterfall.c Makefile
gcc $(COPT) -c $<
vumetre.o: vumetre.c Makefile
gcc $(COPT) -c $<
# --------------- ***
OBJ = ecran.o waterfall.o 7segments.o
OBJ = ecran.o waterfall.o 7segments.o vumetre.o
t: t.c Makefile $(OBJ) ecran.h
gcc $(COPT) $< $(OBJ) -lncurses -o $@

View File

@ -9,3 +9,5 @@ int message(char *);
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);

View File

@ -11,7 +11,7 @@
int verbosity;
/* ---------------------------------------------------------------- */
void demo(int nbl, int k)
void demo_waterfall(int nbl, int k)
{
int loop, foo;
char line[100];
@ -20,7 +20,7 @@ static float rvals[4];
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 133 * 1000 * 1000;
ts.tv_nsec = 200 * 1000 * 1000;
water = open_waterfall("premier essai", 0);
@ -86,7 +86,7 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
fond_ecran(" Demonstrator ");
demo(190000, 0);
demo_waterfall(190000, 0);
/*
* plop, on a fini, restaurer la console

36
viz/curses/vumetre.c Normal file
View File

@ -0,0 +1,36 @@
/*
* DD2 Monitoring
*
* ncurses seven segment display
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <getopt.h>
#include <ncurses.h>
#include "ecran.h"
int verbosity;
/* ---------------------------------------------------------------- */
int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
{
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
__func__, win, lig, col, val, larg);
#endif
for (foo=0; foo<larg; foo++) {
mvwaddch(win, lig-1, col+foo, '*');
wrefresh(win);
}
return -1;
}
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */

View File

@ -23,7 +23,7 @@ WINDOW *win;
int l, c, w, h;
l = 1; c = 1;
w = COLS - 2; h = LINES - 3;
w = COLS; h = LINES - 3;
win = newwin(h, w, l, c);
scrollok(win, 1);
@ -50,11 +50,11 @@ else {
for (foo=0; foo<500; foo+=20) {
ligne[foo] = '.';
}
ligne[COLS-4] = '\0';
ligne[COLS-1] = '\0';
iter++;
coef_w = (float)(COLS-3) / 1024.0;
coef_w = (float)(COLS-1) / 1024.0;
#if TRACE > 1
fprintf(stderr, "COLS = %d, coef_w = %f\n", COLS, coef_w);
@ -79,7 +79,7 @@ switch (mode) {
fprintf(stderr, "%c %3d ", tag, idx);
#endif
}
ligne[COLS-4] = '\0';
ligne[COLS-1] = '\0';
#if TRACE
fprintf(stderr, "\n"); fflush(stderr);
#endif