des minidigits pour afficher l'heure

This commit is contained in:
tth 2019-02-05 16:50:09 +01:00
parent ca420bc745
commit 1fe3a805c3
3 changed files with 24 additions and 10 deletions

View File

@ -11,6 +11,7 @@ int aff7segs_short(WINDOW * win, int lig, int col, short value);
int aff7segs_float(WINDOW * win, int lig, int col, float value); int aff7segs_float(WINDOW * win, int lig, int col, float value);
int minidigit_0(WINDOW *win, int lig, int col, char digit, int k); int minidigit_0(WINDOW *win, int lig, int col, char digit, int k);
int minidigit_HMS(WINDOW *win, int lig, int col, int k);
WINDOW * open_waterfall(char *title, int flags); WINDOW * open_waterfall(char *title, int flags);

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h>
#include <ctype.h> #include <ctype.h>
#include <getopt.h> #include <getopt.h>
#include <ncurses.h> #include <ncurses.h>
@ -88,3 +89,19 @@ wrefresh(win);
return 0; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int minidigit_HMS(WINDOW *win, int lig, int col, int k)
{
int foo;
char chaine[20];
struct tm *p_tms;
time_t temps;
temps = time(NULL);
p_tms = localtime(&temps);
(void)strftime(chaine, 19, "%H:%M:%S", p_tms);
for (foo=0; foo<strlen(chaine); foo++) {
minidigit_0(stdscr, lig, col+foo*8, chaine[foo], 0);
}
return 0;
}
/* ---------------------------------------------------------------- */

View File

@ -16,16 +16,16 @@ int demo_minidigits(int nbl, int k)
{ {
int loop, foo; int loop, foo;
char chaine[100]; char chaine[100];
struct tm *p_tms;
time_t temps;
for (loop=0; loop<nbl; loop++) { for (loop=0; loop<nbl; loop++) {
sprintf(chaine, "== %06X ==", loop); sprintf(chaine, "== %06X ==", loop);
message(chaine); message(chaine);
sprintf(chaine, ".%08d.", rand()%1000000);
for (foo=0; foo<10; foo++) { for (foo=0; foo<10; foo++) {
minidigit_0(stdscr, 5, 2+foo*8, '0'+foo, 0); minidigit_0(stdscr, 5, 2+foo*8, chaine[foo], 0);
} }
wrefresh(stdscr); wrefresh(stdscr);
usleep(350*1000); usleep(350*1000);
@ -33,15 +33,11 @@ for (loop=0; loop<nbl; loop++) {
for (foo=0; foo<10; foo++) { for (foo=0; foo<10; foo++) {
minidigit_0(stdscr, 5, 2+foo*8, ' ', 0); minidigit_0(stdscr, 5, 2+foo*8, ' ', 0);
} }
minidigit_HMS(stdscr, 15, 9, 0);
wrefresh(stdscr); wrefresh(stdscr);
usleep(250*1000); usleep(250*1000);
temps = time(NULL);
p_tms = localtime(&temps);
(void)strftime(chaine, 100, "%H.%M", p_tms);
for (foo=0; foo<strlen(chaine); foo++) {
minidigit_0(stdscr, 15, 8+foo*8, chaine[foo], 0);
}
} }
return -1; return -1;
} }