DD2-monitor/viz/curses/t.c

90 lines
1.5 KiB
C
Raw Normal View History

2019-01-10 11:44:47 +11:00
#include <stdio.h>
2019-01-11 06:35:03 +11:00
#include <unistd.h>
2019-01-10 11:44:47 +11:00
#include <stdlib.h>
#include <strings.h>
#include <getopt.h>
#include <ncurses.h>
#include "ecran.h"
int verbosity;
/* ---------------------------------------------------------------- */
void demo(int nbl, int k)
{
2019-01-11 00:07:56 +11:00
int loop, foo;
char line[100];
WINDOW *water;
static float rvals[4];
2019-01-10 11:44:47 +11:00
water = open_waterfall("premier essai", 0);
for (loop=0; loop<nbl; loop++) {
2019-01-11 00:07:56 +11:00
sprintf(line, "%04X %04X", loop, rand()&0xffff);
mvwaddstr(stdscr, LINES-1, 1, line);
wrefresh(stdscr);
2019-01-10 11:44:47 +11:00
2019-01-11 00:07:56 +11:00
for (foo=0; foo<4; foo++) {
if (rand()%100<42) {
rvals[foo] += 3.8*(foo + 1);
}
if (rvals[foo] > 1023.0) {
rvals[foo] = (float)(rand() % 15);
}
2019-01-10 11:44:47 +11:00
}
2019-01-11 00:07:56 +11:00
plot_waterfall(water, 1, rvals);
if (rand()%10 < 1) sleep(1);
}
close_waterfall(water, 0);
2019-01-10 11:44:47 +11:00
}
/* ---------------------------------------------------------------- */
static void finish(int signal)
{
endwin(); exit(0);
}
/* ---------------------------------------------------------------- */
int main (int argc, char *argv[])
{
int opt;
/* set some default values */
verbosity = 0;
while ((opt = getopt(argc, argv, "v")) != -1) {
switch (opt) {
case 'v': verbosity++; break;
default:
fprintf(stderr, "%s : uh ?", argv[0]);
exit(1);
break;
}
}
initscr();
nonl(); cbreak(); noecho();
keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
2019-01-11 00:07:56 +11:00
fond_ecran(" Demonstrator ");
2019-01-10 11:44:47 +11:00
2019-01-11 06:35:03 +11:00
demo(90000, 0);
2019-01-10 11:44:47 +11:00
/*
* plop, on a fini, restaurer la console
*/
finish(0);
return 0;
}
/* ---------------------------------------------------------------- */