Browse Source

des minidigits pour afficher l'heure

tth 1 year ago
parent
commit
1fe3a805c3
3 changed files with 24 additions and 10 deletions
  1. 1
    0
      viz/curses/ecran.h
  2. 17
    0
      viz/curses/minidigits.c
  3. 6
    10
      viz/curses/t.c

+ 1
- 0
viz/curses/ecran.h View File

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

+ 17
- 0
viz/curses/minidigits.c View File

@@ -7,6 +7,7 @@
7 7
 #include  <stdio.h>
8 8
 #include  <stdlib.h>
9 9
 #include  <string.h>
10
+#include	<time.h>
10 11
 #include  <ctype.h>
11 12
 #include  <getopt.h>
12 13
 #include  <ncurses.h>
@@ -88,3 +89,19 @@ wrefresh(win);
88 89
 return 0;
89 90
 }
90 91
 /* ---------------------------------------------------------------- */
92
+int minidigit_HMS(WINDOW *win, int lig, int col, int k)
93
+{
94
+int		foo;
95
+char		chaine[20];
96
+struct tm       *p_tms;
97
+time_t		temps;
98
+
99
+temps = time(NULL);
100
+p_tms = localtime(&temps);
101
+(void)strftime(chaine, 19, "%H:%M:%S", p_tms);
102
+for (foo=0; foo<strlen(chaine); foo++) {
103
+	minidigit_0(stdscr, lig, col+foo*8, chaine[foo], 0);
104
+	}
105
+return 0;
106
+}
107
+/* ---------------------------------------------------------------- */

+ 6
- 10
viz/curses/t.c View File

@@ -16,16 +16,16 @@ int demo_minidigits(int nbl, int k)
16 16
 {
17 17
 int		loop, foo;
18 18
 char		chaine[100];
19
-struct tm       *p_tms;
20
-time_t		temps;
21 19
 
22 20
 for (loop=0; loop<nbl; loop++) {
23 21
 
24 22
 	sprintf(chaine, "== %06X ==", loop);
25 23
 	message(chaine);
26 24
 
25
+	sprintf(chaine, ".%08d.", rand()%1000000);
26
+
27 27
 	for (foo=0; foo<10; foo++) {
28
-		minidigit_0(stdscr, 5, 2+foo*8, '0'+foo, 0);
28
+		minidigit_0(stdscr, 5, 2+foo*8, chaine[foo], 0);
29 29
 		}
30 30
 	wrefresh(stdscr);
31 31
 	usleep(350*1000);
@@ -33,15 +33,11 @@ for (loop=0; loop<nbl; loop++) {
33 33
 	for (foo=0; foo<10; foo++) {
34 34
 		minidigit_0(stdscr, 5, 2+foo*8, ' ', 0);
35 35
 		}
36
+
37
+	minidigit_HMS(stdscr, 15, 9, 0);
38
+
36 39
 	wrefresh(stdscr);
37 40
 	usleep(250*1000);
38
-
39
-	temps = time(NULL);
40
-	p_tms = localtime(&temps);
41
-	(void)strftime(chaine, 100, "%H.%M", p_tms);
42
-	for (foo=0; foo<strlen(chaine); foo++) {
43
-		minidigit_0(stdscr, 15, 8+foo*8, chaine[foo], 0);
44
-		}
45 41
 	}
46 42
 return -1;
47 43
 }

Loading…
Cancel
Save