more eyecandy

This commit is contained in:
phyto 2019-01-22 15:24:49 +01:00
parent 3cc52c0983
commit 824f805ef8
3 changed files with 20 additions and 2 deletions

View File

@ -12,6 +12,14 @@
int verbosity; int verbosity;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int message(char *txt)
{
standout();
mvaddstr(LINES, 2, txt);
standend();
refresh();
return 0;
}
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
void barre_inverse(char c, int ligne) void barre_inverse(char c, int ligne)
{ {

View File

@ -3,6 +3,7 @@
*/ */
int fond_ecran(char *titre); int fond_ecran(char *titre);
int message(char *);
WINDOW * open_waterfall(char *title, int flags); WINDOW * open_waterfall(char *title, int flags);

View File

@ -2,6 +2,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <strings.h>
#include <time.h>
#include <getopt.h> #include <getopt.h>
#include <ncurses.h> #include <ncurses.h>
@ -16,7 +17,10 @@ int loop, foo;
char line[100]; char line[100];
WINDOW *water; WINDOW *water;
static float rvals[4]; static float rvals[4];
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 133 * 1000 * 1000;
water = open_waterfall("premier essai", 0); water = open_waterfall("premier essai", 0);
@ -28,7 +32,7 @@ for (loop=0; loop<nbl; loop++) {
for (foo=0; foo<4; foo++) { for (foo=0; foo<4; foo++) {
if (rand()%100<42) { if (rand()%100<42) {
rvals[foo] += 3.97 * (foo + 1); rvals[foo] += 4.04 * (foo + 1);
} }
if (rvals[foo] > 1023.0) { if (rvals[foo] > 1023.0) {
rvals[foo] = (float)(rand() % 25); rvals[foo] = (float)(rand() % 25);
@ -37,7 +41,12 @@ for (loop=0; loop<nbl; loop++) {
plot_waterfall(water, 1, rvals); plot_waterfall(water, 1, rvals);
if (rand()%10 < 1) sleep(1); /* if (rand()%10 < 1) sleep(1); */
foo = nanosleep(&ts, NULL);
if (foo) {
/* got a signal ? */
message("err on nanosleep");
}
} }
close_waterfall(water, 0); close_waterfall(water, 0);