ready for the next step ?

This commit is contained in:
tth 2019-01-30 16:44:43 +01:00
parent c52b1659b5
commit b4aa5445a2
4 changed files with 37 additions and 19 deletions

View File

@ -81,7 +81,7 @@ int aff7segs_digit(WINDOW * win, int lig, int col, char digit)
{ {
int bits; int bits;
#if TRACE #if TRACE > 1
fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__, fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__,
win, lig, col, digit); win, lig, col, digit);
#endif #endif
@ -126,7 +126,7 @@ char buff[10];
int idx; int idx;
sprintf(buff, "%6d", value); sprintf(buff, "%6d", value);
mvwaddstr(win, lig-1, col, buff); // mvwaddstr(win, lig-1, col, buff);
for (idx=0; idx<strlen(buff); idx++) { for (idx=0; idx<strlen(buff); idx++) {
aff7segs_digit(win, lig, col+(idx*9), buff[idx]); aff7segs_digit(win, lig, col+(idx*9), buff[idx]);
} }
@ -141,7 +141,7 @@ char buff[10];
int idx; int idx;
sprintf(buff, "%6.2f", value); sprintf(buff, "%6.2f", value);
mvwaddstr(win, lig-1, col, buff); // mvwaddstr(win, lig-1, col, buff);
for (idx=0; idx<strlen(buff); idx++) { for (idx=0; idx<strlen(buff); idx++) {
aff7segs_digit(win, lig, col+(idx*9), buff[idx]); aff7segs_digit(win, lig, col+(idx*9), buff[idx]);
} }

View File

@ -9,14 +9,16 @@
#include "ecran.h" #include "ecran.h"
int verbosity; extern int verbosity;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int message(char *txt) int message(char *txt)
{ {
static int pass = 0; static int pass = 0;
#if TRACE
fprintf(stderr, "%s [%s]\n", __func__, txt); fprintf(stderr, "%s [%s]\n", __func__, txt);
#endif
standout(); standout();
mvhline(LINES-1, 0, '~', COLS); mvhline(LINES-1, 0, '~', COLS);
@ -37,6 +39,7 @@ standend();
/* refresh(); */ /* refresh(); */
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* make display on the standard screen (stdscr) */
int fond_ecran(char *title) int fond_ecran(char *title)
{ {
char *tp; char *tp;
@ -44,7 +47,7 @@ struct utsname utsn;
int foo; int foo;
char buffer[200]; char buffer[200];
tp = " DD2 MONITORING by tTh 2019 "; tp = " DD2 Monitoring by tTh 2019 ";
if (NULL != title) tp = title; if (NULL != title) tp = title;
barre_inverse(' ', 0); barre_inverse(' ', 0);
@ -52,7 +55,8 @@ standout();
mvaddstr(0, 2, tp); mvaddstr(0, 2, tp);
if (verbosity) { if (verbosity) {
sprintf(buffer, " ecran %dx%d ", COLS, LINES); sprintf(buffer, " ecr: %dx%d ", COLS, LINES);
fprintf(stderr, "%s ==> %s\n", __func__, buffer);
foo = strlen(buffer); foo = strlen(buffer);
mvaddstr(0, COLS-2-foo, buffer); mvaddstr(0, COLS-2-foo, buffer);
} }

View File

@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <math.h>
#include <getopt.h> #include <getopt.h>
#include <ncurses.h> #include <ncurses.h>
@ -21,16 +22,21 @@ float fval;
for (loop=0; loop<nbl; loop++) { for (loop=0; loop<nbl; loop++) {
sval = (short)((loop % 1024)-512); sval = (short)((loop % 1024)-512);
foo = aff7segs_short(stdscr, 5, 5, sval); foo = aff7segs_short(stdscr, 5, 3, sval);
if (foo) message("KRKRK"); if (foo) message("KRKRK aff7 short");
fval = (float)sval / 1024.0; fval = (float)sval / 1024.0;
foo = aff7segs_float(stdscr, 16, 5, fval); foo = aff7segs_float(stdscr, 16, 3, fval);
if (foo) message("KRKRK"); if (foo) message("KRKRK aff7 float");
fval = fabs(fval);
foo = vumetre_0(stdscr, 29, 5, fval, COLS-10);
sprintf(ligne, "%04x", loop); sprintf(ligne, "%04x", loop);
mvaddstr(2, 1, ligne); mvaddstr(2, 1, ligne);
refresh(); refresh();
usleep(400*1000); usleep(200*1000);
} }
return 0; return 0;
} }

View File

@ -12,12 +12,12 @@
#include "ecran.h" #include "ecran.h"
int verbosity; extern int verbosity;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int vumetre_0(WINDOW *win, int lig, int col, float val, int larg) int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
{ {
int foo, posc; int foo, posc, c;
char ligne[100]; char ligne[100];
#if DEBUG_LEVEL #if DEBUG_LEVEL
@ -25,16 +25,24 @@ fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
__func__, win, lig, col, val, larg); __func__, win, lig, col, val, larg);
#endif #endif
posc = (int)(val * (float)larg); posc = (int)(val * (float)(larg-5));
sprintf(ligne, "%6.3f", val); sprintf(ligne, "%6.3f", val);
mvwaddstr(win, lig, 2, ligne); mvwaddstr(win, lig, 0, ligne);
for (foo=0; foo<larg; foo++) { for (foo=0; foo<larg; foo++) {
mvwaddch(win, lig, col+foo, " #"[foo < posc]); c = col + foo + 2;
if (foo & 1) { if (foo<posc) {
mvwaddch(win, lig-1, col+foo, '\\'); wstandout(win);
mvwaddch(win, lig+1, col+foo, '/'); mvwaddch(win, lig, c, '#');
wstandend(win);
}
else {
mvwaddch(win, lig, c, ' ');
}
if (!(foo%4)) {
mvwaddch(win, lig-1, c, '\\');
mvwaddch(win, lig+1, c, '/');
} }
} }
wrefresh(win); wrefresh(win);